Commit b6e2ac66 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

De-virtualize JSCell::toObject

https://bugs.webkit.org/show_bug.cgi?id=68937

Reviewed by Darin Adler.

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


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a05e8d9a
2011-09-29 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize JSCell::toObject
https://bugs.webkit.org/show_bug.cgi?id=68937
Reviewed by Darin Adler.
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.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 <barraclough@apple.com>
Start refactoring DFGSpeculativeJIT
......@@ -573,7 +573,6 @@ __ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
......
......@@ -344,8 +344,7 @@ EXPORTS
?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
......
......@@ -151,10 +151,12 @@ UString JSCell::toString(ExecState*) const
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)
......
......@@ -83,7 +83,7 @@ namespace JSC {
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&);
......
......@@ -55,12 +55,6 @@ UString JSNotAnObject::toString(ExecState* exec) const
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&)
{
......
......@@ -66,7 +66,6 @@ namespace JSC {
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&);
......
......@@ -512,11 +512,6 @@ UString JSObject::toString(ExecState* exec) const
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);
......
......@@ -136,7 +136,6 @@ namespace JSC {
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 @@ namespace JSC {
// 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();
......
......@@ -429,6 +429,7 @@ namespace JSC {
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 @@ namespace JSC {
}
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toThisObject(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