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
diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp
index 71f7ae6..7546746 100644
--- a/Source/JavaScriptCore/runtime/JSCell.cpp
+++ b/Source/JavaScriptCore/runtime/JSCell.cpp
@@ -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