Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (96142 => 96143)
--- trunk/Source/_javascript_Core/ChangeLog 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-09-27 19:53:49 UTC (rev 96143)
@@ -1,3 +1,37 @@
+2011-09-27 Mark Hahnenberg <mhahnenb...@apple.com>
+
+ De-virtualize JSCell::getPrimitiveNumber
+ https://bugs.webkit.org/show_bug.cgi?id=68851
+
+ Reviewed by Darin Adler.
+
+ * _javascript_Core.exp:
+ * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+
+ Changed JSCell::getPrimitiveNumber to manually handle the dispatch for
+ JSCells (JSObject and JSString in this case).
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::getPrimitiveNumber):
+ * runtime/JSCell.h:
+
+ Removed JSNotAnObject::getPrimitiveNumber since its return value doesn't
+ matter and it already implements defaultValue, so JSObject::getPrimitiveNumber
+ can cover the case for JSNotAnObject.
+ * runtime/JSNotAnObject.cpp:
+ * runtime/JSNotAnObject.h:
+
+ De-virtualized JSObject::getPrimitiveNumber and JSString::getPrimitiveNumber
+ and changed them to be const. Also made JSString::getPrimitiveNumber public
+ because it needs to be called from JSCell::getPrimitiveNumber and also since it's
+ no longer virtual, we want people who have a more specific pointer (JSString*
+ instead of JSCell*) to not have to pay the cost of a virtual method call.
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::getPrimitiveNumber):
+ * runtime/JSObject.h:
+ * runtime/JSString.cpp:
+ (JSC::JSString::getPrimitiveNumber):
+ * runtime/JSString.h:
+
2011-09-27 Juan Carlos Montemayor Elosua <j.m...@me.com>
Implement Error.stack
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (96142 => 96143)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2011-09-27 19:53:49 UTC (rev 96143)
@@ -259,7 +259,6 @@
__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
-__ZN3JSC6JSCell18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC6JSCell3putEPNS_9ExecStateEjNS_7JSValueE
__ZN3JSC6JSCell9getObjectEv
@@ -322,7 +321,6 @@
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEjbRNS_15PutPropertySlotE
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_7JSValueEj
__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
-__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject20visitChildrenVirtualERNS_11SlotVisitorE
__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (96142 => 96143)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-09-27 19:53:49 UTC (rev 96143)
@@ -205,9 +205,6 @@
?getOwnPropertySlot@JSString@JSC@@EAE_NPAVExecState@2@IAAVPropertySlot@2@@Z
?getOwnPropertySlot@StringObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertySlot@2@@Z
?getOwnPropertySlot@StringObject@JSC@@UAE_NPAVExecState@2@IAAVPropertySlot@2@@Z
- ?getPrimitiveNumber@JSCell@JSC@@UAE_NPAVExecState@2@AANAAVJSValue@2@@Z
- ?getPrimitiveNumber@JSObject@JSC@@UAE_NPAVExecState@2@AANAAVJSValue@2@@Z
- ?getPrimitiveNumber@JSString@JSC@@EAE_NPAVExecState@2@AANAAVJSValue@2@@Z
?getPropertyDescriptor@JSObject@JSC@@QAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
?getPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getSlice@ArgList@JSC@@QBEXHAAV12@@Z
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-09-27 19:53:49 UTC (rev 96143)
@@ -127,10 +127,11 @@
return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
}
-bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&)
+bool JSCell::getPrimitiveNumber(ExecState* exec, double& number, JSValue& value) const
{
- ASSERT_NOT_REACHED();
- return false;
+ if (isString())
+ return static_cast<const JSString*>(this)->getPrimitiveNumber(exec, number, value);
+ return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value);
}
double JSCell::toNumber(ExecState*) const
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2011-09-27 19:53:49 UTC (rev 96143)
@@ -78,7 +78,7 @@
// Basic conversions.
JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
+ bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp 2011-09-27 19:53:49 UTC (rev 96143)
@@ -43,12 +43,6 @@
return jsNumber(0);
}
-bool JSNotAnObject::getPrimitiveNumber(ExecState* exec, double&, JSValue&)
-{
- ASSERT_UNUSED(exec, exec->hadException());
- return false;
-}
-
double JSNotAnObject::toNumber(ExecState* exec) const
{
ASSERT_UNUSED(exec, exec->hadException());
Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.h (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.h 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.h 2011-09-27 19:53:49 UTC (rev 96143)
@@ -64,7 +64,6 @@
// JSValue methods
virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&);
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2011-09-27 19:53:49 UTC (rev 96143)
@@ -288,7 +288,7 @@
return result;
}
-bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result)
+bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result) const
{
result = defaultValue(exec, PreferNumber);
number = result.toNumber(exec);
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2011-09-27 19:53:49 UTC (rev 96143)
@@ -133,8 +133,8 @@
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
bool toBoolean(ExecState*) const;
+ bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
Modified: trunk/Source/_javascript_Core/runtime/JSString.cpp (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSString.cpp 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSString.cpp 2011-09-27 19:53:49 UTC (rev 96143)
@@ -274,7 +274,7 @@
return const_cast<JSString*>(this);
}
-bool JSString::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result)
+bool JSString::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result) const
{
result = this;
number = jsToNumber(value(exec));
Modified: trunk/Source/_javascript_Core/runtime/JSString.h (96142 => 96143)
--- trunk/Source/_javascript_Core/runtime/JSString.h 2011-09-27 19:49:09 UTC (rev 96142)
+++ trunk/Source/_javascript_Core/runtime/JSString.h 2011-09-27 19:53:49 UTC (rev 96143)
@@ -428,6 +428,7 @@
JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
bool toBoolean(ExecState*) const;
+ bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const;
bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
@@ -495,7 +496,6 @@
}
}
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
virtual UString toString(ExecState*) const;