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
+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
__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject18toStrictThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
-__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
?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
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)
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&);
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&)
{
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&);
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);
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;
// 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();
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&);
}
virtual double toNumber(ExecState*) const;
- virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toThisObject(ExecState*) const;