Changeset 31208 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Mar 21, 2008, 4:14:49 AM (17 years ago)
Author:
[email protected]
Message:

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.
Location:
trunk/JavaScriptCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r31205 r31208  
     12008-03-21  Alexey Proskuryakov  <[email protected]>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Consolidate static identifier initializers within CommonIdentifiers.
     6
     7        No reliably measurable change on SunSpider; maybe a tiny improvement (within 0.2%).
     8
     9        * kjs/CommonIdentifiers.h: Added static identifiers that were lazily initialized
     10        throughout the code.
     11
     12        * kjs/date_object.cpp:
     13        (KJS::DateObjectImp::DateObjectImp):
     14        * kjs/function_object.cpp:
     15        (KJS::FunctionPrototype::FunctionPrototype):
     16        * kjs/object_object.cpp:
     17        (KJS::ObjectPrototype::ObjectPrototype):
     18        * kjs/regexp_object.cpp:
     19        (KJS::RegExpPrototype::RegExpPrototype):
     20        Use the values from CommonIdentifiers.
     21
     22        * kjs/lookup.h: Caching the identifier in a static wasn't a win on SunSpider, removed it.
     23
     24        * kjs/value.h:
     25        (KJS::jsNaN): We already have a shared NaN value, no need for a duplicate here.
     26
     27        * wtf/MathExtras.h:
     28        (wtf_atan2): Having local variables for numeric_limits constants is good for readability,
     29        but there is no reason to keep them static.
     30
     31        * JavaScriptCore.exp: Don't needlessly export JSGlobalObject::s_head.
     32
    1332008-03-20  Oliver Hunt  <[email protected]>
    234
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r31167 r31208  
    113113__ZN3KJS14JSGlobalObject4markEv
    114114__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
    115 __ZN3KJS14JSGlobalObject6s_headE
    116115__ZN3KJS14JSGlobalObjectD2Ev
    117116__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
  • trunk/JavaScriptCore/kjs/CommonIdentifiers.h

    r30871 r31208  
    2828// ways without repeating the list.
    2929#define KJS_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
     30    macro(__defineGetter__) \
     31    macro(__defineSetter__) \
     32    macro(__lookupGetter__) \
     33    macro(__lookupSetter__) \
     34    macro(apply) \
    3035    macro(arguments) \
     36    macro(call) \
    3137    macro(callee) \
    3238    macro(caller) \
     39    macro(compile) \
    3340    macro(constructor) \
     41    macro(eval) \
     42    macro(exec) \
    3443    macro(fromCharCode) \
    3544    macro(global) \
     45    macro(hasOwnProperty) \
    3646    macro(ignoreCase) \
    3747    macro(index) \
    3848    macro(input) \
     49    macro(isPrototypeOf) \
    3950    macro(length) \
    4051    macro(message) \
    4152    macro(multiline) \
    4253    macro(name) \
     54    macro(parse) \
     55    macro(propertyIsEnumerable) \
    4356    macro(prototype) \
    4457    macro(source) \
     58    macro(test) \
    4559    macro(toExponential) \
    4660    macro(toFixed) \
     
    4862    macro(toPrecision) \
    4963    macro(toString) \
    50     macro(valueOf) \
    51     macro(eval)
     64    macro(UTC) \
     65    macro(valueOf)
    5266
    5367namespace KJS {
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r31057 r31208  
    453453  : InternalFunctionImp(funcProto, dateProto->classInfo()->className)
    454454{
    455   static const Identifier* parsePropertyName = new Identifier("parse");
    456   static const Identifier* UTCPropertyName = new Identifier("UTC");
    457 
    458455  putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
    459   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum);
    460   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum);
     456  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, CommonIdentifiers::shared()->parse), DontEnum);
     457  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, CommonIdentifiers::shared()->UTC), DontEnum);
    461458  putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
    462459}
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r30942 r31208  
    4545FunctionPrototype::FunctionPrototype(ExecState* exec)
    4646{
    47     static const Identifier* applyPropertyName = new Identifier("apply");
    48     static const Identifier* callPropertyName = new Identifier("call");
    49 
    5047    putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
    5148
    5249    putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    53     putDirectFunction(new PrototypeFunction(exec, this, 2, *applyPropertyName, functionProtoFuncApply), DontEnum);
    54     putDirectFunction(new PrototypeFunction(exec, this, 1, *callPropertyName, functionProtoFuncCall), DontEnum);
     50    putDirectFunction(new PrototypeFunction(exec, this, 2, CommonIdentifiers::shared()->apply, functionProtoFuncApply), DontEnum);
     51    putDirectFunction(new PrototypeFunction(exec, this, 1, CommonIdentifiers::shared()->call, functionProtoFuncCall), DontEnum);
    5552}
    5653
  • trunk/JavaScriptCore/kjs/lookup.h

    r31147 r31208  
    285285    JSObject* ClassPrototype::self(ExecState* exec) \
    286286    { \
    287         static Identifier* prototypeIdentifier = new Identifier("[[" ClassName ".prototype]]"); \
    288         return KJS::cacheGlobalObject<ClassPrototype>(exec, *prototypeIdentifier); \
     287        return KJS::cacheGlobalObject<ClassPrototype>(exec, Identifier("[[" ClassName ".prototype]]")); \
    289288    } \
    290289    bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r30158 r31208  
    4444    : JSObject() // [[Prototype]] is null
    4545{
    46     static const Identifier* hasOwnPropertyPropertyName = new Identifier("hasOwnProperty");
    47     static const Identifier* propertyIsEnumerablePropertyName = new Identifier("propertyIsEnumerable");
    48     static const Identifier* isPrototypeOfPropertyName = new Identifier("isPrototypeOf");
    49     static const Identifier* defineGetterPropertyName = new Identifier("__defineGetter__");
    50     static const Identifier* defineSetterPropertyName = new Identifier("__defineSetter__");
    51     static const Identifier* lookupGetterPropertyName = new Identifier("__lookupGetter__");
    52     static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__");
    53 
    5446    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
    5547    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    5648    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    57     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *hasOwnPropertyPropertyName, objectProtoFuncHasOwnProperty), DontEnum);
    58     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *propertyIsEnumerablePropertyName, objectProtoFuncPropertyIsEnumerable), DontEnum);
    59     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *isPrototypeOfPropertyName, objectProtoFuncIsPrototypeOf), DontEnum);
     49    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     50    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     51    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    6052
    6153    // Mozilla extensions
    62     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineGetterPropertyName, objectProtoFuncDefineGetter), DontEnum);
    63     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, *defineSetterPropertyName, objectProtoFuncDefineSetter), DontEnum);
    64     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupGetterPropertyName, objectProtoFuncLookupGetter), DontEnum);
    65     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, *lookupSetterPropertyName, objectProtoFuncLookupSetter), DontEnum);
     54    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     55    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     56    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     57    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    6658}
    6759
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r30534 r31208  
    5252    : JSObject(objectPrototype)
    5353{
    54     static const Identifier* compilePropertyName = new Identifier("compile");
    55     static const Identifier* execPropertyName = new Identifier("exec");
    56     static const Identifier* testPropertyName = new Identifier("test");
    57 
    58     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *compilePropertyName, regExpProtoFuncCompile), DontEnum);
    59     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *execPropertyName, regExpProtoFuncExec), DontEnum);
    60     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, *testPropertyName, regExpProtoFuncTest), DontEnum);
     54    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->compile, regExpProtoFuncCompile), DontEnum);
     55    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->exec, regExpProtoFuncExec), DontEnum);
     56    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->test, regExpProtoFuncTest), DontEnum);
    6157    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
    6258}
  • trunk/JavaScriptCore/kjs/value.h

    r28110 r31208  
    194194inline JSValue *jsNaN()
    195195{
    196     static const union {
    197         uint64_t bits;
    198         double d;
    199     } nan = { 0x7ff80000ULL << 32 };
    200     return jsNumberCell(nan.d);
     196    return jsNumberCell(NaN);
    201197}
    202198
  • trunk/JavaScriptCore/wtf/MathExtras.h

    r29663 r31208  
    9696inline double wtf_atan2(double x, double y)
    9797{
    98     static double posInf = std::numeric_limits<double>::infinity();
    99     static double negInf = -std::numeric_limits<double>::infinity();
    100     static double nan = std::numeric_limits<double>::quiet_NaN();
     98    double posInf = std::numeric_limits<double>::infinity();
     99    double negInf = -std::numeric_limits<double>::infinity();
     100    double nan = std::numeric_limits<double>::quiet_NaN();
    101101
    102102    double result = nan;
Note: See TracChangeset for help on using the changeset viewer.