Title: [239557] trunk/Source
Revision
239557
Author
[email protected]
Date
2018-12-28 20:24:29 -0800 (Fri, 28 Dec 2018)

Log Message

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

Reviewed by Keith Miller.

Source/_javascript_Core:

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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSCallbackObject.h (239556 => 239557)


--- trunk/Source/_javascript_Core/API/JSCallbackObject.h	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/API/JSCallbackObject.h	2018-12-29 04:24:29 UTC (rev 239557)
@@ -187,6 +187,7 @@
 
 private:
     static String className(const JSObject*, VM&);
+    static String toStringName(const JSObject*, ExecState*);
 
     static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 

Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (239556 => 239557)


--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2018-12-29 04:24:29 UTC (rev 239557)
@@ -140,6 +140,15 @@
 }
 
 template <class Parent>
+String JSCallbackObject<Parent>::toStringName(const JSObject* object, ExecState* exec)
+{
+    VM& vm = exec->vm();
+    const ClassInfo* info = object->classInfo(vm);
+    ASSERT(info);
+    return info->methodTable.className(object, vm);
+}
+
+template <class Parent>
 bool JSCallbackObject<Parent>::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
     VM& vm = exec->vm();

Modified: trunk/Source/_javascript_Core/ChangeLog (239556 => 239557)


--- trunk/Source/_javascript_Core/ChangeLog	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-12-29 04:24:29 UTC (rev 239557)
@@ -1,3 +1,26 @@
+2018-12-28  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Remove one indirection in JSObject::toStringName
+        https://bugs.webkit.org/show_bug.cgi?id=193037
+
+        Reviewed by Keith Miller.
+
+        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):
+
 2018-12-27  Alex Christensen  <[email protected]>
 
         Resurrect Mac CMake build

Modified: trunk/Source/_javascript_Core/debugger/DebuggerScope.cpp (239556 => 239557)


--- trunk/Source/_javascript_Core/debugger/DebuggerScope.cpp	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/debugger/DebuggerScope.cpp	2018-12-29 04:24:29 UTC (rev 239557)
@@ -77,6 +77,17 @@
     return thisObject->methodTable(vm)->className(thisObject, vm);
 }
 
+String DebuggerScope::toStringName(const JSObject* object, ExecState* exec)
+{
+    const DebuggerScope* scope = jsCast<const DebuggerScope*>(object);
+    // We cannot assert that scope->isValid() because the TypeProfiler may encounter an invalidated
+    // DebuggerScope in its log entries. We just need to handle it appropriately as below.
+    if (!scope->isValid())
+        return String();
+    JSObject* thisObject = JSScope::objectAtScope(scope->jsScope());
+    return thisObject->methodTable(exec->vm())->toStringName(thisObject, exec);
+}
+
 bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 {
     DebuggerScope* scope = jsCast<DebuggerScope*>(object);

Modified: trunk/Source/_javascript_Core/debugger/DebuggerScope.h (239556 => 239557)


--- trunk/Source/_javascript_Core/debugger/DebuggerScope.h	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/debugger/DebuggerScope.h	2018-12-29 04:24:29 UTC (rev 239557)
@@ -42,6 +42,7 @@
 
     static void visitChildren(JSCell*, SlotVisitor&);
     static String className(const JSObject*, VM&);
+    static String toStringName(const JSObject*, ExecState*);
     static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
     static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
     static bool deleteProperty(JSCell*, ExecState*, PropertyName);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (239556 => 239557)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2018-12-29 04:24:29 UTC (rev 239557)
@@ -519,7 +519,7 @@
     VM& vm = exec->vm();
     const ClassInfo* info = object->classInfo(vm);
     ASSERT(info);
-    return info->methodTable.className(object, vm);
+    return info->className;
 }
 
 String JSObject::calculatedClassName(JSObject* object)

Modified: trunk/Source/WebCore/ChangeLog (239556 => 239557)


--- trunk/Source/WebCore/ChangeLog	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/WebCore/ChangeLog	2018-12-29 04:24:29 UTC (rev 239557)
@@ -1,3 +1,18 @@
+2018-12-28  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Remove one indirection in JSObject::toStringName
+        https://bugs.webkit.org/show_bug.cgi?id=193037
+
+        Reviewed by Keith Miller.
+
+        Use old JSObject::toStringName function here.
+
+        * bindings/js/JSDOMConstructorBase.cpp:
+        (WebCore::JSDOMConstructorBase::className):
+        (WebCore::JSDOMConstructorBase::toStringName):
+        * bindings/js/JSDOMConstructorBase.h:
+        (WebCore::JSDOMConstructorBase::className): Deleted.
+
 2018-12-27  Alex Christensen  <[email protected]>
 
         Resurrect Mac CMake build

Modified: trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.cpp (239556 => 239557)


--- trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.cpp	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.cpp	2018-12-29 04:24:29 UTC (rev 239557)
@@ -43,4 +43,17 @@
     return CallType::Host;
 }
 
+String JSDOMConstructorBase::className(const JSObject*, JSC::VM&)
+{
+    return "Function"_s;
+}
+
+String JSDOMConstructorBase::toStringName(const JSObject* object, JSC::ExecState* exec)
+{
+    VM& vm = exec->vm();
+    const ClassInfo* info = object->classInfo(vm);
+    ASSERT(info);
+    return info->methodTable.className(object, vm);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.h (239556 => 239557)


--- trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.h	2018-12-27 16:13:47 UTC (rev 239556)
+++ trunk/Source/WebCore/bindings/js/JSDOMConstructorBase.h	2018-12-29 04:24:29 UTC (rev 239557)
@@ -38,6 +38,7 @@
     }
 
     static String className(const JSObject*, JSC::VM&);
+    static String toStringName(const JSObject*, JSC::ExecState*);
     static JSC::CallType getCallData(JSCell*, JSC::CallData&);
 };
 
@@ -46,9 +47,4 @@
     return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
 }
 
-inline String JSDOMConstructorBase::className(const JSObject*, JSC::VM&)
-{
-    return "Function"_s;
-}
-
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to