Title: [95516] trunk/Source/_javascript_Core
Revision
95516
Author
[email protected]
Date
2011-09-19 21:33:10 -0700 (Mon, 19 Sep 2011)

Log Message

Remove toPrimitive from JSCell
https://bugs.webkit.org/show_bug.cgi?id=67875

Reviewed by Darin Adler.

Part of the refactoring process to un-virtualize JSCell.  We move
all of the implicit functionality provided by the virtual toPrimitive method
in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while
also de-virtualizing JSCell::toPrimitive.

* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
* runtime/JSCell.cpp:
(JSC::JSCell::toPrimitive):
* runtime/JSCell.h:

We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from
JSObject.  This pushes the virtual method further down, enabling us to get rid
of the virtual call in JSCell.  Eventually we'll probably have to deal with this
again, but we'll cross that bridge when we come to it.
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::defaultValue):
* runtime/JSNotAnObject.h:
* runtime/JSObject.h:
* runtime/JSString.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (95515 => 95516)


--- trunk/Source/_javascript_Core/ChangeLog	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-09-20 04:33:10 UTC (rev 95516)
@@ -1,3 +1,30 @@
+2011-09-19  Mark Hahnenberg  <[email protected]>
+
+        Remove toPrimitive from JSCell
+        https://bugs.webkit.org/show_bug.cgi?id=67875
+
+        Reviewed by Darin Adler.
+
+        Part of the refactoring process to un-virtualize JSCell.  We move 
+        all of the implicit functionality provided by the virtual toPrimitive method 
+        in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while 
+        also de-virtualizing JSCell::toPrimitive.
+
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+        * runtime/JSCell.cpp:
+        (JSC::JSCell::toPrimitive):
+        * runtime/JSCell.h:
+
+        We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from 
+        JSObject.  This pushes the virtual method further down, enabling us to get rid 
+        of the virtual call in JSCell.  Eventually we'll probably have to deal with this
+        again, but we'll cross that bridge when we come to it.
+        * runtime/JSNotAnObject.cpp:
+        (JSC::JSNotAnObject::defaultValue):
+        * runtime/JSNotAnObject.h:
+        * runtime/JSObject.h:
+        * runtime/JSString.h:
+
 2011-09-19  Geoffrey Garen  <[email protected]>
 
         Removed ENABLE_LAZY_BLOCK_FREEING and related #ifdefs

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (95515 => 95516)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-20 04:33:10 UTC (rev 95516)
@@ -356,8 +356,6 @@
     ?toObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
     ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z
     ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z
-    ?toPrimitive@JSCell@JSC@@UBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
-    ?toPrimitive@JSString@JSC@@EBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
     ?toStrictThisObject@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@@Z
     ?toString@JSCell@JSC@@UBE?AVUString@2@PAVExecState@2@@Z
     ?toString@JSObject@JSC@@UBE?AVUString@2@PAVExecState@2@@Z

Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp	2011-09-20 04:33:10 UTC (rev 95516)
@@ -117,10 +117,11 @@
     return JSValue();
 }
 
-JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const
+JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const
 {
-    ASSERT_NOT_REACHED();
-    return JSValue();
+    if (isString())
+        return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType);
+    return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
 }
 
 bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2011-09-20 04:33:10 UTC (rev 95516)
@@ -77,7 +77,7 @@
         virtual ConstructType getConstructData(ConstructData&);
 
         // Basic conversions.
-        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
+        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
         virtual bool toBoolean(ExecState*) const;
         virtual double toNumber(ExecState*) const;

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp	2011-09-20 04:33:10 UTC (rev 95516)
@@ -37,7 +37,7 @@
 ASSERT_CLASS_FITS_IN_CELL(JSNotAnObject);
 
 // JSValue methods
-JSValue JSNotAnObject::toPrimitive(ExecState* exec, PreferredPrimitiveType) const
+JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) const
 {
     ASSERT_UNUSED(exec, exec->hadException());
     return jsNumber(0);

Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.h (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.h	2011-09-20 04:33:10 UTC (rev 95516)
@@ -63,7 +63,7 @@
         static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
 
         // JSValue methods
-        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
+        virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
         virtual bool toBoolean(ExecState*) const;
         virtual double toNumber(ExecState*) const;

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2011-09-20 04:33:10 UTC (rev 95516)
@@ -131,7 +131,7 @@
         virtual void getPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
 
-        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
+        JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
         virtual bool toBoolean(ExecState*) const;
         virtual double toNumber(ExecState*) const;

Modified: trunk/Source/_javascript_Core/runtime/JSString.h (95515 => 95516)


--- trunk/Source/_javascript_Core/runtime/JSString.h	2011-09-20 04:30:58 UTC (rev 95515)
+++ trunk/Source/_javascript_Core/runtime/JSString.h	2011-09-20 04:33:10 UTC (rev 95516)
@@ -426,6 +426,7 @@
         }
         unsigned length() { return m_length; }
 
+        JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
         bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
         bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
         bool getStringPropertyDescriptor(ExecState*, const Identifier& propertyName, PropertyDescriptor&);
@@ -492,7 +493,6 @@
             }
         }
 
-        virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
         virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
         virtual bool toBoolean(ExecState*) const;
         virtual double toNumber(ExecState*) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to