https://bugs.webkit.org/show_bug.cgi?id=68851
Reviewed by Darin Adler.
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96143
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-27 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ De-virtualize JSCell::getPrimitiveNumber
+ https://bugs.webkit.org/show_bug.cgi?id=68851
+
+ Reviewed by Darin Adler.
+
+ * JavaScriptCore.exp:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.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.mont@me.com>
Implement Error.stack
__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
-__ZN3JSC6JSCell18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC6JSCell3putEPNS_9ExecStateEjNS_7JSValueE
__ZN3JSC6JSCell9getObjectEv
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEjbRNS_15PutPropertySlotE
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_7JSValueEj
__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
-__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject20visitChildrenVirtualERNS_11SlotVisitorE
__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
?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
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
// 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;
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());
// 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;
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);
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;
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));
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&);
}
}
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
virtual UString toString(ExecState*) const;