Changeset 99256 in webkit


Ignore:
Timestamp:
Nov 3, 2011, 6:32:18 PM (14 years ago)
Author:
mhahnenberg@apple.com
Message:

De-virtualize JSObject::getPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=71306

Reviewed by Darin Adler.

Source/JavaScriptCore:

Added getPropertyNames to the MethodTable, changed all the virtual
implementations of getPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.

  • API/JSObjectRef.cpp:

(JSObjectCopyPropertyNames):

(JSC::DebuggerActivation::getOwnPropertyNames):

  • runtime/ClassInfo.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::getPropertyNames):

  • runtime/JSCell.h:
  • runtime/JSObject.cpp:

(JSC::JSObject::getPropertyNames):
(JSC::JSObject::getOwnPropertyNames):

  • runtime/JSObject.h:
  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::create):

  • runtime/ScopeChain.cpp:

(JSC::ScopeChainNode::print):

  • runtime/Structure.cpp:

(JSC::Structure::getPropertyNamesFromStructure):

  • runtime/Structure.h:

Source/JavaScriptGlue:

Added getPropertyNames to the MethodTable, changed all the virtual
implementations of getPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.

  • JSUtils.cpp:

(KJSValueToCFTypeInternal):

  • JSValueWrapper.cpp:

(JSValueWrapper::JSObjectCopyPropertyNames):

Source/WebCore:

No new tests.

Added getPropertyNames to the MethodTable, changed all the virtual
implementations of getPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getPropertyNames):

  • bindings/js/JSDOMWindowShell.cpp:

(WebCore::JSDOMWindowShell::getPropertyNames):

  • bindings/js/JSDOMWindowShell.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • bridge/NP_jsobject.cpp:

(_NPN_Enumerate):

  • bridge/qt/qt_runtime.cpp:

(JSC::Bindings::convertValueToQVariantMap):

Source/WebKit/mac:

Added getPropertyNames to the MethodTable, changed all the virtual
implementations of getPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::enumerate):

Source/WebKit2:

Added getPropertyNames to the MethodTable, changed all the virtual
implementations of getPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::enumerate):

Location:
trunk/Source
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r99167 r99256  
    507507    JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(globalData);
    508508    PropertyNameArray array(globalData);
    509     jsObject->getPropertyNames(exec, array);
     509    jsObject->methodTable()->getPropertyNames(jsObject, exec, array, ExcludeDontEnumProperties);
    510510
    511511    size_t size = array.size();
  • trunk/Source/JavaScriptCore/ChangeLog

    r99239 r99256  
     12011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSObject::getPropertyNames
     4        https://bugs.webkit.org/show_bug.cgi?id=71306
     5
     6        Reviewed by Darin Adler.
     7
     8        Added getPropertyNames to the MethodTable, changed all the virtual
     9        implementations of getPropertyNames to static ones, and replaced
     10        all call sites with corresponding lookups in the MethodTable.
     11
     12        * API/JSObjectRef.cpp:
     13        (JSObjectCopyPropertyNames):
     14        * JavaScriptCore.exp:
     15        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     16        * debugger/DebuggerActivation.cpp:
     17        (JSC::DebuggerActivation::getOwnPropertyNames):
     18        * runtime/ClassInfo.h:
     19        * runtime/JSCell.cpp:
     20        (JSC::JSCell::getPropertyNames):
     21        * runtime/JSCell.h:
     22        * runtime/JSObject.cpp:
     23        (JSC::JSObject::getPropertyNames):
     24        (JSC::JSObject::getOwnPropertyNames):
     25        * runtime/JSObject.h:
     26        * runtime/JSPropertyNameIterator.cpp:
     27        (JSC::JSPropertyNameIterator::create):
     28        * runtime/ScopeChain.cpp:
     29        (JSC::ScopeChainNode::print):
     30        * runtime/Structure.cpp:
     31        (JSC::Structure::getPropertyNamesFromStructure):
     32        * runtime/Structure.h:
     33
    1342011-11-03  Darin Adler  <darin@apple.com>
    235
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r99238 r99256  
    313313__ZN3JSC8JSObject13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
    314314__ZN3JSC8JSObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
    315 __ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
     315__ZN3JSC8JSObject16getPropertyNamesEPS0_PNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
    316316__ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
    317317__ZN3JSC8JSObject17preventExtensionsERNS_12JSGlobalDataE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r99238 r99256  
    204204    ?getOwnPropertySlotByIndex@JSObject@JSC@@SA_NPAVJSCell@2@PAVExecState@2@IAAVPropertySlot@2@@Z
    205205    ?getPropertyDescriptor@JSObject@JSC@@QAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
    206     ?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
     206    ?getPropertyNames@JSObject@JSC@@SAXPAV12@PAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
    207207    ?getSlice@ArgList@JSC@@QBEXHAAV12@@Z
    208208    ?getString@JSCell@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
  • trunk/Source/JavaScriptCore/debugger/DebuggerActivation.cpp

    r99223 r99256  
    8888{
    8989    DebuggerActivation* thisObject = static_cast<DebuggerActivation*>(object);
    90     thisObject->m_activation->getPropertyNames(exec, propertyNames, mode);
     90    thisObject->m_activation->methodTable()->getPropertyNames(thisObject->m_activation.get(), exec, propertyNames, mode);
    9191}
    9292
  • trunk/Source/JavaScriptCore/runtime/ClassInfo.h

    r99238 r99256  
    7676        GetOwnPropertyNamesFunctionPtr getOwnPropertyNames;
    7777
     78        typedef void (*GetPropertyNamesFunctionPtr)(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
     79        GetPropertyNamesFunctionPtr getPropertyNames;
     80
    7881        typedef UString (*ClassNameFunctionPtr)(const JSObject*);
    7982        ClassNameFunctionPtr className;
     
    117120        &ClassName::defaultValue, \
    118121        &ClassName::getOwnPropertyNames, \
     122        &ClassName::getPropertyNames, \
    119123        &ClassName::className, \
    120124        &ClassName::hasInstance, \
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r99238 r99256  
    192192}
    193193
     194void JSCell::getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode)
     195{
     196    ASSERT_NOT_REACHED();
     197}
     198
    194199} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r99238 r99256  
    145145        static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
    146146        static NO_RETURN_DUE_TO_ASSERT void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
     147        static NO_RETURN_DUE_TO_ASSERT void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
    147148        static UString className(const JSObject*);
    148149        static bool hasInstance(JSObject*, ExecState*, JSValue, JSValue prototypeProperty);
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r99238 r99256  
    496496}
    497497
    498 void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    499 {
    500     methodTable()->getOwnPropertyNames(this, exec, propertyNames, mode);
    501 
    502     if (prototype().isNull())
    503         return;
    504 
    505     JSObject* prototype = asObject(this->prototype());
     498void JSObject::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     499{
     500    object->methodTable()->getOwnPropertyNames(object, exec, propertyNames, mode);
     501
     502    if (object->prototype().isNull())
     503        return;
     504
     505    JSObject* prototype = asObject(object->prototype());
    506506    while(1) {
    507507        if (prototype->structure()->typeInfo().overridesGetPropertyNames()) {
    508             prototype->getPropertyNames(exec, propertyNames, mode);
     508            prototype->methodTable()->getPropertyNames(prototype, exec, propertyNames, mode);
    509509            break;
    510510        }
     
    519519void JSObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    520520{
    521     object->structure()->getPropertyNames(exec->globalData(), propertyNames, mode);
     521    object->structure()->getPropertyNamesFromStructure(exec->globalData(), propertyNames, mode);
    522522    if (!object->staticFunctionsReified())
    523523        getClassPropertyNames(exec, object->classInfo(), propertyNames, mode);
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r99238 r99256  
    127127        static bool hasInstance(JSObject*, ExecState*, JSValue, JSValue prototypeProperty);
    128128
    129         virtual void getPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
    130129        static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
     130        static void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
    131131
    132132        JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

    r96346 r99256  
    5353
    5454    PropertyNameArray propertyNames(exec);
    55     o->getPropertyNames(exec, propertyNames);
     55    o->methodTable()->getPropertyNames(o, exec, propertyNames, ExcludeDontEnumProperties);
    5656    size_t numCacheableSlots = 0;
    5757    if (!o->structure()->hasNonEnumerableProperties() && !o->structure()->hasGetterSetterProperties()
  • trunk/Source/JavaScriptCore/runtime/ScopeChain.cpp

    r96346 r99256  
    4242        JSObject* o = scopeIter->get();
    4343        PropertyNameArray propertyNames(globalObject->globalExec());
    44         o->getPropertyNames(globalObject->globalExec(), propertyNames);
     44        o->methodTable()->getPropertyNames(o, globalObject->globalExec(), propertyNames, ExcludeDontEnumProperties);
    4545        PropertyNameArray::const_iterator propEnd = propertyNames.end();
    4646
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r98647 r99256  
    721721}
    722722
    723 void Structure::getPropertyNames(JSGlobalData& globalData, PropertyNameArray& propertyNames, EnumerationMode mode)
     723void Structure::getPropertyNamesFromStructure(JSGlobalData& globalData, PropertyNameArray& propertyNames, EnumerationMode mode)
    724724{
    725725    materializePropertyMapIfNecessary(globalData);
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r99126 r99256  
    157157        void setEnumerationCache(JSGlobalData&, JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h.
    158158        JSPropertyNameIterator* enumerationCache(); // Defined in JSPropertyNameIterator.h.
    159         void getPropertyNames(JSGlobalData&, PropertyNameArray&, EnumerationMode mode);
     159        void getPropertyNamesFromStructure(JSGlobalData&, PropertyNameArray&, EnumerationMode);
    160160
    161161        bool staticFunctionsReified()
  • trunk/Source/JavaScriptGlue/ChangeLog

    r99223 r99256  
     12011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSObject::getPropertyNames
     4        https://bugs.webkit.org/show_bug.cgi?id=71306
     5
     6        Reviewed by Darin Adler.
     7
     8        Added getPropertyNames to the MethodTable, changed all the virtual
     9        implementations of getPropertyNames to static ones, and replaced
     10        all call sites with corresponding lookups in the MethodTable.
     11
     12        * JSUtils.cpp:
     13        (KJSValueToCFTypeInternal):
     14        * JSValueWrapper.cpp:
     15        (JSValueWrapper::JSObjectCopyPropertyNames):
     16
    1172011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
    218
  • trunk/Source/JavaScriptGlue/JSUtils.cpp

    r99223 r99256  
    278278                        if (globalObject && (globalObject->Flags() & kJSFlagConvertAssociativeArray)) {
    279279                            PropertyNameArray propNames(exec);
    280                             object->getPropertyNames(exec, propNames);
     280                            object->methodTable()->getPropertyNames(object, exec, propNames, ExcludeDontEnumProperties);
    281281                            PropertyNameArray::const_iterator iter = propNames.begin();
    282282                            PropertyNameArray::const_iterator end = propNames.end();
     
    317317                        // Not an array, just treat it like a dictionary which contains (property name, property value) pairs
    318318                        PropertyNameArray propNames(exec);
    319                         object->getPropertyNames(exec, propNames);
     319                        object->methodTable()->getPropertyNames(object, exec, propNames, ExcludeDontEnumProperties);
    320320                        {
    321321                            result = CFDictionaryCreateMutable(0,
  • trunk/Source/JavaScriptGlue/JSValueWrapper.cpp

    r98415 r99256  
    7878        JSObject* object = ptr->GetValue().toObject(exec);
    7979        PropertyNameArray propNames(exec);
    80         object->getPropertyNames(exec, propNames);
     80        object->methodTable()->getPropertyNames(object, exec, propNames, ExcludeDontEnumProperties);
    8181        PropertyNameArray::const_iterator iterator = propNames.begin();
    8282
  • trunk/Source/WebCore/ChangeLog

    r99255 r99256  
     12011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSObject::getPropertyNames
     4        https://bugs.webkit.org/show_bug.cgi?id=71306
     5
     6        Reviewed by Darin Adler.
     7
     8        No new tests.
     9
     10        Added getPropertyNames to the MethodTable, changed all the virtual
     11        implementations of getPropertyNames to static ones, and replaced
     12        all call sites with corresponding lookups in the MethodTable.
     13
     14        * bindings/js/JSDOMWindowCustom.cpp:
     15        (WebCore::JSDOMWindow::getPropertyNames):
     16        * bindings/js/JSDOMWindowShell.cpp:
     17        (WebCore::JSDOMWindowShell::getPropertyNames):
     18        * bindings/js/JSDOMWindowShell.h:
     19        * bindings/scripts/CodeGeneratorJS.pm:
     20        (GenerateHeader):
     21        * bridge/NP_jsobject.cpp:
     22        (_NPN_Enumerate):
     23        * bridge/qt/qt_runtime.cpp:
     24        (JSC::Bindings::convertValueToQVariantMap):
     25
    1262011-11-02  Xiaomei Ji  <xji@chromium.org>
    227
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r99126 r99256  
    369369}
    370370
    371 void JSDOMWindow::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    372 {
     371void JSDOMWindow::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     372{
     373    JSDOMWindow* thisObject = static_cast<JSDOMWindow*>(object);
    373374    // Only allow the window to enumerated by frames in the same origin.
    374     if (!allowsAccessFrom(exec))
     375    if (!thisObject->allowsAccessFrom(exec))
    375376        return;
    376     Base::getPropertyNames(exec, propertyNames, mode);
     377    Base::getPropertyNames(thisObject, exec, propertyNames, mode);
    377378}
    378379
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp

    r99223 r99256  
    124124}
    125125
    126 void JSDOMWindowShell::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     126void JSDOMWindowShell::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    127127{
    128     window()->getPropertyNames(exec, propertyNames, mode);
     128    JSDOMWindowShell* thisObject = static_cast<JSDOMWindowShell*>(object);
     129    thisObject->window()->methodTable()->getPropertyNames(thisObject->window(), exec, propertyNames, mode);
    129130}
    130131
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h

    r99223 r99256  
    8585        virtual void putWithAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, unsigned attributes);
    8686        static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName);
    87         virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);
    8887        static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
     88        static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
    8989        static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);
    9090        static void defineSetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r99244 r99256  
    829829    # Custom getPropertyNames function exists on DOMWindow
    830830    if ($interfaceName eq "DOMWindow") {
    831         push(@headerContent, "    virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n");
     831        push(@headerContent, "    static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode mode = JSC::ExcludeDontEnumProperties);\n");
    832832        $structureFlags{"JSC::OverridesGetPropertyNames"} = 1;
    833833    }
  • trunk/Source/WebCore/bridge/NP_jsobject.cpp

    r99239 r99256  
    461461        PropertyNameArray propertyNames(exec);
    462462
    463         obj->imp->getPropertyNames(exec, propertyNames);
     463        obj->imp->methodTable()->getPropertyNames(obj->imp, exec, propertyNames, ExcludeDontEnumProperties);
    464464        unsigned size = static_cast<unsigned>(propertyNames.size());
    465465        // FIXME: This should really call NPN_MemAlloc but that's in WebKit
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r99126 r99256  
    190190
    191191    PropertyNameArray properties(exec);
    192     object->getPropertyNames(exec, properties);
     192    object->methodTable()->getPropertyNames(object, exec, properties, ExcludeDontEnumProperties);
    193193    PropertyNameArray::const_iterator it = properties.begin();
    194194    QVariantMap result;
  • trunk/Source/WebKit/mac/ChangeLog

    r99239 r99256  
     12011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSObject::getPropertyNames
     4        https://bugs.webkit.org/show_bug.cgi?id=71306
     5
     6        Reviewed by Darin Adler.
     7
     8        Added getPropertyNames to the MethodTable, changed all the virtual
     9        implementations of getPropertyNames to static ones, and replaced
     10        all call sites with corresponding lookups in the MethodTable.
     11
     12        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     13        (WebKit::NetscapePluginInstanceProxy::enumerate):
     14
    1152011-11-02  Darin Adler  <darin@apple.com>
    216
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r98593 r99256  
    12311231 
    12321232    PropertyNameArray propertyNames(exec);
    1233     object->getPropertyNames(exec, propertyNames);
     1233    object->methodTable()->getPropertyNames(object, exec, propertyNames, ExcludeDontEnumProperties);
    12341234
    12351235    RetainPtr<NSMutableArray*> array(AdoptNS, [[NSMutableArray alloc] init]);
  • trunk/Source/WebKit2/ChangeLog

    r99250 r99256  
     12011-11-03  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSObject::getPropertyNames
     4        https://bugs.webkit.org/show_bug.cgi?id=71306
     5
     6        Reviewed by Darin Adler.
     7
     8        Added getPropertyNames to the MethodTable, changed all the virtual
     9        implementations of getPropertyNames to static ones, and replaced
     10        all call sites with corresponding lookups in the MethodTable.
     11
     12        * WebProcess/Plugins/Netscape/NPJSObject.cpp:
     13        (WebKit::NPJSObject::enumerate):
     14
    1152011-11-03  Anders Carlsson  <andersca@apple.com>
    216
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp

    r98593 r99256  
    237237
    238238    PropertyNameArray propertyNames(exec);
    239     m_jsObject->getPropertyNames(exec, propertyNames);
     239    m_jsObject->methodTable()->getPropertyNames(m_jsObject.get(), exec, propertyNames, ExcludeDontEnumProperties);
    240240
    241241    NPIdentifier* nameIdentifiers = npnMemNewArray<NPIdentifier>(propertyNames.size());
Note: See TracChangeset for help on using the changeset viewer.