Changeset 55397 in webkit


Ignore:
Timestamp:
Mar 1, 2010 8:08:22 PM (14 years ago)
Author:
oliver@apple.com
Message:

2010-03-01 Oliver Hunt <oliver@apple.com>

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 <oliver@apple.com>

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:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r55379 r55397  
     12010-03-01  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        PropertySlot::getValue(ExecState, unsigned) unnecessarily converts index to an Identifier
     6        https://bugs.webkit.org/show_bug.cgi?id=35561
     7
     8        Fix this by defining a separate property getter function for index getters.  This allows
     9        us to pass an unsigned number without the conversion to an Identifier.  We then update
     10        setCustomIndex to take this new getter type.
     11
     12        * runtime/PropertySlot.h:
     13        (JSC::PropertySlot::getValue):
     14        (JSC::PropertySlot::setCustom):
     15        (JSC::PropertySlot::setCustomIndex):
     16
    1172010-03-01  Gavin Barraclough  <barraclough@apple.com>
    218
  • 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;
  • trunk/WebCore/ChangeLog

    r55390 r55397  
     12010-03-01  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        PropertySlot::getValue(ExecState, unsigned) unnecessarily converts index to an Identifier
     6        https://bugs.webkit.org/show_bug.cgi?id=35561
     7
     8        Update bindings generation and the few manual indexing getters we have to use
     9        the new PropertySlot API.
     10
     11        * bindings/js/JSDOMWindowCustom.cpp:
     12        (WebCore::indexGetter):
     13        * bindings/scripts/CodeGeneratorJS.pm:
     14        * bridge/runtime_array.cpp:
     15        (JSC::RuntimeArray::indexGetter):
     16        * bridge/runtime_array.h:
     17
    1182010-03-01  Chris Fleizach  <cfleizach@apple.com>
    219
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r54835 r55397  
    135135}
    136136
    137 static JSValue indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    138 {
    139     return toJS(exec, static_cast<JSDOMWindow*>(asObject(slot.slotBase()))->impl()->frame()->tree()->child(slot.index())->domWindow());
     137static JSValue indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
     138{
     139    return toJS(exec, static_cast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->child(index)->domWindow());
    140140}
    141141
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r55311 r55397  
    747747    # Index getter
    748748    if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
    749         push(@headerContent, "    static JSC::JSValue indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&);\n");
     749        push(@headerContent, "    static JSC::JSValue indexGetter(JSC::ExecState*, JSC::JSValue, unsigned);\n");
    750750    }
    751751    if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
     
    17131713
    17141714    if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
    1715         push(@implContent, "\nJSValue ${className}::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)\n");
     1715        push(@implContent, "\nJSValue ${className}::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)\n");
    17161716        push(@implContent, "{\n");
    1717         push(@implContent, "    ${className}* thisObj = static_cast<$className*>(asObject(slot.slotBase()));\n");
     1717        push(@implContent, "    ${className}* thisObj = static_cast<$className*>(asObject(slotBase));\n");
    17181718        if (IndexGetterReturnsStrings($implClassName)) {
    17191719            $implIncludes{"KURL.h"} = 1;
    1720             push(@implContent, "    return jsStringOrNull(exec, thisObj->impl()->item(slot.index()));\n");
     1720            push(@implContent, "    return jsStringOrNull(exec, thisObj->impl()->item(index));\n");
    17211721        } else {
    1722             push(@implContent, "    return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
     1722            push(@implContent, "    return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(index));\n");
    17231723        }
    17241724        push(@implContent, "}\n");
  • trunk/WebCore/bridge/runtime_array.cpp

    r55262 r55397  
    5757}
    5858
    59 JSValue RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
     59JSValue RuntimeArray::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
    6060{
    61     RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
    62     return thisObj->getConcreteArray()->valueAt(exec, slot.index());
     61    RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slotBase));
     62    return thisObj->getConcreteArray()->valueAt(exec, index);
    6363}
    6464
  • trunk/WebCore/bridge/runtime_array.h

    r55262 r55397  
    6363    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
    6464    static JSValue lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    65     static JSValue indexGetter(ExecState*, const Identifier&, const PropertySlot&);
     65    static JSValue indexGetter(ExecState*, JSValue, unsigned);
    6666};
    6767   
Note: See TracChangeset for help on using the changeset viewer.