Ignore:
Timestamp:
Mar 1, 2010, 8:08:22 PM (15 years ago)
Author:
[email protected]
Message:

2010-03-01 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

PropertySlot::getValue(ExecState, unsigned) unnecessarily converts index to an Identifier
https://bugs.webkit.org/show_bug.cgi?id=35561

Fix this by defining a separate property getter function for index getters. This allows
us to pass an unsigned number without the conversion to an Identifier. We then update
setCustomIndex to take this new getter type.

  • runtime/PropertySlot.h: (JSC::PropertySlot::getValue): (JSC::PropertySlot::setCustom): (JSC::PropertySlot::setCustomIndex):

2010-03-01 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

PropertySlot::getValue(ExecState, unsigned) unnecessarily converts index to an Identifier
https://bugs.webkit.org/show_bug.cgi?id=35561

Update bindings generation and the few manual indexing getters we have to use
the new PropertySlot API.

  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::indexGetter):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/runtime_array.cpp: (JSC::RuntimeArray::indexGetter):
  • bridge/runtime_array.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/PropertySlot.h

    r55002 r55397  
    3535#define JSC_VALUE_SLOT_MARKER 0
    3636#define JSC_REGISTER_SLOT_MARKER reinterpret_cast<GetValueFunc>(1)
     37#define INDEX_GETTER_MARKER reinterpret_cast<GetValueFunc>(2)
    3738
    3839    class PropertySlot {
     
    5354
    5455        typedef JSValue (*GetValueFunc)(ExecState*, const Identifier&, const PropertySlot&);
     56        typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
    5557
    5658        JSValue getValue(ExecState* exec, const Identifier& propertyName) const
     
    6062            if (m_getValue == JSC_REGISTER_SLOT_MARKER)
    6163                return (*m_data.registerSlot).jsValue();
     64            if (m_getValue == INDEX_GETTER_MARKER)
     65                return m_getIndexValue(exec, slotBase(), index());
    6266            return m_getValue(exec, propertyName, *this);
    6367        }
     
    6973            if (m_getValue == JSC_REGISTER_SLOT_MARKER)
    7074                return (*m_data.registerSlot).jsValue();
     75            if (m_getValue == INDEX_GETTER_MARKER)
     76                return m_getIndexValue(exec, m_slotBase, m_data.index);
    7177            return m_getValue(exec, Identifier::from(exec, propertyName), *this);
    7278        }
     
    133139            ASSERT(getValue);
    134140            m_getValue = getValue;
    135             m_slotBase = slotBase;
    136         }
    137 
    138         void setCustomIndex(JSValue slotBase, unsigned index, GetValueFunc getValue)
     141            m_getIndexValue = 0;
     142            m_slotBase = slotBase;
     143        }
     144
     145        void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue)
    139146        {
    140147            ASSERT(slotBase);
    141             ASSERT(getValue);
    142             m_getValue = getValue;
     148            ASSERT(getIndexValue);
     149            m_getValue = INDEX_GETTER_MARKER;
     150            m_getIndexValue = getIndexValue;
    143151            m_slotBase = slotBase;
    144152            m_data.index = index;
     
    213221
    214222        GetValueFunc m_getValue;
     223        GetIndexValueFunc m_getIndexValue;
    215224       
    216225        JSValue m_slotBase;
Note: See TracChangeset for help on using the changeset viewer.