Changeset 98593 in webkit


Ignore:
Timestamp:
Oct 27, 2011, 10:01:38 AM (14 years ago)
Author:
mhahnenberg@apple.com
Message:

De-virtualize JSCell::toThisObject
https://bugs.webkit.org/show_bug.cgi?id=70958

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.

  • API/JSContextRef.cpp:
  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • runtime/ClassInfo.h:
  • runtime/JSActivation.cpp:

(JSC::JSActivation::toThisObject):

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

(JSC::JSCell::toThisObject):

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

(JSC::JSObject::put):
(JSC::JSObject::toThisObject):

  • runtime/JSObject.h:

(JSC::JSValue::toThisObject):

  • runtime/JSStaticScopeObject.cpp:

(JSC::JSStaticScopeObject::toThisObject):

  • runtime/JSStaticScopeObject.h:
  • runtime/JSString.cpp:

(JSC::JSString::toThisObject):

  • runtime/JSString.h:
  • runtime/StrictEvalActivation.cpp:

(JSC::StrictEvalActivation::toThisObject):

  • runtime/StrictEvalActivation.h:

Source/WebCore:

No new tests.

Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::toThisObject):

  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSErrorHandler.cpp:

(WebCore::JSErrorHandler::handleEvent):

  • bridge/NP_jsobject.cpp:

(_NPN_Invoke):

  • bridge/qt/qt_runtime.cpp:

(JSC::Bindings::QtRuntimeConnectionMethod::call):

Source/WebKit/mac:

Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::invoke):
(WebKit::NetscapePluginInstanceProxy::invokeDefault):

Source/WebKit2:

Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::invoke):

Location:
trunk/Source
Files:
27 edited

Legend:

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

    r95510 r98593  
    164164
    165165    // It is necessary to call toThisObject to get the wrapper object when used with WebCore.
    166     return toRef(exec->lexicalGlobalObject()->toThisObject(exec));
     166    return toRef(exec->lexicalGlobalObject()->methodTable()->toThisObject(exec->lexicalGlobalObject(), exec));
    167167}
    168168
  • trunk/Source/JavaScriptCore/ChangeLog

    r98574 r98593  
     12011-10-27  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::toThisObject
     4        https://bugs.webkit.org/show_bug.cgi?id=70958
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Converted all instances of toThisObject to static functions,
     9        added toThisObject to the MethodTable, and replaced all call sites
     10        with a corresponding lookup in the MethodTable.
     11
     12        * API/JSContextRef.cpp:
     13        * JavaScriptCore.exp:
     14        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     15        * runtime/ClassInfo.h:
     16        * runtime/JSActivation.cpp:
     17        (JSC::JSActivation::toThisObject):
     18        * runtime/JSActivation.h:
     19        * runtime/JSCell.cpp:
     20        (JSC::JSCell::toThisObject):
     21        * runtime/JSCell.h:
     22        * runtime/JSObject.cpp:
     23        (JSC::JSObject::put):
     24        (JSC::JSObject::toThisObject):
     25        * runtime/JSObject.h:
     26        (JSC::JSValue::toThisObject):
     27        * runtime/JSStaticScopeObject.cpp:
     28        (JSC::JSStaticScopeObject::toThisObject):
     29        * runtime/JSStaticScopeObject.h:
     30        * runtime/JSString.cpp:
     31        (JSC::JSString::toThisObject):
     32        * runtime/JSString.h:
     33        * runtime/StrictEvalActivation.cpp:
     34        (JSC::StrictEvalActivation::toThisObject):
     35        * runtime/StrictEvalActivation.h:
     36
    1372011-10-27  Yuqiang Xian  <yuqiang.xian@intel.com>
    238
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r98501 r98593  
    306306__ZN3JSC8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE
    307307__ZN3JSC8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
     308__ZN3JSC8JSObject12toThisObjectEPNS_6JSCellEPNS_9ExecStateE
    308309__ZN3JSC8JSObject13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
    309310__ZN3JSC8JSObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
     
    551552__ZNK3JSC19SourceProviderCache8byteSizeEv
    552553__ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
    553 __ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE
    554554__ZNK3JSC6JSCell8toNumberEPNS_9ExecStateE
    555555__ZNK3JSC6JSCell8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
     
    570570__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj
    571571__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
    572 __ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
    573572__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
    574573__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r98501 r98593  
    343343    ?toStringDecimal@DecimalNumber@WTF@@QBEIPA_WI@Z
    344344    ?toStringExponential@DecimalNumber@WTF@@QBEIPA_WI@Z
    345     ?toThisObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@@Z
    346     ?toThisObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@@Z
    347     ?toThisObject@JSString@JSC@@EBEPAVJSObject@2@PAVExecState@2@@Z
    348345    ?toThisObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@@Z
    349346    ?toUInt32@Identifier@JSC@@SAIABVUString@2@AA_N@Z
  • trunk/Source/JavaScriptCore/runtime/ClassInfo.h

    r98367 r98593  
    5959        typedef bool (*GetOwnPropertySlotByIndexFunctionPtr)(JSCell*, ExecState*, unsigned, PropertySlot&);
    6060        GetOwnPropertySlotByIndexFunctionPtr getOwnPropertySlotByIndex;
     61
     62        typedef JSObject* (*ToThisObjectFunctionPtr)(JSCell*, ExecState*);
     63        ToThisObjectFunctionPtr toThisObject;
    6164    };
    6265
     
    7174        &ClassName::getOwnPropertySlot, \
    7275        &ClassName::getOwnPropertySlotByIndex, \
     76        &ClassName::toThisObject, \
    7377    }, \
    7478    sizeof(ClassName)
  • trunk/Source/JavaScriptCore/runtime/JSActivation.cpp

    r98501 r98593  
    204204}
    205205
    206 JSObject* JSActivation::toThisObject(ExecState* exec) const
     206JSObject* JSActivation::toThisObject(JSCell*, ExecState* exec)
    207207{
    208208    return exec->globalThisValue();
  • trunk/Source/JavaScriptCore/runtime/JSActivation.h

    r98501 r98593  
    7070        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
    7171
    72         virtual JSObject* toThisObject(ExecState*) const;
     72        static JSObject* toThisObject(JSCell*, ExecState*);
    7373
    7474        void copyRegisters(JSGlobalData&);
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r98501 r98593  
    113113}
    114114
    115 JSObject* JSCell::toThisObject(ExecState* exec) const
     115JSObject* JSCell::toThisObject(JSCell* cell, ExecState* exec)
    116116{
    117     return toObject(exec, exec->lexicalGlobalObject());
     117    return cell->toObject(exec, exec->lexicalGlobalObject());
    118118}
    119119
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r98525 r98593  
    9797        static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
    9898
    99         virtual JSObject* toThisObject(ExecState*) const;
     99        static JSObject* toThisObject(JSCell*, ExecState*);
    100100
    101101        void* vptr() const { ASSERT(!isZapped()); return *reinterpret_cast<void* const*>(this); }
     
    296296    }
    297297
    298     inline JSObject* JSValue::toThisObject(ExecState* exec) const
    299     {
    300         return isCell() ? asCell()->toThisObject(exec) : toThisObjectSlowCase(exec);
    301     }
    302 
    303298    template <typename T> void* allocateCell(Heap& heap)
    304299    {
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r98501 r98593  
    174174
    175175                // If this is WebCore's global object then we need to substitute the shell.
    176                 call(exec, setterFunc, callType, callData, thisObject->toThisObject(exec), args);
     176                call(exec, setterFunc, callType, callData, thisObject->methodTable()->toThisObject(thisObject, exec), args);
    177177                return;
    178178            }
     
    558558}
    559559
    560 JSObject* JSObject::toThisObject(ExecState*) const
    561 {
    562     return const_cast<JSObject*>(this);
     560JSObject* JSObject::toThisObject(JSCell* cell, ExecState*)
     561{
     562    return static_cast<JSObject*>(cell);
    563563}
    564564
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r98501 r98593  
    136136        UString toString(ExecState*) const;
    137137
    138         virtual JSObject* toThisObject(ExecState*) const;
     138        static JSObject* toThisObject(JSCell*, ExecState*);
    139139        virtual JSObject* unwrappedObject();
    140140
     
    498498{
    499499    return isCell() && asCell()->inherits(classInfo);
     500}
     501
     502inline JSObject* JSValue::toThisObject(ExecState* exec) const
     503{
     504    return isCell() ? asCell()->methodTable()->toThisObject(asCell(), exec) : toThisObjectSlowCase(exec);
    500505}
    501506
  • trunk/Source/JavaScriptCore/runtime/JSStaticScopeObject.cpp

    r98501 r98593  
    4545}
    4646
    47 JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const
     47JSObject* JSStaticScopeObject::toThisObject(JSCell*, ExecState* exec)
    4848{
    4949    return exec->globalThisValue();
  • trunk/Source/JavaScriptCore/runtime/JSStaticScopeObject.h

    r98501 r98593  
    4444        static void visitChildren(JSCell*, SlotVisitor&);
    4545        bool isDynamicScope(bool& requiresDynamicChecks) const;
    46         virtual JSObject* toThisObject(ExecState*) const;
     46        static JSObject* toThisObject(JSCell*, ExecState*);
    4747        static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
    4848        static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r98501 r98593  
    197197}
    198198
    199 JSObject* JSString::toThisObject(ExecState* exec) const
    200 {
    201     return StringObject::create(exec, exec->lexicalGlobalObject(), const_cast<JSString*>(this));
     199JSObject* JSString::toThisObject(JSCell* cell, ExecState* exec)
     200{
     201    return StringObject::create(exec, exec->lexicalGlobalObject(), static_cast<JSString*>(cell));
    202202}
    203203
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r98501 r98593  
    248248        void outOfMemory(ExecState*) const;
    249249
    250         virtual JSObject* toThisObject(ExecState*) const;
     250        static JSObject* toThisObject(JSCell*, ExecState*);
    251251
    252252        // Actually getPropertySlot, not getOwnPropertySlot (see JSCell).
  • trunk/Source/JavaScriptCore/runtime/StrictEvalActivation.cpp

    r98422 r98593  
    4141}
    4242
    43 JSObject* StrictEvalActivation::toThisObject(ExecState* exec) const
     43JSObject* StrictEvalActivation::toThisObject(JSCell*, ExecState* exec)
    4444{
    4545    return exec->globalThisValue();
  • trunk/Source/JavaScriptCore/runtime/StrictEvalActivation.h

    r98422 r98593  
    4343
    4444    static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
    45     virtual JSObject* toThisObject(ExecState*) const;
     45    static JSObject* toThisObject(JSCell*, ExecState*);
    4646
    4747    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
  • trunk/Source/WebCore/ChangeLog

    r98592 r98593  
     12011-10-27  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::toThisObject
     4        https://bugs.webkit.org/show_bug.cgi?id=70958
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        No new tests.
     9
     10        Converted all instances of toThisObject to static functions,
     11        added toThisObject to the MethodTable, and replaced all call sites
     12        with a corresponding lookup in the MethodTable.
     13
     14        * bindings/js/JSDOMWindowBase.cpp:
     15        (WebCore::JSDOMWindowBase::toThisObject):
     16        * bindings/js/JSDOMWindowBase.h:
     17        * bindings/js/JSErrorHandler.cpp:
     18        (WebCore::JSErrorHandler::handleEvent):
     19        * bridge/NP_jsobject.cpp:
     20        (_NPN_Invoke):
     21        * bridge/qt/qt_runtime.cpp:
     22        (JSC::Bindings::QtRuntimeConnectionMethod::call):
     23
    1242011-10-27  Adam Roben  <aroben@apple.com>
    225
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp

    r96547 r98593  
    146146}
    147147
    148 JSObject* JSDOMWindowBase::toThisObject(ExecState*) const
    149 {
    150     return shell();
     148JSObject* JSDOMWindowBase::toThisObject(JSCell* cell, ExecState*)
     149{
     150    return static_cast<JSDOMWindowBase*>(cell)->shell();
    151151}
    152152
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h

    r96446 r98593  
    6969        virtual bool allowsAccessFrom(const JSC::JSGlobalObject*) const;
    7070       
    71         virtual JSC::JSObject* toThisObject(JSC::ExecState*) const;
     71        static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
    7272        JSDOMWindowShell* shell() const;
    7373
  • trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp

    r98164 r98593  
    9292        DynamicGlobalObjectScope globalObjectScope(globalData, globalData.dynamicGlobalObject ? globalData.dynamicGlobalObject : globalObject);
    9393
    94         JSValue thisValue = globalObject->toThisObject(exec);
     94        JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec);
    9595
    9696        globalData.timeoutChecker.start();
  • trunk/Source/WebCore/bridge/NP_jsobject.cpp

    r98422 r98593  
    242242        RefPtr<JSGlobalData> globalData(&exec->globalData());
    243243        globalData->timeoutChecker.start();
    244         JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp->toThisObject(exec), argList);
     244        JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp->methodTable()->toThisObject(obj->imp, exec), argList);
    245245        globalData->timeoutChecker.stop();
    246246
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r98501 r98593  
    16061606    if (sender) {
    16071607
    1608         JSObject* thisObject = exec->lexicalGlobalObject()->toThisObject(exec);
     1608        JSObject* thisObject = exec->lexicalGlobalObject()->methodTable()->toThisObject(exec->lexicalGlobalObject(), exec);
    16091609        JSObject* funcObject = 0;
    16101610
  • trunk/Source/WebKit/mac/ChangeLog

    r98422 r98593  
     12011-10-27  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::toThisObject
     4        https://bugs.webkit.org/show_bug.cgi?id=70958
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Converted all instances of toThisObject to static functions,
     9        added toThisObject to the MethodTable, and replaced all call sites
     10        with a corresponding lookup in the MethodTable.
     11
     12        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     13        (WebKit::NetscapePluginInstanceProxy::invoke):
     14        (WebKit::NetscapePluginInstanceProxy::invokeDefault):
     15
    1162011-10-25  Mark Hahnenberg  <mhahnenberg@apple.com>
    217
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r98422 r98593  
    917917    RefPtr<JSGlobalData> globalData = pluginWorld()->globalData();
    918918    globalData->timeoutChecker.start();
    919     JSValue value = call(exec, function, callType, callData, object->toThisObject(exec), argList);
     919    JSValue value = call(exec, function, callType, callData, object->methodTable()->toThisObject(object, exec), argList);
    920920    globalData->timeoutChecker.stop();
    921921       
     
    952952    RefPtr<JSGlobalData> globalData = pluginWorld()->globalData();
    953953    globalData->timeoutChecker.start();
    954     JSValue value = call(exec, object, callType, callData, object->toThisObject(exec), argList);
     954    JSValue value = call(exec, object, callType, callData, object->methodTable()->toThisObject(object, exec), argList);
    955955    globalData->timeoutChecker.stop();
    956956   
  • trunk/Source/WebKit2/ChangeLog

    r98588 r98593  
     12011-10-27  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        De-virtualize JSCell::toThisObject
     4        https://bugs.webkit.org/show_bug.cgi?id=70958
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Converted all instances of toThisObject to static functions,
     9        added toThisObject to the MethodTable, and replaced all call sites
     10        with a corresponding lookup in the MethodTable.
     11
     12        * WebProcess/Plugins/Netscape/NPJSObject.cpp:
     13        (WebKit::NPJSObject::invoke):
     14
    1152011-10-27  Adam Roben  <aroben@apple.com>
    216
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp

    r98422 r98593  
    292292
    293293    exec->globalData().timeoutChecker.start();
    294     JSValue value = JSC::call(exec, function, callType, callData, m_jsObject->toThisObject(exec), argumentList);
     294    JSValue value = JSC::call(exec, function, callType, callData, m_jsObject->methodTable()->toThisObject(m_jsObject.get(), exec), argumentList);
    295295    exec->globalData().timeoutChecker.stop();
    296296
Note: See TracChangeset for help on using the changeset viewer.