Title: [96381] trunk/Source/_javascript_Core
Revision
96381
Author
[email protected]
Date
2011-09-29 19:09:16 -0700 (Thu, 29 Sep 2011)

Log Message

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

Reviewed by Darin Adler.

* _javascript_Core.exp:
* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (96380 => 96381)


--- trunk/Source/_javascript_Core/ChangeLog	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-09-30 02:09:16 UTC (rev 96381)
@@ -1,3 +1,30 @@
+2011-09-29  Mark Hahnenberg  <[email protected]>
+
+        De-virtualize JSCell::toObject
+        https://bugs.webkit.org/show_bug.cgi?id=68937
+
+        Reviewed by Darin Adler.
+
+        * _javascript_Core.exp:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.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  <[email protected]>
 
         Start refactoring DFGSpeculativeJIT

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (96380 => 96381)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2011-09-30 02:09:16 UTC (rev 96381)
@@ -573,7 +573,6 @@
 __ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
 __ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE
 __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
-__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
 __ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
 __ZNK3JSC8JSObject9classNameEv
 __ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (96380 => 96381)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-30 02:09:16 UTC (rev 96381)
@@ -344,8 +344,7 @@
     ?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

Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-09-30 02:09:16 UTC (rev 96381)
@@ -151,10 +151,12 @@
     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)

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-30 02:09:16 UTC (rev 96381)
@@ -83,7 +83,7 @@
         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&);
 

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-09-30 02:09:16 UTC (rev 96381)
@@ -55,12 +55,6 @@
     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&)
 {

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.h (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-09-30 02:09:16 UTC (rev 96381)
@@ -66,7 +66,6 @@
         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&);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2011-09-30 02:09:16 UTC (rev 96381)
@@ -512,11 +512,6 @@
     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);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-30 02:09:16 UTC (rev 96381)
@@ -136,7 +136,6 @@
         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 @@
         // 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();

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (96380 => 96381)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2011-09-30 00:13:23 UTC (rev 96380)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2011-09-30 02:09:16 UTC (rev 96381)
@@ -429,6 +429,7 @@
         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 @@
         }
 
         virtual double toNumber(ExecState*) const;
-        virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
         virtual UString toString(ExecState*) const;
 
         virtual JSObject* toThisObject(ExecState*) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to