Changeset 20310 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Mar 18, 2007, 10:43:47 PM (18 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Mark.


  • avoid static construction (and global variable access) in a smarter, more portable way, to later enable MUTLI_THREAD mode to work on other platforms and compilers.


  • kjs/CommonIdentifiers.cpp: Added. New class to hold all the shared identifiers. (KJS::CommonIdentifiers::CommonIdentifiers): (KJS::CommonIdentifiers::shared):
  • kjs/CommonIdentifiers.h: Added.
  • kjs/ExecState.h: (KJS::ExecState::propertyNames): Hand the CommonIdentifiers instance here for easy access. (KJS::ExecState::ExecState):
  • API/JSObjectRef.cpp: (JSObjectMakeConstructor):
  • CMakeLists.txt:
  • JavaScriptCore.exp:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • bindings/runtime_array.cpp: (RuntimeArray::getOwnPropertySlot): (RuntimeArray::put):
  • bindings/runtime_method.cpp: (RuntimeMethod::getOwnPropertySlot):
  • kjs/array_object.cpp: (ArrayInstance::getOwnPropertySlot): (ArrayInstance::put): (ArrayInstance::deleteProperty): (ArrayProtoFunc::ArrayProtoFunc): (ArrayProtoFunc::callAsFunction): (ArrayObjectImp::ArrayObjectImp):
  • kjs/bool_object.cpp: (BooleanPrototype::BooleanPrototype): (BooleanProtoFunc::BooleanProtoFunc): (BooleanProtoFunc::callAsFunction): (BooleanObjectImp::BooleanObjectImp):
  • kjs/completion.h: (KJS::Completion::Completion):
  • kjs/date_object.cpp: (KJS::DateProtoFunc::DateProtoFunc): (KJS::DateObjectImp::DateObjectImp): (KJS::DateObjectFuncImp::DateObjectFuncImp):
  • kjs/error_object.cpp: (ErrorPrototype::ErrorPrototype): (ErrorProtoFunc::ErrorProtoFunc): (ErrorProtoFunc::callAsFunction): (ErrorObjectImp::ErrorObjectImp): (ErrorObjectImp::construct): (NativeErrorPrototype::NativeErrorPrototype): (NativeErrorImp::NativeErrorImp): (NativeErrorImp::construct): (NativeErrorImp::callAsFunction):
  • kjs/function.cpp: (KJS::FunctionImp::getOwnPropertySlot): (KJS::FunctionImp::put): (KJS::FunctionImp::deleteProperty): (KJS::FunctionImp::getParameterName): (KJS::DeclaredFunctionImp::construct): (KJS::IndexToNameMap::unMap): (KJS::Arguments::Arguments): (KJS::ActivationImp::getOwnPropertySlot): (KJS::ActivationImp::deleteProperty): (KJS::GlobalFuncImp::GlobalFuncImp):
  • kjs/function_object.cpp: (FunctionPrototype::FunctionPrototype): (FunctionProtoFunc::FunctionProtoFunc): (FunctionProtoFunc::callAsFunction): (FunctionObjectImp::FunctionObjectImp): (FunctionObjectImp::construct):
  • kjs/grammar.y:
  • kjs/identifier.cpp:
  • kjs/identifier.h:
  • kjs/interpreter.cpp: (KJS::Interpreter::init): (KJS::Interpreter::initGlobalObject):
  • kjs/interpreter.h:
  • kjs/lookup.h:
  • kjs/math_object.cpp: (MathFuncImp::MathFuncImp):
  • kjs/nodes.cpp: (ArrayNode::evaluate): (FuncDeclNode::processFuncDecl): (FuncExprNode::evaluate):
  • kjs/number_object.cpp: (NumberPrototype::NumberPrototype): (NumberProtoFunc::NumberProtoFunc): (NumberObjectImp::NumberObjectImp):
  • kjs/object.cpp: (KJS::JSObject::put): (KJS::JSObject::defaultValue): (KJS::JSObject::hasInstance):
  • kjs/object.h: (KJS::JSObject::getOwnPropertySlot):
  • kjs/object_object.cpp: (ObjectPrototype::ObjectPrototype): (ObjectProtoFunc::ObjectProtoFunc): (ObjectObjectImp::ObjectObjectImp):
  • kjs/regexp_object.cpp: (RegExpPrototype::RegExpPrototype): (RegExpProtoFunc::RegExpProtoFunc): (RegExpObjectImp::RegExpObjectImp):
  • kjs/string_object.cpp: (KJS::StringInstance::getOwnPropertySlot): (KJS::StringInstance::put): (KJS::StringInstance::deleteProperty): (KJS::StringPrototype::StringPrototype): (KJS::StringProtoFunc::StringProtoFunc): (KJS::StringProtoFunc::callAsFunction): (KJS::StringObjectImp::StringObjectImp): (KJS::StringObjectFuncImp::StringObjectFuncImp):
  • kjs/testkjs.cpp: (TestFunctionImp::TestFunctionImp):

WebCore:

Reviewed by Mark.

  • avoid static construction (and global variable access) in a smarter, more portable way, to later enable MUTLI_THREAD mode to work on other platforms and compilers.


  • bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::JSHTMLInputElementBaseFunction::JSHTMLInputElementBaseFunction):
  • bindings/js/JSHTMLOptionElementConstructor.cpp: (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
  • bindings/js/JSXMLHttpRequest.cpp: (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
  • bindings/js/JSXSLTProcessor.cpp: (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
  • bindings/js/kjs_dom.cpp: (KJS::DOMNamedNodeMap::getOwnPropertySlot): (KJS::DOMNamedNodesCollection::getOwnPropertySlot):
  • bindings/js/kjs_events.cpp: (KJS::JSAbstractEventListener::handleEvent):
  • bindings/js/kjs_html.cpp: (KJS::HTMLElementFunction::HTMLElementFunction): (KJS::JSHTMLCollection::getOwnPropertySlot):
  • bindings/js/kjs_window.cpp: (KJS::ScheduledAction::execute):
  • bindings/objc/WebScriptObject.mm:
  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/JavaScriptCore/kjs
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.h

    r17372 r20310  
    2727#include "value.h"
    2828#include "types.h"
     29#include "CommonIdentifiers.h"
    2930
    3031namespace KJS {
     
    7677    bool hadException() const { return !!m_exception; }
    7778
     79    // This is a workaround to avoid accessing the global variables for these identifiers in
     80    // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
     81    const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
     82
    7883  private:
    7984    ExecState(Interpreter* interp, Context* con)
     
    8186        , m_context(con)
    8287        , m_exception(0)
     88        , m_propertyNames(CommonIdentifiers::shared())
    8389    {
    8490    }
     
    8692    Context* m_context;
    8793    JSValue* m_exception;
     94    CommonIdentifiers* m_propertyNames;
    8895  };
    8996
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r17610 r20310  
    9090bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    9191{
    92   if (propertyName == lengthPropertyName) {
     92  if (propertyName == exec->propertyNames().length) {
    9393    slot.setCustom(this, lengthGetter);
    9494    return true;
     
    131131
    132132// Special implementation of [[Put]] - see ECMA 15.4.5.1
    133 void ArrayInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
    134 {
    135   if (propertyName == lengthPropertyName) {
     133void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
     134{
     135  if (propertyName == exec->propertyNames().length) {
    136136    unsigned int newLen = value->toUInt32(exec);
    137137    if (value->toNumber(exec) != double(newLen)) {
     
    179179}
    180180
    181 bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
    182 {
    183   if (propertyName == lengthPropertyName)
     181bool ArrayInstance::deleteProperty(ExecState* exec, const Identifier &propertyName)
     182{
     183  if (propertyName == exec->propertyNames().length)
    184184    return false;
    185185 
     
    436436// ------------------------------ ArrayProtoFunc ----------------------------
    437437
    438 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     438ArrayProtoFunc::ArrayProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
    439439  : InternalFunctionImp(static_cast<FunctionPrototype*>
    440440                        (exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
    441441  , id(i)
    442442{
    443   put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
     443  put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
    444444}
    445445
     
    453453
    454454// ECMA 15.4.4
    455 JSValue *ArrayProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
    456 {
    457   unsigned length = thisObj->get(exec,lengthPropertyName)->toUInt32(exec);
     455JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     456{
     457  unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    458458
    459459  JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning
     
    488488        if (id == ToLocaleString) {
    489489            JSObject* o = element->toObject(exec);
    490             JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName);
     490            JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString);
    491491            if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall())
    492492                str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec);
     
    518518        // Older versions tried to optimize out getting the length of thisObj
    519519        // by checking for n != 0, but that doesn't work if thisObj is an empty array.
    520         length = curObj->get(exec,lengthPropertyName)->toUInt32(exec);
     520        length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    521521        while (k < length) {
    522522          if (JSValue *v = getProperty(exec, curObj, k))
     
    534534      curObj = static_cast<JSObject *>(it++); // may be 0
    535535    }
    536     arr->put(exec,lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
     536    arr->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
    537537
    538538    result = arr;
     
    541541  case Pop:{
    542542    if (length == 0) {
    543       thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
     543      thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
    544544      result = jsUndefined();
    545545    } else {
    546546      result = thisObj->get(exec, length - 1);
    547       thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
     547      thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
    548548    }
    549549    break;
     
    553553      thisObj->put(exec, length + n, args[n]);
    554554    length += args.size();
    555     thisObj->put(exec,lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
     555    thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
    556556    result = jsNumber(length);
    557557    break;
     
    581581  case Shift: {
    582582    if (length == 0) {
    583       thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);
     583      thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
    584584      result = jsUndefined();
    585585    } else {
     
    592592      }
    593593      thisObj->deleteProperty(exec, length - 1);
    594       thisObj->put(exec, lengthPropertyName, jsNumber(length - 1), DontEnum | DontDelete);
     594      thisObj->put(exec, exec->propertyNames().length, jsNumber(length - 1), DontEnum | DontDelete);
    595595    }
    596596    break;
     
    635635        resObj->put(exec, n, v);
    636636    }
    637     resObj->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);
     637    resObj->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete);
    638638    break;
    639639  }
     
    662662
    663663    if (length == 0) {
    664       thisObj->put(exec, lengthPropertyName, jsNumber(0), DontEnum | DontDelete);
     664      thisObj->put(exec, exec->propertyNames().length, jsNumber(0), DontEnum | DontDelete);
    665665      result = thisObj;
    666666      break;
     
    728728        resObj->put(exec, k, v);
    729729    }
    730     resObj->put(exec, lengthPropertyName, jsNumber(deleteCount), DontEnum | DontDelete);
     730    resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete);
    731731
    732732    unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
     
    760760      thisObj->put(exec, k+begin, args[k+2]);
    761761    }
    762     thisObj->put(exec, lengthPropertyName, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
     762    thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
    763763    break;
    764764  }
     
    775775      thisObj->put(exec, k, args[k]);
    776776    result = jsNumber(length + nrArgs);
    777     thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);
     777    thisObj->put(exec, exec->propertyNames().length, result, DontEnum | DontDelete);
    778778    break;
    779779  }
     
    936936{
    937937  // ECMA 15.4.3.1 Array.prototype
    938   put(exec, prototypePropertyName, arrayProto, DontEnum|DontDelete|ReadOnly);
     938  put(exec, exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
    939939
    940940  // no. of arguments for constructor
    941   put(exec, lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     941  put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    942942}
    943943
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r17372 r20310  
    4747  // The constructor will be added later by Interpreter::Interpreter()
    4848
    49   putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
    50   putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, valueOfPropertyName),  DontEnum);
     49  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
     50  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, exec->propertyNames().valueOf),  DontEnum);
    5151  setInternalValue(jsBoolean(false));
    5252}
     
    5555// ------------------------------ BooleanProtoFunc --------------------------
    5656
    57 BooleanProtoFunc::BooleanProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     57BooleanProtoFunc::BooleanProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    5858  : InternalFunctionImp(funcProto, name)
    5959  , id(i)
    6060{
    61   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     61  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    6262}
    6363
    6464
    6565// ECMA 15.6.4.2 + 15.6.4.3
    66 JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
     66JSValue *BooleanProtoFunc::callAsFunction(ExecState* exec, JSObject *thisObj, const List &/*args*/)
    6767{
    6868  // no generic function. "this" has to be a Boolean object
     
    8383
    8484
    85 BooleanObjectImp::BooleanObjectImp(ExecState*, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
     85BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* funcProto, BooleanPrototype* booleanProto)
    8686  : InternalFunctionImp(funcProto)
    8787{
    88   putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
     88  putDirect(exec->propertyNames().prototype, booleanProto, DontEnum|DontDelete|ReadOnly);
    8989
    9090  // no. of arguments for constructor
    91   putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     91  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    9292}
    9393
  • trunk/JavaScriptCore/kjs/completion.h

    r17372 r20310  
    2626#define _KJS_COMPLETION_H_
    2727
    28 #include "identifier.h"
     28#include "CommonIdentifiers.h"
    2929#include "value.h"
    3030
     
    4848  class Completion {
    4949  public:
    50     Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = Identifier::null())
     50    Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = CommonIdentifiers::shared()->nullIdentifier)
    5151        : comp(c), val(v), tar(t) { }
    5252
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r20205 r20310  
    434434// ------------------------------ DateProtoFunc -----------------------------
    435435
    436 DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     436DateProtoFunc::DateProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
    437437  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
    438438  , id(abs(i))
     
    440440  // We use a negative ID to denote the "UTC" variant.
    441441{
    442     putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     442    putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    443443}
    444444
     
    600600  static const Identifier* UTCPropertyName = new Identifier("UTC");
    601601
    602   putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
     602  putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
    603603  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum);
    604604  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, *UTCPropertyName), DontEnum);
    605   putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum);
     605  putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
    606606}
    607607
     
    669669// ------------------------------ DateObjectFuncImp ----------------------------
    670670
    671 DateObjectFuncImp::DateObjectFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     671DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    672672    : InternalFunctionImp(funcProto, name), id(i)
    673673{
    674     putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     674    putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    675675}
    676676
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r17372 r20310  
    4444
    4545// ECMA 15.9.4
    46 ErrorPrototype::ErrorPrototype(ExecState *exec,
    47                                      ObjectPrototype *objectProto,
    48                                      FunctionPrototype *funcProto)
     46ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto)
    4947  : JSObject(objectProto)
    5048{
    5149  // The constructor will be added later in ErrorObjectImp's constructor
    5250
    53   put(exec, namePropertyName,     jsString("Error"), DontEnum);
    54   put(exec, messagePropertyName,  jsString("Unknown error"), DontEnum);
    55   putDirectFunction(new ErrorProtoFunc(exec, funcProto, toStringPropertyName), DontEnum);
     51  put(exec, exec->propertyNames().name,     jsString("Error"), DontEnum);
     52  put(exec, exec->propertyNames().message,  jsString("Unknown error"), DontEnum);
     53  putDirectFunction(new ErrorProtoFunc(exec, funcProto, exec->propertyNames().toString), DontEnum);
    5654}
    5755
    5856// ------------------------------ ErrorProtoFunc ----------------------------
    5957
    60 ErrorProtoFunc::ErrorProtoFunc(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
     58ErrorProtoFunc::ErrorProtoFunc(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
    6159  : InternalFunctionImp(funcProto, name)
    6260{
    63   putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
     61  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete|ReadOnly|DontEnum);
    6462}
    6563
    66 JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)
     64JSValue* ErrorProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &/*args*/)
    6765{
    6866  // toString()
    6967  UString s = "Error";
    7068
    71   JSValue *v = thisObj->get(exec, namePropertyName);
     69  JSValue* v = thisObj->get(exec, exec->propertyNames().name);
    7270  if (!v->isUndefined()) {
    7371    s = v->toString(exec);
    7472  }
    7573
    76   v = thisObj->get(exec, messagePropertyName);
     74  v = thisObj->get(exec, exec->propertyNames().message);
    7775  if (!v->isUndefined()) {
    7876    s += ": " + v->toString(exec); // Mozilla compatible format
     
    8482// ------------------------------ ErrorObjectImp -------------------------------
    8583
    86 ErrorObjectImp::ErrorObjectImp(ExecState*, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
     84ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
    8785  : InternalFunctionImp(funcProto)
    8886{
    8987  // ECMA 15.11.3.1 Error.prototype
    90   putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
    91   putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
     88  putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly);
     89  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
    9290  //putDirect(namePropertyName, jsString(n));
    9391}
     
    9997
    10098// ECMA 15.9.3
    101 JSObject *ErrorObjectImp::construct(ExecState *exec, const List &args)
     99JSObject* ErrorObjectImp::construct(ExecState* exec, const List &args)
    102100{
    103   JSObject *proto = static_cast<JSObject *>(exec->lexicalInterpreter()->builtinErrorPrototype());
    104   JSObject *imp = new ErrorInstance(proto);
    105   JSObject *obj(imp);
     101  JSObject* proto = static_cast<JSObject*>(exec->lexicalInterpreter()->builtinErrorPrototype());
     102  JSObject* imp = new ErrorInstance(proto);
     103  JSObject* obj(imp);
    106104
    107105  if (!args[0]->isUndefined())
    108     imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
     106    imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
    109107
    110108  return obj;
     
    120118// ------------------------------ NativeErrorPrototype ----------------------
    121119
    122 NativeErrorPrototype::NativeErrorPrototype(ExecState*, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
     120NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, ErrorType et, UString name, UString message)
    123121  : JSObject(errorProto)
    124122{
    125123  errType = et;
    126   putDirect(namePropertyName, jsString(name), 0);
    127   putDirect(messagePropertyName, jsString(message), 0);
     124  putDirect(exec->propertyNames().name, jsString(name), 0);
     125  putDirect(exec->propertyNames().message, jsString(message), 0);
    128126}
    129127
     
    132130const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0};
    133131
    134 NativeErrorImp::NativeErrorImp(ExecState*, FunctionPrototype* funcProto, JSObject* prot)
     132NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, JSObject* prot)
    135133  : InternalFunctionImp(funcProto)
    136134  , proto(prot)
    137135{
    138   putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
    139   putDirect(prototypePropertyName, proto, DontDelete|ReadOnly|DontEnum);
     136  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
     137  putDirect(exec->propertyNames().prototype, proto, DontDelete|ReadOnly|DontEnum);
    140138}
    141139
     
    145143}
    146144
    147 JSObject *NativeErrorImp::construct(ExecState *exec, const List &args)
     145JSObject* NativeErrorImp::construct(ExecState* exec, const List& args)
    148146{
    149   JSObject *imp = new ErrorInstance(proto);
    150   JSObject *obj(imp);
     147  JSObject* imp = new ErrorInstance(proto);
     148  JSObject* obj(imp);
    151149  if (!args[0]->isUndefined())
    152     imp->putDirect(messagePropertyName, jsString(args[0]->toString(exec)));
     150    imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec)));
    153151  return obj;
    154152}
    155153
    156 JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
     154JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
    157155{
    158   return construct(exec,args);
     156  return construct(exec, args);
    159157}
    160158
  • trunk/JavaScriptCore/kjs/function.cpp

    r20304 r20310  
    263263{
    264264    // Find the arguments from the closest context.
    265     if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
     265    if (propertyName == exec->propertyNames().arguments) {
    266266        slot.setCustom(this, argumentsGetter);
    267267        return true;
     
    269269
    270270    // Compute length of parameters.
    271     if (propertyName == lengthPropertyName) {
     271    if (propertyName == exec->propertyNames().length) {
    272272        slot.setCustom(this, lengthGetter);
    273273        return true;
    274274    }
    275275
    276     if (propertyName == callerPropertyName) {
     276    if (propertyName == exec->propertyNames().caller) {
    277277        slot.setCustom(this, callerGetter);
    278278        return true;
     
    284284void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
    285285{
    286     if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
     286    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    287287        return;
    288288    InternalFunctionImp::put(exec, propertyName, value, attr);
     
    291291bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
    292292{
    293     if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)
     293    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    294294        return false;
    295295    return InternalFunctionImp::deleteProperty(exec, propertyName);
     
    306306{
    307307    if (!parameters)
    308         return Identifier::null();
     308        return CommonIdentifiers::shared()->nullIdentifier;
    309309
    310310    if (static_cast<size_t>(index) >= parameters->size())
    311         return Identifier::null();
     311        return CommonIdentifiers::shared()->nullIdentifier;
    312312 
    313313    Identifier name = parameters->at(index).name;
     
    316316    for (size_t i = index + 1; i < parameters->size(); ++i)
    317317        if (parameters->at(i).name == name)
    318             return Identifier::null();
     318            return CommonIdentifiers::shared()->nullIdentifier;
    319319
    320320    return name;
     
    342342{
    343343  JSObject* proto;
    344   JSValue* p = get(exec,prototypePropertyName);
     344  JSValue* p = get(exec, exec->propertyNames().prototype);
    345345  if (p->isObject())
    346346    proto = static_cast<JSObject*>(p);
     
    422422  assert(indexIsNumber && indexAsNumber < size);
    423423 
    424   _map[indexAsNumber] = Identifier::null();
     424  _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier;
    425425}
    426426
     
    450450indexToNameMap(func, args)
    451451{
    452   putDirect(calleePropertyName, func, DontEnum);
    453   putDirect(lengthPropertyName, args.size(), DontEnum);
     452  putDirect(exec->propertyNames().callee, func, DontEnum);
     453  putDirect(exec->propertyNames().length, args.size(), DontEnum);
    454454 
    455455  int i = 0;
     
    543543    }
    544544
    545     if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier()) {
     545    if (propertyName == exec->propertyNames().arguments) {
    546546        slot.setCustom(this, getArgumentsGetter());
    547547        return true;
     
    553553bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName)
    554554{
    555     if (propertyName == exec->dynamicInterpreter()->argumentsIdentifier())
     555    if (propertyName == exec->propertyNames().arguments)
    556556        return false;
    557557    return JSObject::deleteProperty(exec, propertyName);
     
    585585
    586586
    587 GlobalFuncImp::GlobalFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     587GlobalFuncImp::GlobalFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    588588  : InternalFunctionImp(funcProto, name)
    589589  , id(i)
    590590{
    591   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     591  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    592592}
    593593
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r20004 r20310  
    4444  static const Identifier* callPropertyName = new Identifier("call");
    4545
    46   putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
    47   putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
     46  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
     47  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
    4848  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2, *applyPropertyName), DontEnum);
    4949  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1, *callPropertyName), DontEnum);
     
    6262// ------------------------------ FunctionProtoFunc -------------------------
    6363
    64 FunctionProtoFunc::FunctionProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     64FunctionProtoFunc::FunctionProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    6565  : InternalFunctionImp(funcProto, name)
    6666  , id(i)
    6767{
    68   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
    69 }
    70 
    71 JSValue *FunctionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
    72 {
    73   JSValue *result = NULL;
     68  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
     69}
     70
     71JSValue* FunctionProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
     72{
     73  JSValue* result = NULL;
    7474
    7575  switch (id) {
     
    114114
    115115        JSObject *argArrayObj = static_cast<JSObject *>(argArray);
    116         unsigned int length = argArrayObj->get(exec,lengthPropertyName)->toUInt32(exec);
     116        unsigned int length = argArrayObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    117117        for (unsigned int i = 0; i < length; i++)
    118118          applyArgs.append(argArrayObj->get(exec,i));
     
    147147// ------------------------------ FunctionObjectImp ----------------------------
    148148
    149 FunctionObjectImp::FunctionObjectImp(ExecState*, FunctionPrototype* funcProto)
     149FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* funcProto)
    150150  : InternalFunctionImp(funcProto)
    151151{
    152   putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
     152  putDirect(exec->propertyNames().prototype, funcProto, DontEnum|DontDelete|ReadOnly);
    153153
    154154  // no. of arguments for constructor
    155   putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     155  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    156156}
    157157
     
    244244  List consArgs;
    245245
    246   JSObject *objCons = exec->lexicalInterpreter()->builtinObject();
    247   JSObject *prototype = objCons->construct(exec,List::empty());
    248   prototype->put(exec, constructorPropertyName, fimp, DontEnum|DontDelete|ReadOnly);
    249   fimp->put(exec, prototypePropertyName, prototype, Internal|DontDelete);
     246  JSObject* objCons = exec->lexicalInterpreter()->builtinObject();
     247  JSObject* prototype = objCons->construct(exec,List::empty());
     248  prototype->put(exec, exec->propertyNames().constructor, fimp, DontEnum|DontDelete|ReadOnly);
     249  fimp->put(exec, exec->propertyNames().prototype, prototype, Internal|DontDelete);
    250250  return fimp;
    251251}
  • trunk/JavaScriptCore/kjs/grammar.y

    r20304 r20310  
    3333#include "lexer.h"
    3434#include "internal.h"
    35 
     35#include "CommonIdentifiers.h"
     36   
    3637// Not sure why, but yacc doesn't add this define along with the others.
    3738#define yylloc kjsyylloc
     
    816817
    817818TryStatement:
    818     TRY Block FINALLY Block             { $$ = new TryNode($2, Identifier::null(), 0, $4); DBG($$, @1, @2); }
     819TRY Block FINALLY Block             { $$ = new TryNode($2, CommonIdentifiers::shared()->nullIdentifier, 0, $4); DBG($$, @1, @2); }
    819820  | TRY Block CATCH '(' IDENT ')' Block { $$ = new TryNode($2, *$5, $7, 0); DBG($$, @1, @2); }
    820821  | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
     
    834835
    835836FunctionExpr:
    836     FUNCTION '(' ')' FunctionBody       { $$ = new FuncExprNode(Identifier::null(), $4); }
     837    FUNCTION '(' ')' FunctionBody       { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $4); }
    837838  | FUNCTION '(' FormalParameterList ')' FunctionBody
    838                                         { $$ = new FuncExprNode(Identifier::null(), $5, $3); }
     839                                        { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3); }
    839840  | FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncExprNode(*$2, $5); }
    840841  | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody
     
    10021003   
    10031004    result = new PropertyNode(new PropertyNameNode(name),
    1004                               new FuncExprNode(Identifier::null(), body, params), type);
     1005                              new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, params), type);
    10051006
    10061007    return true;
  • trunk/JavaScriptCore/kjs/identifier.cpp

    r20004 r20310  
    2121
    2222#include "config.h"
    23 // For JavaScriptCore we need to avoid having static constructors.
    24 // Our strategy is to declare the global objects with a different type (initialized to 0)
    25 // and then use placement new to initialize the global objects later. This is not completely
    26 // portable, and it would be good to figure out a 100% clean way that still avoids code that
    27 // runs at init time.
    28 
    29 #if !PLATFORM(WIN_OS) // can't get this to compile on Visual C++ yet
    30 #define AVOID_STATIC_CONSTRUCTORS 1
    31 #else
    32 #define AVOID_STATIC_CONSTRUCTORS 0
    33 #endif
    34 
    35 #if AVOID_STATIC_CONSTRUCTORS
    36 #define KJS_IDENTIFIER_HIDE_GLOBALS 1
    37 #endif
    3823
    3924#include "identifier.h"
     
    210195}
    211196
    212 // Global constants for property name strings.
    213 
    214 #if !AVOID_STATIC_CONSTRUCTORS
    215     // Define an Identifier in the normal way.
    216     #define DEFINE_GLOBAL(name, string) extern const Identifier name(string);
    217 #else
    218     // Define an Identifier-sized array of pointers to avoid static initialization.
    219     // Use an array of pointers instead of an array of char in case there is some alignment issue.
    220     #define DEFINE_GLOBAL(name, string) \
    221         void * name[(sizeof(Identifier) + sizeof(void *) - 1) / sizeof(void *)];
    222 #endif
    223 
    224 const char * const nullCString = 0;
    225 
    226 DEFINE_GLOBAL(nullIdentifier, nullCString)
    227 DEFINE_GLOBAL(specialPrototypePropertyName, "__proto__")
    228 
    229 #define DEFINE_PROPERTY_NAME_GLOBAL(name) DEFINE_GLOBAL(name ## PropertyName, #name)
    230 KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(DEFINE_PROPERTY_NAME_GLOBAL)
    231 
    232 void Identifier::init()
    233 {
    234 #if AVOID_STATIC_CONSTRUCTORS
    235     static bool initialized;
    236     if (!initialized) {
    237         // Use placement new to initialize the globals.
    238 
    239         new (&nullIdentifier) Identifier(nullCString);
    240         new (&specialPrototypePropertyName) Identifier("__proto__");
    241 
    242         #define PLACEMENT_NEW_PROPERTY_NAME_GLOBAL(name) new(&name ## PropertyName) Identifier(#name);
    243         KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(PLACEMENT_NEW_PROPERTY_NAME_GLOBAL)
    244 
    245         initialized = true;
    246     }
    247 #endif
    248 }
    249 
    250197} // namespace KJS
  • trunk/JavaScriptCore/kjs/identifier.h

    r20295 r20310  
    3030        friend class PropertyMap;
    3131    public:
    32         static void init();
    33 
    3432        Identifier() { }
    3533        Identifier(const char* s) : _ustring(add(s)) { }
     
    5755        double toDouble() const { return _ustring.toDouble(); }
    5856       
    59         static const Identifier& null();
    60        
    6157        friend bool operator==(const Identifier&, const Identifier&);
    6258        friend bool operator!=(const Identifier&, const Identifier&);
     
    8379    };
    8480   
    85 #ifndef KJS_IDENTIFIER_HIDE_GLOBALS
    86     extern const Identifier nullIdentifier;
    87 
    88     inline const Identifier& Identifier::null()
    89         { return nullIdentifier; }
    90 #endif
    91 
    9281    inline bool operator==(const Identifier& a, const Identifier& b)
    9382        { return Identifier::equal(a, b); }
     
    9988        { return Identifier::equal(a, b); }
    10089
    101     // List of property names, passed to a macro so we can do set them up various
    102     // ways without repeating the list.
    103     #define KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(macro) \
    104         macro(arguments) \
    105         macro(callee) \
    106         macro(caller) \
    107         macro(constructor) \
    108         macro(fromCharCode) \
    109         macro(length) \
    110         macro(message) \
    111         macro(name) \
    112         macro(prototype) \
    113         macro(toLocaleString) \
    114         macro(toString) \
    115         macro(toFixed) \
    116         macro(toExponential) \
    117         macro(toPrecision) \
    118         macro(valueOf)
    119 
    120     // Define external global variables for all property names above (and one more).
    121 #ifndef KJS_IDENTIFIER_HIDE_GLOBALS
    122     extern const Identifier specialPrototypePropertyName;
    123 
    124     #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) extern const Identifier name ## PropertyName;
    125     KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
    126     #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
    127 #endif
    128 
    12990} // namespace KJS
    13091
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r20004 r20310  
    9797    JSLock lock;
    9898
    99     Identifier::init();
    100 
    10199    m_refCount = 0;
    102100    m_timeoutTime = 0;
     
    109107   
    110108    m_compatMode = NativeMode;
    111     m_argumentsPropertyName = &argumentsPropertyName;
    112     m_specialPrototypePropertyName = &specialPrototypePropertyName;
    113109
    114110    if (s_hook) {
     
    228224    m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype);
    229225   
    230     m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum);
    231     m_ObjectPrototype->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly);
    232     m_FunctionPrototype->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly);
    233     m_ArrayPrototype->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly);
    234     m_BooleanPrototype->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly);
    235     m_StringPrototype->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly);
    236     m_NumberPrototype->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly);
    237     m_DatePrototype->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly);
    238     m_RegExpPrototype->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly);
    239     m_ErrorPrototype->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly);
    240     m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly);
    241     m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly);
    242     m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
    243     m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
    244     m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly);
    245     m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly);
     226    m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum);
     227    m_ObjectPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Object, DontEnum | DontDelete | ReadOnly);
     228    m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum | DontDelete | ReadOnly);
     229    m_ArrayPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Array, DontEnum | DontDelete | ReadOnly);
     230    m_BooleanPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Boolean, DontEnum | DontDelete | ReadOnly);
     231    m_StringPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_String, DontEnum | DontDelete | ReadOnly);
     232    m_NumberPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Number, DontEnum | DontDelete | ReadOnly);
     233    m_DatePrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Date, DontEnum | DontDelete | ReadOnly);
     234    m_RegExpPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RegExp, DontEnum | DontDelete | ReadOnly);
     235    m_ErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Error, DontEnum | DontDelete | ReadOnly);
     236    m_EvalErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_EvalError, DontEnum | DontDelete | ReadOnly);
     237    m_RangeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RangeError, DontEnum | DontDelete | ReadOnly);
     238    m_ReferenceErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_ReferenceError, DontEnum | DontDelete | ReadOnly);
     239    m_SyntaxErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_SyntaxError, DontEnum | DontDelete | ReadOnly);
     240    m_TypeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_TypeError, DontEnum | DontDelete | ReadOnly);
     241    m_UriErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_UriError, DontEnum | DontDelete | ReadOnly);
    246242
    247243    // Set global object prototype
  • trunk/JavaScriptCore/kjs/interpreter.h

    r20004 r20310  
    328328    virtual bool isSafeScript(const Interpreter*) { return true; }
    329329 
    330     // This is a workaround to avoid accessing the global variables for these identifiers in
    331     // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
    332     const Identifier& argumentsIdentifier() { return *m_argumentsPropertyName; }
    333     const Identifier& specialPrototypeIdentifier() { return *m_specialPrototypePropertyName; }
    334    
    335330    // Chained list of interpreters (ring)
    336331    static Interpreter* firstInterpreter() { return s_hook; }
     
    376371   
    377372    ExecState m_globalExec;
    378 
    379     const Identifier *m_argumentsPropertyName;
    380     const Identifier *m_specialPrototypePropertyName;
    381373
    382374    // Chained list of interpreters (ring) - for collector
  • trunk/JavaScriptCore/kjs/lookup.h

    r18912 r20310  
    353353      , id(i) \
    354354    { \
    355        put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
     355       put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
    356356    } \
    357357    /* Macro user needs to implement the callAsFunction function. */ \
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r17372 r20310  
    122122  , id(i)
    123123{
    124   putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
     124  putDirect(exec->propertyNames().length, l, DontDelete|ReadOnly|DontEnum);
    125125}
    126126
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r20291 r20310  
    446446    array = static_cast<JSObject*>(element->evaluate(exec));
    447447    KJS_CHECKEXCEPTIONVALUE
    448     length = opt ? array->get(exec,lengthPropertyName)->toInt32(exec) : 0;
     448    length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0;
    449449  } else {
    450450    JSValue *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty());
     
    454454
    455455  if (opt)
    456     array->put(exec,lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);
     456    array->put(exec, exec->propertyNames().length, jsNumber(elision + length), DontEnum | DontDelete);
    457457
    458458  return array;
     
    23702370
    23712371  JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    2372   proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
    2373   func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
     2372  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
     2373  func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
    23742374
    23752375  int plen = 0;
     
    23772377    func->addParameter(p->ident());
    23782378
    2379   func->put(exec, lengthPropertyName, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
     2379  func->put(exec, exec->propertyNames().length, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
    23802380
    23812381  // ECMA 10.2.2
     
    24162416  }
    24172417
    2418   FunctionImp *func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
    2419   JSObject *proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
    2420   proto->put(exec, constructorPropertyName, func, ReadOnly|DontDelete|DontEnum);
    2421   func->put(exec, prototypePropertyName, proto, Internal|DontDelete);
     2418  FunctionImp* func = new DeclaredFunctionImp(exec, ident, body.get(), context->scopeChain());
     2419  JSObject* proto = exec->lexicalInterpreter()->builtinObject()->construct(exec, List::empty());
     2420  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
     2421  func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
    24222422
    24232423  int plen = 0;
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r17372 r20310  
    5353  // The constructor will be added later, after NumberObjectImp has been constructed
    5454
    55   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString,       1, toStringPropertyName), DontEnum);
    56   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
    57   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf,        0, valueOfPropertyName), DontEnum);
    58   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed,        1, toFixedPropertyName), DontEnum);
    59   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential,  1, toExponentialPropertyName), DontEnum);
    60   putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision,    1, toPrecisionPropertyName), DontEnum);
     55  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString,       1, exec->propertyNames().toString), DontEnum);
     56  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
     57  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf,        0, exec->propertyNames().valueOf), DontEnum);
     58  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed,        1, exec->propertyNames().toFixed), DontEnum);
     59  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential,  1, exec->propertyNames().toExponential), DontEnum);
     60  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision,    1, exec->propertyNames().toPrecision), DontEnum);
    6161}
    6262
     
    6464// ------------------------------ NumberProtoFunc ---------------------------
    6565
    66 NumberProtoFunc::NumberProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     66NumberProtoFunc::NumberProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    6767   : InternalFunctionImp(funcProto, name)
    6868   , id(i)
    6969{
    70   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     70  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    7171}
    7272
     
    417417@end
    418418*/
    419 NumberObjectImp::NumberObjectImp(ExecState*, FunctionPrototype* funcProto, NumberPrototype* numberProto)
     419NumberObjectImp::NumberObjectImp(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto)
    420420  : InternalFunctionImp(funcProto)
    421421{
    422422  // Number.Prototype
    423   putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
     423  putDirect(exec->propertyNames().prototype, numberProto,DontEnum|DontDelete|ReadOnly);
    424424
    425425  // no. of arguments for constructor
    426   putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     426  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    427427}
    428428
  • trunk/JavaScriptCore/kjs/object.cpp

    r18963 r20310  
    206206
    207207// ECMA 8.6.2.2
    208 void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
     208void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr)
    209209{
    210210  assert(value);
    211211
    212212  // non-standard netscape extension
    213   if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
     213  if (propertyName == exec->propertyNames().underscoreProto) {
    214214    setPrototype(value);
    215215    return;
     
    354354
    355355// ECMA 8.6.2.6
    356 JSValue *JSObject::defaultValue(ExecState *exec, JSType hint) const
     356JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
    357357{
    358358  Identifier firstPropertyName;
     
    360360  /* Prefer String for Date objects */
    361361  if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {
    362     firstPropertyName = toStringPropertyName;
    363     secondPropertyName = valueOfPropertyName;
     362    firstPropertyName = exec->propertyNames().toString;
     363    secondPropertyName = exec->propertyNames().valueOf;
    364364  } else {
    365     firstPropertyName = valueOfPropertyName;
    366     secondPropertyName = toStringPropertyName;
     365    firstPropertyName = exec->propertyNames().valueOf;
     366    secondPropertyName = exec->propertyNames().toString;
    367367  }
    368368
     
    456456bool JSObject::hasInstance(ExecState* exec, JSValue* value)
    457457{
    458     JSValue* proto = get(exec, prototypePropertyName);
     458    JSValue* proto = get(exec, exec->propertyNames().prototype);
    459459    if (!proto->isObject()) {
    460460        throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
  • trunk/JavaScriptCore/kjs/object.h

    r20004 r20310  
    2727
    2828#include "JSType.h"
     29#include "CommonIdentifiers.h"
    2930#include "interpreter.h"
    3031#include "property_map.h"
     
    246247     * @param propertyValue The value to set
    247248     */
    248     virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
    249     virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
     249    virtual void put(ExecState* exec, const Identifier &propertyName, JSValue* value, int attr = None);
     250    virtual void put(ExecState* exec, unsigned propertyName, JSValue* value, int attr = None);
    250251
    251252    /**
     
    565566// but it makes a big difference to property lookup that derived classes can inline their
    566567// base class call to this.
    567 ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
     568ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    568569{
    569570    if (JSValue **location = getDirectLocation(propertyName)) {
     
    576577
    577578    // non-standard Netscape extension
    578     if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
     579    if (propertyName == exec->propertyNames().underscoreProto) {
    579580        slot.setValueSlot(this, &_proto);
    580581        return true;
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r20004 r20310  
    4242    static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__");
    4343
    44     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
    45     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
    46     putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
     44    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
     45    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, exec->propertyNames().toLocaleString), DontEnum);
     46    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum);
    4747    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty, 1, *hasOwnPropertyPropertyName), DontEnum);
    4848    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1, *propertyIsEnumerablePropertyName), DontEnum);
     
    5959// ------------------------------ ObjectProtoFunc --------------------------------
    6060
    61 ObjectProtoFunc::ObjectProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     61ObjectProtoFunc::ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    6262  : InternalFunctionImp(funcProto, name)
    6363  , id(i)
    6464{
    65   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     65  putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum);
    6666}
    6767
     
    154154// ------------------------------ ObjectObjectImp --------------------------------
    155155
    156 ObjectObjectImp::ObjectObjectImp(ExecState*, ObjectPrototype* objProto, FunctionPrototype* funcProto)
     156ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto)
    157157  : InternalFunctionImp(funcProto)
    158158{
    159159  // ECMA 15.2.3.1
    160   putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
     160  putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly);
    161161
    162162  // no. of arguments for constructor
    163   putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     163  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    164164}
    165165
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r20004 r20310  
    5454  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Exec, 0, *execPropertyName), DontEnum);
    5555  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Test, 0, *testPropertyName), DontEnum);
    56   putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
     56  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum);
    5757}
    5858
    5959// ------------------------------ RegExpProtoFunc ---------------------------
    6060
    61 RegExpProtoFunc::RegExpProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     61RegExpProtoFunc::RegExpProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
    6262   : InternalFunctionImp(funcProto, name), id(i)
    6363{
    64   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     64  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
    6565}
    6666
     
    181181*/
    182182
    183 RegExpObjectImp::RegExpObjectImp(ExecState*, FunctionPrototype* funcProto, RegExpPrototype* regProto)
     183RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto)
    184184
    185185  : InternalFunctionImp(funcProto), lastInput(""), lastNumSubPatterns(0), multiline(false)
    186186{
    187187  // ECMA 15.10.5.1 RegExp.prototype
    188   putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
     188  putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly);
    189189
    190190  // no. of arguments for constructor
    191   putDirect(lengthPropertyName, jsNumber(2), ReadOnly|DontDelete|DontEnum);
     191  putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
    192192}
    193193
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r18718 r20310  
    7171bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
    7272{
    73   if (propertyName == lengthPropertyName) {
     73  if (propertyName == exec->propertyNames().length) {
    7474    slot.setCustom(this, lengthGetter);
    7575    return true;
     
    9292void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
    9393{
    94   if (propertyName == lengthPropertyName)
     94  if (propertyName == exec->propertyNames().length)
    9595    return;
    9696  JSObject::put(exec, propertyName, value, attr);
     
    9999bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)
    100100{
    101   if (propertyName == lengthPropertyName)
     101  if (propertyName == exec->propertyNames().length)
    102102    return false;
    103103  return JSObject::deleteProperty(exec, propertyName);
     
    155155*/
    156156// ECMA 15.5.4
    157 StringPrototype::StringPrototype(ExecState*, ObjectPrototype* objProto)
     157StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto)
    158158  : StringInstance(objProto)
    159159{
    160160  // The constructor will be added later, after StringObjectImp has been built
    161   putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
     161  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
    162162}
    163163
     
    169169// ------------------------------ StringProtoFunc ---------------------------
    170170
    171 StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     171StringProtoFunc::StringProtoFunc(ExecState* exec, int i, int len, const Identifier& name)
    172172  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
    173173  , id(i)
    174174{
    175   putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     175  putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum);
    176176}
    177177
     
    419419
    420420// ECMA 15.5.4.2 - 15.5.4.20
    421 JSValue *StringProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
    422 {
    423   JSValue *result = NULL;
     421JSValue* StringProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
     422{
     423  JSValue* result = NULL;
    424424
    425425  // toString and valueOf are no generic function.
     
    591591      if (u.isEmpty() && !reg->match(u, 0).isNull()) {
    592592        // empty string matched by regexp -> empty array
    593         res->put(exec,lengthPropertyName, jsNumber(0));
     593        res->put(exec, exec->propertyNames().length, jsNumber(0));
    594594        break;
    595595      }
     
    615615        if (u.isEmpty()) {
    616616          // empty separator matches empty string -> empty array
    617           put(exec,lengthPropertyName, jsNumber(0));
     617          put(exec, exec->propertyNames().length, jsNumber(0));
    618618          break;
    619619        } else {
     
    632632    if (static_cast<uint32_t>(i) != limit)
    633633      res->put(exec, i++, jsString(u.substr(p0)));
    634     res->put(exec,lengthPropertyName, jsNumber(i));
     634    res->put(exec, exec->propertyNames().length, jsNumber(i));
    635635    }
    636636    break;
     
    761761// ------------------------------ StringObjectImp ------------------------------
    762762
    763 StringObjectImp::StringObjectImp(ExecState *exec,
    764                                  FunctionPrototype *funcProto,
    765                                  StringPrototype *stringProto)
     763StringObjectImp::StringObjectImp(ExecState* exec,
     764                                 FunctionPrototype* funcProto,
     765                                 StringPrototype* stringProto)
    766766  : InternalFunctionImp(funcProto)
    767767{
    768768  // ECMA 15.5.3.1 String.prototype
    769   putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
    770 
    771   putDirectFunction(new StringObjectFuncImp(exec, funcProto, fromCharCodePropertyName), DontEnum);
     769  putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
     770
     771  putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
    772772
    773773  // no. of arguments for constructor
    774   putDirect(lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     774  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    775775}
    776776
     
    804804
    805805// ECMA 15.5.3.2 fromCharCode()
    806 StringObjectFuncImp::StringObjectFuncImp(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
     806StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name)
    807807  : InternalFunctionImp(funcProto, name)
    808808{
    809   putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
     809  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
    810810}
    811811
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r19894 r20310  
    119119TestFunctionImp::TestFunctionImp(int i, int length) : JSObject(), id(i)
    120120{
    121   putDirect(lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);
     121  putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum);
    122122}
    123123
Note: See TracChangeset for help on using the changeset viewer.