De-virtualize JSCell::toObject
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2011 02:09:16 +0000 (02:09 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2011 02:09:16 +0000 (02:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68937

Reviewed by Darin Adler.

* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:

De-virtualized JSCell::toObject and changed its implementation to manually check the
cases for JSString and JSObject rather than leaving it up to the virtual method call.
* runtime/JSCell.cpp:
(JSC::JSCell::toObject):
* runtime/JSCell.h:

Removed JSNotAnObject::toObject because the case for JSObject works for it.
Also removed JSObject::toObject because it was essentially the identity function,
which is not necessary since toObject is no longer virtual.
* runtime/JSNotAnObject.cpp:
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
* runtime/JSObject.h:

De-virtualized JSObject::toObject and JSString::toObject.
* runtime/JSString.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96381 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.exp
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSNotAnObject.cpp
Source/JavaScriptCore/runtime/JSNotAnObject.h
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSString.h

index 2f0f560..0d09b92 100644 (file)
@@ -1,3 +1,30 @@
+2011-09-29  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        De-virtualize JSCell::toObject
+        https://bugs.webkit.org/show_bug.cgi?id=68937
+
+        Reviewed by Darin Adler.
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+        De-virtualized JSCell::toObject and changed its implementation to manually check the 
+        cases for JSString and JSObject rather than leaving it up to the virtual method call.
+        * runtime/JSCell.cpp:
+        (JSC::JSCell::toObject):
+        * runtime/JSCell.h:
+
+        Removed JSNotAnObject::toObject because the case for JSObject works for it.
+        Also removed JSObject::toObject because it was essentially the identity function,
+        which is not necessary since toObject is no longer virtual.
+        * runtime/JSNotAnObject.cpp:
+        * runtime/JSNotAnObject.h:
+        * runtime/JSObject.cpp:
+        * runtime/JSObject.h:
+
+        De-virtualized JSObject::toObject and JSString::toObject.
+        * runtime/JSString.h:
+
 2011-09-29  Gavin Barraclough  <barraclough@apple.com>
 
         Start refactoring DFGSpeculativeJIT
index f822988..c93dff2 100644 (file)
@@ -573,7 +573,6 @@ __ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
 __ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
 __ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE
 __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
-__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
 __ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
 __ZNK3JSC8JSObject9classNameEv
 __ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
index 867259b..13eca63 100644 (file)
@@ -344,8 +344,7 @@ EXPORTS
     ?toNumber@JSObject@JSC@@UBENPAVExecState@2@@Z
     ?toNumber@JSString@JSC@@EBENPAVExecState@2@@Z
     ?toNumberSlowCase@JSValue@JSC@@ABENPAVExecState@2@@Z
-    ?toObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
-    ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z
+    ?toObject@JSCell@JSC@@QBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
     ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
     ?toStrictThisObject@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@@Z
     ?toString@JSCell@JSC@@UBE?AVUString@2@PAVExecState@2@@Z
index ed8042d..62b651e 100644 (file)
@@ -151,10 +151,12 @@ UString JSCell::toString(ExecState*) const
     return UString();
 }
 
-JSObject* JSCell::toObject(ExecState*, JSGlobalObject*) const
+JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const
 {
-    ASSERT_NOT_REACHED();
-    return 0;
+    if (isString())
+        return static_cast<const JSString*>(this)->toObject(exec, globalObject);
+    ASSERT(isObject());
+    return static_cast<JSObject*>(const_cast<JSCell*>(this));
 }
 
 void slowValidateCell(JSCell* cell)
index 8bf75ac..11344c6 100644 (file)
@@ -83,7 +83,7 @@ namespace JSC {
         bool toBoolean(ExecState*) const;
         virtual double toNumber(ExecState*) const;
         virtual UString toString(ExecState*) const;
-        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
+        JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
         static void visitChildren(JSCell*, SlotVisitor&);
 
index cc155fc..9ae7964 100644 (file)
@@ -55,12 +55,6 @@ UString JSNotAnObject::toString(ExecState* exec) const
     return "";
 }
 
-JSObject* JSNotAnObject::toObject(ExecState* exec, JSGlobalObject*) const
-{
-    ASSERT_UNUSED(exec, exec->hadException());
-    return const_cast<JSNotAnObject*>(this);
-}
-
 // JSObject methods
 bool JSNotAnObject::getOwnPropertySlot(ExecState* exec, const Identifier&, PropertySlot&)
 {
index 9c5b3b8..03e5518 100644 (file)
@@ -66,7 +66,6 @@ namespace JSC {
         virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
         virtual double toNumber(ExecState*) const;
         virtual UString toString(ExecState*) const;
-        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
         // JSObject methods
         virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
index a75c36a..a4bf153 100644 (file)
@@ -512,11 +512,6 @@ UString JSObject::toString(ExecState* exec) const
     return primitive.toString(exec);
 }
 
-JSObject* JSObject::toObject(ExecState*, JSGlobalObject*) const
-{
-    return const_cast<JSObject*>(this);
-}
-
 JSObject* JSObject::toThisObject(ExecState*) const
 {
     return const_cast<JSObject*>(this);
index 21837ea..1973804 100644 (file)
@@ -136,7 +136,6 @@ namespace JSC {
         bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
         virtual double toNumber(ExecState*) const;
         virtual UString toString(ExecState*) const;
-        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
 
         virtual JSObject* toThisObject(ExecState*) const;
         virtual JSValue toStrictThisObject(ExecState*) const;
@@ -271,7 +270,6 @@ namespace JSC {
         // Nobody should ever ask any of these questions on something already known to be a JSObject.
         using JSCell::isAPIValueWrapper;
         using JSCell::isGetterSetter;
-        using JSCell::toObject;
         void getObject();
         void getString(ExecState* exec);
         void isObject();
index be1839b..54afd5c 100644 (file)
@@ -429,6 +429,7 @@ namespace JSC {
         JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
         bool toBoolean(ExecState*) const;
         bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
+        JSObject* toObject(ExecState*, JSGlobalObject*) const;
         
         bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
         bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
@@ -497,7 +498,6 @@ namespace JSC {
         }
 
         virtual double toNumber(ExecState*) const;
-        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
         virtual UString toString(ExecState*) const;
 
         virtual JSObject* toThisObject(ExecState*) const;