Changeset 55397 in webkit
- Timestamp:
- Mar 1, 2010 8:08:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r55379 r55397 1 2010-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 1 17 2010-03-01 Gavin Barraclough <barraclough@apple.com> 2 18 -
trunk/JavaScriptCore/runtime/PropertySlot.h
r55002 r55397 35 35 #define JSC_VALUE_SLOT_MARKER 0 36 36 #define JSC_REGISTER_SLOT_MARKER reinterpret_cast<GetValueFunc>(1) 37 #define INDEX_GETTER_MARKER reinterpret_cast<GetValueFunc>(2) 37 38 38 39 class PropertySlot { … … 53 54 54 55 typedef JSValue (*GetValueFunc)(ExecState*, const Identifier&, const PropertySlot&); 56 typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned); 55 57 56 58 JSValue getValue(ExecState* exec, const Identifier& propertyName) const … … 60 62 if (m_getValue == JSC_REGISTER_SLOT_MARKER) 61 63 return (*m_data.registerSlot).jsValue(); 64 if (m_getValue == INDEX_GETTER_MARKER) 65 return m_getIndexValue(exec, slotBase(), index()); 62 66 return m_getValue(exec, propertyName, *this); 63 67 } … … 69 73 if (m_getValue == JSC_REGISTER_SLOT_MARKER) 70 74 return (*m_data.registerSlot).jsValue(); 75 if (m_getValue == INDEX_GETTER_MARKER) 76 return m_getIndexValue(exec, m_slotBase, m_data.index); 71 77 return m_getValue(exec, Identifier::from(exec, propertyName), *this); 72 78 } … … 133 139 ASSERT(getValue); 134 140 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) 139 146 { 140 147 ASSERT(slotBase); 141 ASSERT(getValue); 142 m_getValue = getValue; 148 ASSERT(getIndexValue); 149 m_getValue = INDEX_GETTER_MARKER; 150 m_getIndexValue = getIndexValue; 143 151 m_slotBase = slotBase; 144 152 m_data.index = index; … … 213 221 214 222 GetValueFunc m_getValue; 223 GetIndexValueFunc m_getIndexValue; 215 224 216 225 JSValue m_slotBase; -
trunk/WebCore/ChangeLog
r55390 r55397 1 2010-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 1 18 2010-03-01 Chris Fleizach <cfleizach@apple.com> 2 19 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r54835 r55397 135 135 } 136 136 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());137 static JSValue indexGetter(ExecState* exec, JSValue slotBase, unsigned index) 138 { 139 return toJS(exec, static_cast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->child(index)->domWindow()); 140 140 } 141 141 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r55311 r55397 747 747 # Index getter 748 748 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"); 750 750 } 751 751 if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { … … 1713 1713 1714 1714 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"); 1716 1716 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"); 1718 1718 if (IndexGetterReturnsStrings($implClassName)) { 1719 1719 $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"); 1721 1721 } 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"); 1723 1723 } 1724 1724 push(@implContent, "}\n"); -
trunk/WebCore/bridge/runtime_array.cpp
r55262 r55397 57 57 } 58 58 59 JSValue RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)59 JSValue RuntimeArray::indexGetter(ExecState* exec, JSValue slotBase, unsigned index) 60 60 { 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); 63 63 } 64 64 -
trunk/WebCore/bridge/runtime_array.h
r55262 r55397 63 63 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags; 64 64 static JSValue lengthGetter(ExecState*, const Identifier&, const PropertySlot&); 65 static JSValue indexGetter(ExecState*, const Identifier&, const PropertySlot&);65 static JSValue indexGetter(ExecState*, JSValue, unsigned); 66 66 }; 67 67
Note: See TracChangeset
for help on using the changeset viewer.