Commit 944d1900 authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Oliver Hunt.

        Consolidate static identifier initializers within CommonIdentifiers.

        No reliably measurable change on SunSpider; maybe a tiny improvement (within 0.2%).

        * kjs/CommonIdentifiers.h: Added static identifiers that were lazily initialized
        throughout the code.

        * kjs/date_object.cpp:
        (KJS::DateObjectImp::DateObjectImp):
        * kjs/function_object.cpp:
        (KJS::FunctionPrototype::FunctionPrototype):
        * kjs/object_object.cpp:
        (KJS::ObjectPrototype::ObjectPrototype):
        * kjs/regexp_object.cpp:
        (KJS::RegExpPrototype::RegExpPrototype):
        Use the values from CommonIdentifiers. 

        * kjs/lookup.h: Caching the identifier in a static wasn't a win on SunSpider, removed it.

        * kjs/value.h:
        (KJS::jsNaN): We already have a shared NaN value, no need for a duplicate here.

        * wtf/MathExtras.h:
        (wtf_atan2): Having local variables for numeric_limits constants is good for readability,
        but there is no reason to keep them static.

        * JavaScriptCore.exp: Don't needlessly export JSGlobalObject::s_head.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e84203b8
2008-03-21 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Oliver Hunt.
Consolidate static identifier initializers within CommonIdentifiers.
No reliably measurable change on SunSpider; maybe a tiny improvement (within 0.2%).
* kjs/CommonIdentifiers.h: Added static identifiers that were lazily initialized
throughout the code.
* kjs/date_object.cpp:
(KJS::DateObjectImp::DateObjectImp):
* kjs/function_object.cpp:
(KJS::FunctionPrototype::FunctionPrototype):
* kjs/object_object.cpp:
(KJS::ObjectPrototype::ObjectPrototype):
* kjs/regexp_object.cpp:
(KJS::RegExpPrototype::RegExpPrototype):
Use the values from CommonIdentifiers.
* kjs/lookup.h: Caching the identifier in a static wasn't a win on SunSpider, removed it.
* kjs/value.h:
(KJS::jsNaN): We already have a shared NaN value, no need for a duplicate here.
* wtf/MathExtras.h:
(wtf_atan2): Having local variables for numeric_limits constants is good for readability,
but there is no reason to keep them static.
* JavaScriptCore.exp: Don't needlessly export JSGlobalObject::s_head.
2008-03-20 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej.
......
......@@ -112,7 +112,6 @@ __ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
__ZN3KJS14JSGlobalObject4initEv
__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
__ZN3KJS14JSGlobalObject6s_headE
__ZN3KJS14JSGlobalObjectD2Ev
__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
......
......@@ -27,28 +27,42 @@
// List of property names, passed to a macro so we can do set them up various
// ways without repeating the list.
#define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
macro(__defineGetter__) \
macro(__defineSetter__) \
macro(__lookupGetter__) \
macro(__lookupSetter__) \
macro(apply) \
macro(arguments) \
macro(call) \
macro(callee) \
macro(caller) \
macro(compile) \
macro(constructor) \
macro(eval) \
macro(exec) \
macro(fromCharCode) \
macro(global) \
macro(hasOwnProperty) \
macro(ignoreCase) \
macro(index) \
macro(input) \
macro(isPrototypeOf) \
macro(length) \
macro(message) \
macro(multiline) \
macro(name) \
macro(parse) \
macro(propertyIsEnumerable) \
macro(prototype) \
macro(source) \
macro(test) \
macro(toExponential) \
macro(toFixed) \
macro(toLocaleString) \
macro(toPrecision) \
macro(toString) \
macro(valueOf) \
macro(eval)
macro(UTC) \
macro(valueOf)
namespace KJS {
......
......@@ -452,12 +452,9 @@ bool DatePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& proper
DateObjectImp::DateObjectImp(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto)
: InternalFunctionImp(funcProto, dateProto->classInfo()->className)
{
static const Identifier* parsePropertyName = new Identifier("parse");
static const Identifier* UTCPropertyName = new Identifier("UTC");
putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, CommonIdentifiers::shared()->parse), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, CommonIdentifiers::shared()->UTC), DontEnum);
putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
}
......
......@@ -44,14 +44,11 @@ static JSValue* functionProtoFuncCall(ExecState*, JSObject*, const List&);
FunctionPrototype::FunctionPrototype(ExecState* exec)
{
static const Identifier* applyPropertyName = new Identifier("apply");
static const Identifier* callPropertyName = new Identifier("call");
putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 2, *applyPropertyName, functionProtoFuncApply), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 1, *callPropertyName, functionProtoFuncCall), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 2, CommonIdentifiers::shared()->apply, functionProtoFuncApply), DontEnum);
putDirectFunction(new PrototypeFunction(exec, this, 1, CommonIdentifiers::shared()->call, functionProtoFuncCall), DontEnum);
}
// ECMA 15.3.4
......
......@@ -284,8 +284,7 @@ namespace KJS {
const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table }; \
JSObject* ClassPrototype::self(ExecState* exec) \
{ \
static Identifier* prototypeIdentifier = new Identifier("[[" ClassName ".prototype]]"); \
return KJS::cacheGlobalObject<ClassPrototype>(exec, *prototypeIdentifier); \
return KJS::cacheGlobalObject<ClassPrototype>(exec, Identifier("[[" ClassName ".prototype]]")); \
} \
bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
{ \
......
......@@ -43,26 +43,18 @@ static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, const List&
ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype)
: JSObject() // [[Prototype]] is null
{
static const Identifier* hasOwnPropertyPropertyName = new Identifier("hasOwnProperty");
static const Identifier* propertyIsEnumerablePropertyName = new Identifier("propertyIsEnumerable");
static const Identifier* isPrototypeOfPropertyName = new Identifier("isPrototypeOf");
static const Identifier* defineGetterPropertyName = new Identifier("__defineGetter__");
static const Identifier* defineSetterPropertyName = new Identifier("__defineSetter__");
static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__");
static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__");
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *hasOwnPropertyPropertyName, objectProtoFuncHasOwnProperty), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *propertyIsEnumerablePropertyName, objectProtoFuncPropertyIsEnumerable), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *isPrototypeOfPropertyName, objectProtoFuncIsPrototypeOf), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
// Mozilla extensions
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineGetterPropertyName, objectProtoFuncDefineGetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineSetterPropertyName, objectProtoFuncDefineSetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupGetterPropertyName, objectProtoFuncLookupGetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupSetterPropertyName, objectProtoFuncLookupSetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
}
......
......@@ -51,13 +51,9 @@ const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0 };
RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
: JSObject(objectPrototype)
{
static const Identifier* compilePropertyName = new Identifier("compile");
static const Identifier* execPropertyName = new Identifier("exec");
static const Identifier* testPropertyName = new Identifier("test");
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *compilePropertyName, regExpProtoFuncCompile), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *execPropertyName, regExpProtoFuncExec), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *testPropertyName, regExpProtoFuncTest), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->compile, regExpProtoFuncCompile), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->exec, regExpProtoFuncExec), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->test, regExpProtoFuncTest), DontEnum);
putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
}
......
......@@ -193,11 +193,7 @@ inline JSValue *jsNull()
inline JSValue *jsNaN()
{
static const union {
uint64_t bits;
double d;
} nan = { 0x7ff80000ULL << 32 };
return jsNumberCell(nan.d);
return jsNumberCell(NaN);
}
inline JSValue *jsBoolean(bool b)
......
......@@ -95,9 +95,9 @@ inline int isfinite(double x) { return _finite(x); }
// Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values.
inline double wtf_atan2(double x, double y)
{
static double posInf = std::numeric_limits<double>::infinity();
static double negInf = -std::numeric_limits<double>::infinity();
static double nan = std::numeric_limits<double>::quiet_NaN();
double posInf = std::numeric_limits<double>::infinity();
double negInf = -std::numeric_limits<double>::infinity();
double nan = std::numeric_limits<double>::quiet_NaN();
double result = nan;
......
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