Title: [98932] trunk/Source
Revision
98932
Author
mhahnenb...@apple.com
Date
2011-10-31 18:15:06 -0700 (Mon, 31 Oct 2011)

Log Message

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

Reviewed by Sam Weinig.

Source/_javascript_Core: 

Added defaultValue to the MethodTable.  Replaced all virtual versions of 
defaultValue with static versions.  Replaced all call sites with lookups in the 
MethodTable.

* _javascript_Core.exp:
* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
* runtime/ClassInfo.h:
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::defaultValue):
(JSC::TerminatedExecutionError::defaultValue):
* runtime/ExceptionHelpers.h:
* runtime/JSCell.cpp:
(JSC::JSCell::defaultValue):
* runtime/JSCell.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::defaultValue):
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::getPrimitiveNumber):
(JSC::JSObject::defaultValue):
* runtime/JSObject.h:
(JSC::JSObject::toPrimitive):

Source/WebCore: 

No new tests.

Added defaultValue to the MethodTable.  Replaced all virtual versions of 
defaultValue with static versions.  Replaced all call sites with lookups in the 
MethodTable.

* WebCore.exp.in:
* bridge/objc/objc_runtime.h:
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::defaultValue):
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::defaultValue):
* bridge/runtime_object.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (98931 => 98932)


--- trunk/Source/_javascript_Core/ChangeLog	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-11-01 01:15:06 UTC (rev 98932)
@@ -1,5 +1,35 @@
 2011-10-31  Mark Hahnenberg  <mhahnenb...@apple.com>
 
+        De-virtualize JSObject::defaultValue
+        https://bugs.webkit.org/show_bug.cgi?id=71146
+
+        Reviewed by Sam Weinig.
+
+        Added defaultValue to the MethodTable.  Replaced all virtual versions of 
+        defaultValue with static versions.  Replaced all call sites with lookups in the 
+        MethodTable.
+
+        * _javascript_Core.exp:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+        * runtime/ClassInfo.h:
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::InterruptedExecutionError::defaultValue):
+        (JSC::TerminatedExecutionError::defaultValue):
+        * runtime/ExceptionHelpers.h:
+        * runtime/JSCell.cpp:
+        (JSC::JSCell::defaultValue):
+        * runtime/JSCell.h:
+        * runtime/JSNotAnObject.cpp:
+        (JSC::JSNotAnObject::defaultValue):
+        * runtime/JSNotAnObject.h:
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::getPrimitiveNumber):
+        (JSC::JSObject::defaultValue):
+        * runtime/JSObject.h:
+        (JSC::JSObject::toPrimitive):
+
+2011-10-31  Mark Hahnenberg  <mhahnenb...@apple.com>
+
         Interpreter build fix
 
         Unreviewed build fix

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (98931 => 98932)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -304,6 +304,7 @@
 __ZN3JSC8JSObject10putByIndexEPNS_6JSCellEPNS_9ExecStateEjNS_7JSValueE
 __ZN3JSC8JSObject11hasInstanceEPNS_9ExecStateENS_7JSValueES3_
 __ZN3JSC8JSObject12defineGetterEPS0_PNS_9ExecStateERKNS_10IdentifierES1_j
+__ZN3JSC8JSObject12defaultValueEPKS0_PNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZN3JSC8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_j
 __ZN3JSC8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE
 __ZN3JSC8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
@@ -565,7 +566,6 @@
 __ZNK3JSC7UString5asciiEv
 __ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
 __ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj
-__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
 __ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
 __ZNK3JSC8JSObject9classNameEv

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (98931 => 98932)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-11-01 01:15:06 UTC (rev 98932)
@@ -133,7 +133,7 @@
     ?dayInYear@WTF@@YAHNH@Z
     ?decrement@RefCountedLeakCounter@WTF@@QAEXXZ
     ?defaultAttributes@PropertyDescriptor@JSC@@0IA
-    ?defaultValue@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
+    ?defaultValue@JSObject@JSC@@SA?AVJSValue@2@PBV12@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
     ?defineOwnProperty@JSObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z
     ?defineGetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z
     ?defineGetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z

Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -64,6 +64,9 @@
 
         typedef void (*DefineGetterFunctionPtr)(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
         DefineGetterFunctionPtr defineGetter;
+
+        typedef JSValue (*DefaultValueFunctionPtr)(const JSObject*, ExecState*, PreferredPrimitiveType);
+        DefaultValueFunctionPtr defaultValue;
     };
 
 #define CREATE_MEMBER_CHECKER(member) \
@@ -97,6 +100,7 @@
         &ClassName::getOwnPropertySlotByIndex, \
         &ClassName::toThisObject, \
         &ClassName::defineGetter, \
+        &ClassName::defaultValue, \
     }, \
     sizeof(ClassName)
 

Modified: trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -43,7 +43,7 @@
 
 const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(InterruptedExecutionError) };
 
-JSValue InterruptedExecutionError::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValue InterruptedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint)
 {
     if (hint == PreferString)
         return jsNontrivialString(exec, "_javascript_ execution exceeded timeout.");
@@ -68,7 +68,7 @@
 
 const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(TerminatedExecutionError) };
 
-JSValue TerminatedExecutionError::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValue TerminatedExecutionError::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType hint)
 {
     if (hint == PreferString)
         return jsNontrivialString(exec, "_javascript_ execution terminated.");

Modified: trunk/Source/_javascript_Core/runtime/ExceptionHelpers.h (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/ExceptionHelpers.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/ExceptionHelpers.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -62,7 +62,7 @@
     {
     }
 
-    virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+    static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 
 public:
     typedef JSNonFinalObject Base;
@@ -89,7 +89,7 @@
     {
     }
 
-    virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+    static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 
 public:
     typedef JSNonFinalObject Base;

Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -163,4 +163,10 @@
     ASSERT_NOT_REACHED();
 }
 
+JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType)
+{
+    ASSERT_NOT_REACHED();
+    return jsUndefined();
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -135,7 +135,8 @@
 
         // Dummy implementations of override-able static functions for classes to put in their MethodTable
         static NO_RETURN_DUE_TO_ASSERT void defineGetter(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
-        
+        static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
+
     private:
         WriteBarrier<Structure> m_structure;
     };

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -39,7 +39,7 @@
 const ClassInfo JSNotAnObject::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSNotAnObject) };
 
 // JSValue methods
-JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) const
+JSValue JSNotAnObject::defaultValue(const JSObject*, ExecState* exec, PreferredPrimitiveType)
 {
     ASSERT_UNUSED(exec, exec->hadException());
     return jsNumber(0);

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.h (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -65,7 +65,7 @@
         static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
 
         // JSValue methods
-        virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+        static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 
         // JSObject methods
         static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -308,27 +308,27 @@
 
 bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result) const
 {
-    result = defaultValue(exec, PreferNumber);
+    result = methodTable()->defaultValue(this, exec, PreferNumber);
     number = result.toNumber(exec);
     return !result.isString();
 }
 
 // ECMA 8.6.2.6
-JSValue JSObject::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValue JSObject::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType hint)
 {
     // Must call toString first for Date objects.
-    if ((hint == PreferString) || (hint != PreferNumber && prototype() == exec->lexicalGlobalObject()->datePrototype())) {
-        JSValue value = callDefaultValueFunction(exec, this, exec->propertyNames().toString);
+    if ((hint == PreferString) || (hint != PreferNumber && object->prototype() == exec->lexicalGlobalObject()->datePrototype())) {
+        JSValue value = callDefaultValueFunction(exec, object, exec->propertyNames().toString);
         if (value)
             return value;
-        value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf);
+        value = callDefaultValueFunction(exec, object, exec->propertyNames().valueOf);
         if (value)
             return value;
     } else {
-        JSValue value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf);
+        JSValue value = callDefaultValueFunction(exec, object, exec->propertyNames().valueOf);
         if (value)
             return value;
-        value = callDefaultValueFunction(exec, this, exec->propertyNames().toString);
+        value = callDefaultValueFunction(exec, object, exec->propertyNames().toString);
         if (value)
             return value;
     }

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (98931 => 98932)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -122,7 +122,7 @@
         static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
 
-        virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+        static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 
         virtual bool hasInstance(ExecState*, JSValue, JSValue prototypeProperty);
 
@@ -774,7 +774,7 @@
 
 inline JSValue JSObject::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const
 {
-    return defaultValue(exec, preferredType);
+    return methodTable()->defaultValue(this, exec, preferredType);
 }
 
 inline JSValue JSValue::get(ExecState* exec, const Identifier& propertyName) const

Modified: trunk/Source/WebCore/ChangeLog (98931 => 98932)


--- trunk/Source/WebCore/ChangeLog	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/ChangeLog	2011-11-01 01:15:06 UTC (rev 98932)
@@ -1,3 +1,24 @@
+2011-10-31  Mark Hahnenberg  <mhahnenb...@apple.com>
+
+        De-virtualize JSObject::defaultValue
+        https://bugs.webkit.org/show_bug.cgi?id=71146
+
+        Reviewed by Sam Weinig.
+
+        No new tests.
+
+        Added defaultValue to the MethodTable.  Replaced all virtual versions of 
+        defaultValue with static versions.  Replaced all call sites with lookups in the 
+        MethodTable.
+
+        * WebCore.exp.in:
+        * bridge/objc/objc_runtime.h:
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::ObjcFallbackObjectImp::defaultValue):
+        * bridge/runtime_object.cpp:
+        (JSC::Bindings::RuntimeObject::defaultValue):
+        * bridge/runtime_object.h:
+
 2011-10-31  Levi Weintraub  <le...@chromium.org>
 
         Switch RoundedRect back to integers

Modified: trunk/Source/WebCore/WebCore.exp.in (98931 => 98932)


--- trunk/Source/WebCore/WebCore.exp.in	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-11-01 01:15:06 UTC (rev 98932)
@@ -1702,6 +1702,7 @@
 __ZN3JSC13RuntimeMethodC2EPNS_14JSGlobalObjectEPNS_9StructureERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
 __ZN3JSC8Bindings10RootObjectD1Ev
 __ZN3JSC8Bindings13RuntimeObject11getCallDataEPNS_6JSCellERNS_8CallDataE
+__ZN3JSC8Bindings13RuntimeObject12defaultValueEPKNS_8JSObjectEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZN3JSC8Bindings13RuntimeObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
 __ZN3JSC8Bindings13RuntimeObject14finishCreationEPNS_14JSGlobalObjectE
 __ZN3JSC8Bindings13RuntimeObject16getConstructDataEPNS_6JSCellERNS_13ConstructDataE
@@ -1717,7 +1718,6 @@
 __ZN3JSC8Bindings8InstanceD2Ev
 __ZN7WebCore13IdentifierRep7isValidEPS0_
 __ZN7WebCore16ScriptController16createRootObjectEPv
-__ZNK3JSC8Bindings13RuntimeObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZTVN3JSC13RuntimeMethodE
 #endif
 

Modified: trunk/Source/WebCore/bridge/objc/objc_runtime.h (98931 => 98932)


--- trunk/Source/WebCore/bridge/objc/objc_runtime.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/bridge/objc/objc_runtime.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -128,7 +128,7 @@
     static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     static CallType getCallData(JSCell*, CallData&);
     static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
-    virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+    static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
 
     virtual bool toBoolean(ExecState*) const;
 

Modified: trunk/Source/WebCore/bridge/objc/objc_runtime.mm (98931 => 98932)


--- trunk/Source/WebCore/bridge/objc/objc_runtime.mm	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/bridge/objc/objc_runtime.mm	2011-11-01 01:15:06 UTC (rev 98932)
@@ -270,9 +270,10 @@
     return false;
 }
 
-JSValue ObjcFallbackObjectImp::defaultValue(ExecState* exec, PreferredPrimitiveType) const
+JSValue ObjcFallbackObjectImp::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType)
 {
-    return _instance->getValueOfUndefinedField(exec, _item);
+    const ObjcFallbackObjectImp* thisObject = static_cast<const ObjcFallbackObjectImp*>(object);
+    return thisObject->_instance->getValueOfUndefinedField(exec, thisObject->_item);
 }
 
 bool ObjcFallbackObjectImp::toBoolean(ExecState *) const

Modified: trunk/Source/WebCore/bridge/runtime_object.cpp (98931 => 98932)


--- trunk/Source/WebCore/bridge/runtime_object.cpp	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/bridge/runtime_object.cpp	2011-11-01 01:15:06 UTC (rev 98932)
@@ -238,12 +238,13 @@
     return false;
 }
 
-JSValue RuntimeObject::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValue RuntimeObject::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType hint)
 {
-    if (!m_instance)
+    const RuntimeObject* thisObject = static_cast<const RuntimeObject*>(object);
+    if (!thisObject->m_instance)
         return throwInvalidAccessError(exec);
     
-    RefPtr<Instance> instance = m_instance;
+    RefPtr<Instance> instance = thisObject->m_instance;
 
     instance->begin();
     JSValue result = instance->defaultValue(exec, hint);

Modified: trunk/Source/WebCore/bridge/runtime_object.h (98931 => 98932)


--- trunk/Source/WebCore/bridge/runtime_object.h	2011-11-01 01:09:03 UTC (rev 98931)
+++ trunk/Source/WebCore/bridge/runtime_object.h	2011-11-01 01:15:06 UTC (rev 98932)
@@ -49,7 +49,7 @@
     virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier& propertyName, PropertyDescriptor&);
     static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
-    virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
+    static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
     static CallType getCallData(JSCell*, CallData&);
     static ConstructType getConstructData(JSCell*, ConstructData&);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to