Commit 061133e0 authored by mhahnenberg@apple.com's avatar 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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5a05ec18
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
......@@ -259,7 +259,6 @@ __ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateEj
__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_7JSValu
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEjbRNS_15PutPropertySlotE
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_7JSValueEj
__ZN3JSC8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3JSC8JSObject18getPrimitiveNumberEPNS_9ExecStateERdRNS_7JSValueE
__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject20visitChildrenVirtualERNS_11SlotVisitorE
__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
......
......@@ -205,9 +205,6 @@ EXPORTS
?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
......
......@@ -127,10 +127,11 @@ JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredTyp
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
......
......@@ -78,7 +78,7 @@ namespace JSC {
// 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;
......
......@@ -43,12 +43,6 @@ JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) con
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());
......
......@@ -64,7 +64,6 @@ namespace JSC {
// 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;
......
......@@ -288,7 +288,7 @@ static ALWAYS_INLINE JSValue callDefaultValueFunction(ExecState* exec, const JSO
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);
......
......@@ -133,8 +133,8 @@ namespace JSC {
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;
......
......@@ -274,7 +274,7 @@ JSValue JSString::toPrimitive(ExecState*, PreferredPrimitiveType) 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));
......
......@@ -428,6 +428,7 @@ namespace JSC {
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 @@ namespace JSC {
}
}
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value);
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
virtual UString toString(ExecState*) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment