Changeset 239557 in webkit


Ignore:
Timestamp:
Dec 28, 2018 8:24:29 PM (5 years ago)
Author:
yusukesuzuki@slowstart.org
Message:

[JSC] Remove one indirection in JSObject::toStringName
https://bugs.webkit.org/show_bug.cgi?id=193037

Reviewed by Keith Miller.

Source/JavaScriptCore:

We should not have additional one-level indirection in JSObject::toStringName.
JSObject::toStringName is dispatched through methodTable. Even after that, we
need to call JSObject::className function through methodTable again. But className
function is rarely defined. So instead of introducing this indirection here,
classes having className functions should have toStringName function too. This can
remove one-level indirection in toStringName in major cases.

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:

(JSC::JSCallbackObject<Parent>::toStringName):

  • debugger/DebuggerScope.cpp:

(JSC::DebuggerScope::toStringName):

  • debugger/DebuggerScope.h:
  • runtime/JSObject.cpp:

(JSC::JSObject::toStringName):

Source/WebCore:

Use old JSObject::toStringName function here.

  • bindings/js/JSDOMConstructorBase.cpp:

(WebCore::JSDOMConstructorBase::className):
(WebCore::JSDOMConstructorBase::toStringName):

  • bindings/js/JSDOMConstructorBase.h:

(WebCore::JSDOMConstructorBase::className): Deleted.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObject.h

    r239191 r239557  
    188188private:
    189189    static String className(const JSObject*, VM&);
     190    static String toStringName(const JSObject*, ExecState*);
    190191
    191192    static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r237009 r239557  
    141141
    142142template <class Parent>
     143String JSCallbackObject<Parent>::toStringName(const JSObject* object, ExecState* exec)
     144{
     145    VM& vm = exec->vm();
     146    const ClassInfo* info = object->classInfo(vm);
     147    ASSERT(info);
     148    return info->methodTable.className(object, vm);
     149}
     150
     151template <class Parent>
    143152bool JSCallbackObject<Parent>::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    144153{
  • trunk/Source/JavaScriptCore/ChangeLog

    r239556 r239557  
     12018-12-28  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        [JSC] Remove one indirection in JSObject::toStringName
     4        https://bugs.webkit.org/show_bug.cgi?id=193037
     5
     6        Reviewed by Keith Miller.
     7
     8        We should not have additional one-level indirection in JSObject::toStringName.
     9        JSObject::toStringName is dispatched through methodTable. Even after that, we
     10        need to call JSObject::className function through methodTable again. But className
     11        function is rarely defined. So instead of introducing this indirection here,
     12        classes having className functions should have toStringName function too. This can
     13        remove one-level indirection in toStringName in major cases.
     14
     15        * API/JSCallbackObject.h:
     16        * API/JSCallbackObjectFunctions.h:
     17        (JSC::JSCallbackObject<Parent>::toStringName):
     18        * debugger/DebuggerScope.cpp:
     19        (JSC::DebuggerScope::toStringName):
     20        * debugger/DebuggerScope.h:
     21        * runtime/JSObject.cpp:
     22        (JSC::JSObject::toStringName):
     23
    1242018-12-27  Alex Christensen  <achristensen@webkit.org>
    225
  • trunk/Source/JavaScriptCore/debugger/DebuggerScope.cpp

    r233765 r239557  
    7878}
    7979
     80String DebuggerScope::toStringName(const JSObject* object, ExecState* exec)
     81{
     82    const DebuggerScope* scope = jsCast<const DebuggerScope*>(object);
     83    // We cannot assert that scope->isValid() because the TypeProfiler may encounter an invalidated
     84    // DebuggerScope in its log entries. We just need to handle it appropriately as below.
     85    if (!scope->isValid())
     86        return String();
     87    JSObject* thisObject = JSScope::objectAtScope(scope->jsScope());
     88    return thisObject->methodTable(exec->vm())->toStringName(thisObject, exec);
     89}
     90
    8091bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    8192{
  • trunk/Source/JavaScriptCore/debugger/DebuggerScope.h

    r233765 r239557  
    4343    static void visitChildren(JSCell*, SlotVisitor&);
    4444    static String className(const JSObject*, VM&);
     45    static String toStringName(const JSObject*, ExecState*);
    4546    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
    4647    static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r239427 r239557  
    520520    const ClassInfo* info = object->classInfo(vm);
    521521    ASSERT(info);
    522     return info->methodTable.className(object, vm);
     522    return info->className;
    523523}
    524524
  • trunk/Source/WebCore/ChangeLog

    r239556 r239557  
     12018-12-28  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        [JSC] Remove one indirection in JSObject::toStringName
     4        https://bugs.webkit.org/show_bug.cgi?id=193037
     5
     6        Reviewed by Keith Miller.
     7
     8        Use old JSObject::toStringName function here.
     9
     10        * bindings/js/JSDOMConstructorBase.cpp:
     11        (WebCore::JSDOMConstructorBase::className):
     12        (WebCore::JSDOMConstructorBase::toStringName):
     13        * bindings/js/JSDOMConstructorBase.h:
     14        (WebCore::JSDOMConstructorBase::className): Deleted.
     15
    1162018-12-27  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.cpp

    r233122 r239557  
    4444}
    4545
     46String JSDOMConstructorBase::className(const JSObject*, JSC::VM&)
     47{
     48    return "Function"_s;
     49}
     50
     51String JSDOMConstructorBase::toStringName(const JSObject* object, JSC::ExecState* exec)
     52{
     53    VM& vm = exec->vm();
     54    const ClassInfo* info = object->classInfo(vm);
     55    ASSERT(info);
     56    return info->methodTable.className(object, vm);
     57}
     58
    4659} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.h

    r233765 r239557  
    3939
    4040    static String className(const JSObject*, JSC::VM&);
     41    static String toStringName(const JSObject*, JSC::ExecState*);
    4142    static JSC::CallType getCallData(JSCell*, JSC::CallData&);
    4243};
     
    4748}
    4849
    49 inline String JSDOMConstructorBase::className(const JSObject*, JSC::VM&)
    50 {
    51     return "Function"_s;
    52 }
    53 
    5450} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.