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

De-virtualize JSCell::getJSNumber

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

Reviewed by Oliver Hunt.

Added a new JSType to check whether or not something is a 
NumberObject (which includes NumberPrototype) in TypeInfo::isNumberObject because there's not 
currently a better way to determine whether something is indeed a NumberObject.
Also de-virtualized JSCell::getJSNumber, having it check the TypeInfo 
for whether the object is a NumberObject or not.  This patch is part of 
the larger process of de-virtualizing JSCell.

* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSCell.cpp:
(JSC::JSCell::getJSNumber):
* runtime/JSCell.h:
(JSC::JSValue::getJSNumber):
* runtime/JSType.h:
* runtime/JSTypeInfo.h:
(JSC::TypeInfo::isNumberObject):
* runtime/JSValue.h:
* runtime/NumberObject.cpp:
(JSC::NumberObject::getJSNumber):
* runtime/NumberObject.h:
(JSC::NumberObject::createStructure):
* runtime/NumberPrototype.h:
(JSC::NumberPrototype::createStructure):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 804807af
2011-09-23 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize JSCell::getJSNumber
https://bugs.webkit.org/show_bug.cgi?id=68651
Reviewed by Oliver Hunt.
Added a new JSType to check whether or not something is a
NumberObject (which includes NumberPrototype) in TypeInfo::isNumberObject because there's not
currently a better way to determine whether something is indeed a NumberObject.
Also de-virtualized JSCell::getJSNumber, having it check the TypeInfo
for whether the object is a NumberObject or not. This patch is part of
the larger process of de-virtualizing JSCell.
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/JSCell.cpp:
(JSC::JSCell::getJSNumber):
* runtime/JSCell.h:
(JSC::JSValue::getJSNumber):
* runtime/JSType.h:
* runtime/JSTypeInfo.h:
(JSC::TypeInfo::isNumberObject):
* runtime/JSValue.h:
* runtime/NumberObject.cpp:
(JSC::NumberObject::getJSNumber):
* runtime/NumberObject.h:
(JSC::NumberObject::createStructure):
* runtime/NumberPrototype.h:
(JSC::NumberPrototype::createStructure):
2011-09-23 Filip Pizlo <fpizlo@apple.com>
Resolve opcodes should have value profiling.
......@@ -253,7 +253,6 @@ __ZN3JSC4Yarr11byteCompileERNS0_11YarrPatternEPN3WTF20BumpPointerAllocatorE
__ZN3JSC4Yarr9interpretEPNS0_15BytecodePatternERKNS_7UStringEjjPi
__ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE
__ZN3JSC6JSCell11getCallDataERNS_8CallDataE
__ZN3JSC6JSCell11getJSNumberEv
__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateEj
__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE
......
......@@ -188,7 +188,6 @@ EXPORTS
?get@Structure@JSC@@QAEIAAVJSGlobalData@2@PAVStringImpl@WTF@@AAIAAPAVJSCell@2@@Z
?getCallData@JSCell@JSC@@UAE?AW4CallType@2@AATCallData@2@@Z
?getConstructData@JSCell@JSC@@UAE?AW4ConstructType@2@AATConstructData@2@@Z
?getJSNumber@JSCell@JSC@@UAE?AVJSValue@2@XZ
?getObject@JSCell@JSC@@QAEPAVJSObject@2@XZ
?getOwnPropertyDescriptor@JSGlobalObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
?getOwnPropertyDescriptor@JSObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
......
......@@ -26,6 +26,7 @@
#include "JSFunction.h"
#include "JSString.h"
#include "JSObject.h"
#include "NumberObject.h"
#include <wtf/MathExtras.h>
namespace JSC {
......@@ -112,8 +113,10 @@ JSObject* JSCell::toThisObject(ExecState* exec) const
return toObject(exec, exec->lexicalGlobalObject());
}
JSValue JSCell::getJSNumber()
JSValue JSCell::getJSNumber() const
{
if (structure()->typeInfo().isNumberObject())
return static_cast<const NumberObject*>(this)->getJSNumber();
return JSValue();
}
......
......@@ -95,7 +95,7 @@ namespace JSC {
virtual bool deleteProperty(ExecState*, unsigned propertyName);
virtual JSObject* toThisObject(ExecState*) const;
virtual JSValue getJSNumber();
JSValue getJSNumber() const;
void* vptr() { return *reinterpret_cast<void**>(this); }
void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; }
......@@ -314,7 +314,7 @@ namespace JSC {
return toNumberSlowCase(exec);
}
inline JSValue JSValue::getJSNumber()
inline JSValue JSValue::getJSNumber() const
{
if (isInt32() || isDouble())
return *this;
......
......@@ -41,6 +41,7 @@ enum JSType {
ObjectType = 10,
FinalObjectType = 11,
JSFunctionType = 12,
NumberObjectType = 13,
};
} // namespace JSC
......
......@@ -64,6 +64,7 @@ namespace JSC {
JSType type() const { return static_cast<JSType>(m_type); }
bool isObject() const { return type() >= ObjectType; }
bool isFinalObject() const { return type() == FinalObjectType; }
bool isNumberObject() const { return type() == NumberObjectType; }
bool masqueradesAsUndefined() const { return isSetOnFlags1(MasqueradesAsUndefined); }
bool implementsHasInstance() const { return isSetOnFlags1(ImplementsHasInstance); }
......
......@@ -215,7 +215,7 @@ namespace JSC {
static bool strictEqualSlowCase(ExecState* exec, JSValue v1, JSValue v2);
static bool strictEqualSlowCaseInline(ExecState* exec, JSValue v1, JSValue v2);
JSValue getJSNumber(); // JSValue() if this is not a JSNumber or number object
JSValue getJSNumber() const; // JSValue() if this is not a JSNumber or number object
bool isCell() const;
JSCell* asCell() const;
......
......@@ -42,7 +42,7 @@ void NumberObject::finishCreation(JSGlobalData& globalData)
ASSERT(inherits(&s_info));
}
JSValue NumberObject::getJSNumber()
JSValue NumberObject::getJSNumber() const
{
return internalValue();
}
......
......@@ -44,11 +44,10 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, globalObject, prototype, TypeInfo(NumberObjectType, StructureFlags), &s_info);
}
private:
virtual JSValue getJSNumber();
JSValue getJSNumber() const;
};
NumberObject* constructNumber(ExecState*, JSGlobalObject*, JSValue);
......
......@@ -40,7 +40,7 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, globalObject, prototype, TypeInfo(NumberObjectType, StructureFlags), &s_info);
}
protected:
......
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