Changeset 20310 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Mar 18, 2007, 10:43:47 PM (18 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.h
r17372 r20310 27 27 #include "value.h" 28 28 #include "types.h" 29 #include "CommonIdentifiers.h" 29 30 30 31 namespace KJS { … … 76 77 bool hadException() const { return !!m_exception; } 77 78 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 78 83 private: 79 84 ExecState(Interpreter* interp, Context* con) … … 81 86 , m_context(con) 82 87 , m_exception(0) 88 , m_propertyNames(CommonIdentifiers::shared()) 83 89 { 84 90 } … … 86 92 Context* m_context; 87 93 JSValue* m_exception; 94 CommonIdentifiers* m_propertyNames; 88 95 }; 89 96 -
trunk/JavaScriptCore/kjs/array_object.cpp
r17610 r20310 90 90 bool ArrayInstance::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 91 91 { 92 if (propertyName == lengthPropertyName) {92 if (propertyName == exec->propertyNames().length) { 93 93 slot.setCustom(this, lengthGetter); 94 94 return true; … … 131 131 132 132 // 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) {133 void ArrayInstance::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) 134 { 135 if (propertyName == exec->propertyNames().length) { 136 136 unsigned int newLen = value->toUInt32(exec); 137 137 if (value->toNumber(exec) != double(newLen)) { … … 179 179 } 180 180 181 bool ArrayInstance::deleteProperty(ExecState *exec, const Identifier &propertyName)182 { 183 if (propertyName == lengthPropertyName)181 bool ArrayInstance::deleteProperty(ExecState* exec, const Identifier &propertyName) 182 { 183 if (propertyName == exec->propertyNames().length) 184 184 return false; 185 185 … … 436 436 // ------------------------------ ArrayProtoFunc ---------------------------- 437 437 438 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name)438 ArrayProtoFunc::ArrayProtoFunc(ExecState* exec, int i, int len, const Identifier& name) 439 439 : InternalFunctionImp(static_cast<FunctionPrototype*> 440 440 (exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 441 441 , id(i) 442 442 { 443 put(exec, lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);443 put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum); 444 444 } 445 445 … … 453 453 454 454 // 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);455 JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 456 { 457 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); 458 458 459 459 JSValue *result = 0; // work around gcc 4.0 bug in uninitialized variable warning … … 488 488 if (id == ToLocaleString) { 489 489 JSObject* o = element->toObject(exec); 490 JSValue* conversionFunction = o->get(exec, toLocaleStringPropertyName);490 JSValue* conversionFunction = o->get(exec, exec->propertyNames().toLocaleString); 491 491 if (conversionFunction->isObject() && static_cast<JSObject*>(conversionFunction)->implementsCall()) 492 492 str += static_cast<JSObject*>(conversionFunction)->call(exec, o, List())->toString(exec); … … 518 518 // Older versions tried to optimize out getting the length of thisObj 519 519 // 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); 521 521 while (k < length) { 522 522 if (JSValue *v = getProperty(exec, curObj, k)) … … 534 534 curObj = static_cast<JSObject *>(it++); // may be 0 535 535 } 536 arr->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);536 arr->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete); 537 537 538 538 result = arr; … … 541 541 case Pop:{ 542 542 if (length == 0) { 543 thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);543 thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete); 544 544 result = jsUndefined(); 545 545 } else { 546 546 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); 548 548 } 549 549 break; … … 553 553 thisObj->put(exec, length + n, args[n]); 554 554 length += args.size(); 555 thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);555 thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete); 556 556 result = jsNumber(length); 557 557 break; … … 581 581 case Shift: { 582 582 if (length == 0) { 583 thisObj->put(exec, lengthPropertyName, jsNumber(length), DontEnum | DontDelete);583 thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete); 584 584 result = jsUndefined(); 585 585 } else { … … 592 592 } 593 593 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); 595 595 } 596 596 break; … … 635 635 resObj->put(exec, n, v); 636 636 } 637 resObj->put(exec, lengthPropertyName, jsNumber(n), DontEnum | DontDelete);637 resObj->put(exec, exec->propertyNames().length, jsNumber(n), DontEnum | DontDelete); 638 638 break; 639 639 } … … 662 662 663 663 if (length == 0) { 664 thisObj->put(exec, lengthPropertyName, jsNumber(0), DontEnum | DontDelete);664 thisObj->put(exec, exec->propertyNames().length, jsNumber(0), DontEnum | DontDelete); 665 665 result = thisObj; 666 666 break; … … 728 728 resObj->put(exec, k, v); 729 729 } 730 resObj->put(exec, lengthPropertyName, jsNumber(deleteCount), DontEnum | DontDelete);730 resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete); 731 731 732 732 unsigned int additionalArgs = maxInt( args.size() - 2, 0 ); … … 760 760 thisObj->put(exec, k+begin, args[k+2]); 761 761 } 762 thisObj->put(exec, lengthPropertyName, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);762 thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete); 763 763 break; 764 764 } … … 775 775 thisObj->put(exec, k, args[k]); 776 776 result = jsNumber(length + nrArgs); 777 thisObj->put(exec, lengthPropertyName, result, DontEnum | DontDelete);777 thisObj->put(exec, exec->propertyNames().length, result, DontEnum | DontDelete); 778 778 break; 779 779 } … … 936 936 { 937 937 // 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); 939 939 940 940 // 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); 942 942 } 943 943 -
trunk/JavaScriptCore/kjs/bool_object.cpp
r17372 r20310 47 47 // The constructor will be added later by Interpreter::Interpreter() 48 48 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); 51 51 setInternalValue(jsBoolean(false)); 52 52 } … … 55 55 // ------------------------------ BooleanProtoFunc -------------------------- 56 56 57 BooleanProtoFunc::BooleanProtoFunc(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)57 BooleanProtoFunc::BooleanProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 58 58 : InternalFunctionImp(funcProto, name) 59 59 , id(i) 60 60 { 61 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);61 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 62 62 } 63 63 64 64 65 65 // ECMA 15.6.4.2 + 15.6.4.3 66 JSValue *BooleanProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)66 JSValue *BooleanProtoFunc::callAsFunction(ExecState* exec, JSObject *thisObj, const List &/*args*/) 67 67 { 68 68 // no generic function. "this" has to be a Boolean object … … 83 83 84 84 85 BooleanObjectImp::BooleanObjectImp(ExecState* , FunctionPrototype* funcProto, BooleanPrototype* booleanProto)85 BooleanObjectImp::BooleanObjectImp(ExecState* exec, FunctionPrototype* funcProto, BooleanPrototype* booleanProto) 86 86 : InternalFunctionImp(funcProto) 87 87 { 88 putDirect( prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);88 putDirect(exec->propertyNames().prototype, booleanProto, DontEnum|DontDelete|ReadOnly); 89 89 90 90 // no. of arguments for constructor 91 putDirect( lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);91 putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 92 92 } 93 93 -
trunk/JavaScriptCore/kjs/completion.h
r17372 r20310 26 26 #define _KJS_COMPLETION_H_ 27 27 28 #include " identifier.h"28 #include "CommonIdentifiers.h" 29 29 #include "value.h" 30 30 … … 48 48 class Completion { 49 49 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) 51 51 : comp(c), val(v), tar(t) { } 52 52 -
trunk/JavaScriptCore/kjs/date_object.cpp
r20205 r20310 434 434 // ------------------------------ DateProtoFunc ----------------------------- 435 435 436 DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len, const Identifier& name)436 DateProtoFunc::DateProtoFunc(ExecState* exec, int i, int len, const Identifier& name) 437 437 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 438 438 , id(abs(i)) … … 440 440 // We use a negative ID to denote the "UTC" variant. 441 441 { 442 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);442 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 443 443 } 444 444 … … 600 600 static const Identifier* UTCPropertyName = new Identifier("UTC"); 601 601 602 putDirect( prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);602 putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly); 603 603 putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, *parsePropertyName), DontEnum); 604 604 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); 606 606 } 607 607 … … 669 669 // ------------------------------ DateObjectFuncImp ---------------------------- 670 670 671 DateObjectFuncImp::DateObjectFuncImp(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)671 DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 672 672 : InternalFunctionImp(funcProto, name), id(i) 673 673 { 674 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);674 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 675 675 } 676 676 -
trunk/JavaScriptCore/kjs/error_object.cpp
r17372 r20310 44 44 45 45 // ECMA 15.9.4 46 ErrorPrototype::ErrorPrototype(ExecState *exec, 47 ObjectPrototype *objectProto, 48 FunctionPrototype *funcProto) 46 ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto) 49 47 : JSObject(objectProto) 50 48 { 51 49 // The constructor will be added later in ErrorObjectImp's constructor 52 50 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); 56 54 } 57 55 58 56 // ------------------------------ ErrorProtoFunc ---------------------------- 59 57 60 ErrorProtoFunc::ErrorProtoFunc(ExecState* , FunctionPrototype* funcProto, const Identifier& name)58 ErrorProtoFunc::ErrorProtoFunc(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name) 61 59 : InternalFunctionImp(funcProto, name) 62 60 { 63 putDirect( lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);61 putDirect(exec->propertyNames().length, jsNumber(0), DontDelete|ReadOnly|DontEnum); 64 62 } 65 63 66 JSValue *ErrorProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &/*args*/)64 JSValue* ErrorProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &/*args*/) 67 65 { 68 66 // toString() 69 67 UString s = "Error"; 70 68 71 JSValue *v = thisObj->get(exec, namePropertyName);69 JSValue* v = thisObj->get(exec, exec->propertyNames().name); 72 70 if (!v->isUndefined()) { 73 71 s = v->toString(exec); 74 72 } 75 73 76 v = thisObj->get(exec, messagePropertyName);74 v = thisObj->get(exec, exec->propertyNames().message); 77 75 if (!v->isUndefined()) { 78 76 s += ": " + v->toString(exec); // Mozilla compatible format … … 84 82 // ------------------------------ ErrorObjectImp ------------------------------- 85 83 86 ErrorObjectImp::ErrorObjectImp(ExecState* , FunctionPrototype* funcProto, ErrorPrototype* errorProto)84 ErrorObjectImp::ErrorObjectImp(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto) 87 85 : InternalFunctionImp(funcProto) 88 86 { 89 87 // 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); 92 90 //putDirect(namePropertyName, jsString(n)); 93 91 } … … 99 97 100 98 // ECMA 15.9.3 101 JSObject *ErrorObjectImp::construct(ExecState *exec, const List &args)99 JSObject* ErrorObjectImp::construct(ExecState* exec, const List &args) 102 100 { 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); 106 104 107 105 if (!args[0]->isUndefined()) 108 imp->putDirect( messagePropertyName, jsString(args[0]->toString(exec)));106 imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); 109 107 110 108 return obj; … … 120 118 // ------------------------------ NativeErrorPrototype ---------------------- 121 119 122 NativeErrorPrototype::NativeErrorPrototype(ExecState* , ErrorPrototype* errorProto, ErrorType et, UString name, UString message)120 NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorProto, ErrorType et, UString name, UString message) 123 121 : JSObject(errorProto) 124 122 { 125 123 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); 128 126 } 129 127 … … 132 130 const ClassInfo NativeErrorImp::info = {"Function", &InternalFunctionImp::info, 0, 0}; 133 131 134 NativeErrorImp::NativeErrorImp(ExecState* , FunctionPrototype* funcProto, JSObject* prot)132 NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, JSObject* prot) 135 133 : InternalFunctionImp(funcProto) 136 134 , proto(prot) 137 135 { 138 putDirect( lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5139 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); 140 138 } 141 139 … … 145 143 } 146 144 147 JSObject *NativeErrorImp::construct(ExecState *exec, const List &args)145 JSObject* NativeErrorImp::construct(ExecState* exec, const List& args) 148 146 { 149 JSObject *imp = new ErrorInstance(proto);150 JSObject *obj(imp);147 JSObject* imp = new ErrorInstance(proto); 148 JSObject* obj(imp); 151 149 if (!args[0]->isUndefined()) 152 imp->putDirect( messagePropertyName, jsString(args[0]->toString(exec)));150 imp->putDirect(exec->propertyNames().message, jsString(args[0]->toString(exec))); 153 151 return obj; 154 152 } 155 153 156 JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)154 JSValue* NativeErrorImp::callAsFunction(ExecState* exec, JSObject*, const List& args) 157 155 { 158 return construct(exec, args);156 return construct(exec, args); 159 157 } 160 158 -
trunk/JavaScriptCore/kjs/function.cpp
r20304 r20310 263 263 { 264 264 // Find the arguments from the closest context. 265 if (propertyName == exec-> dynamicInterpreter()->argumentsIdentifier()) {265 if (propertyName == exec->propertyNames().arguments) { 266 266 slot.setCustom(this, argumentsGetter); 267 267 return true; … … 269 269 270 270 // Compute length of parameters. 271 if (propertyName == lengthPropertyName) {271 if (propertyName == exec->propertyNames().length) { 272 272 slot.setCustom(this, lengthGetter); 273 273 return true; 274 274 } 275 275 276 if (propertyName == callerPropertyName) {276 if (propertyName == exec->propertyNames().caller) { 277 277 slot.setCustom(this, callerGetter); 278 278 return true; … … 284 284 void FunctionImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) 285 285 { 286 if (propertyName == exec-> dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)286 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) 287 287 return; 288 288 InternalFunctionImp::put(exec, propertyName, value, attr); … … 291 291 bool FunctionImp::deleteProperty(ExecState* exec, const Identifier& propertyName) 292 292 { 293 if (propertyName == exec-> dynamicInterpreter()->argumentsIdentifier() || propertyName == lengthPropertyName)293 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length) 294 294 return false; 295 295 return InternalFunctionImp::deleteProperty(exec, propertyName); … … 306 306 { 307 307 if (!parameters) 308 return Identifier::null();308 return CommonIdentifiers::shared()->nullIdentifier; 309 309 310 310 if (static_cast<size_t>(index) >= parameters->size()) 311 return Identifier::null();311 return CommonIdentifiers::shared()->nullIdentifier; 312 312 313 313 Identifier name = parameters->at(index).name; … … 316 316 for (size_t i = index + 1; i < parameters->size(); ++i) 317 317 if (parameters->at(i).name == name) 318 return Identifier::null();318 return CommonIdentifiers::shared()->nullIdentifier; 319 319 320 320 return name; … … 342 342 { 343 343 JSObject* proto; 344 JSValue* p = get(exec, prototypePropertyName);344 JSValue* p = get(exec, exec->propertyNames().prototype); 345 345 if (p->isObject()) 346 346 proto = static_cast<JSObject*>(p); … … 422 422 assert(indexIsNumber && indexAsNumber < size); 423 423 424 _map[indexAsNumber] = Identifier::null();424 _map[indexAsNumber] = CommonIdentifiers::shared()->nullIdentifier; 425 425 } 426 426 … … 450 450 indexToNameMap(func, args) 451 451 { 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); 454 454 455 455 int i = 0; … … 543 543 } 544 544 545 if (propertyName == exec-> dynamicInterpreter()->argumentsIdentifier()) {545 if (propertyName == exec->propertyNames().arguments) { 546 546 slot.setCustom(this, getArgumentsGetter()); 547 547 return true; … … 553 553 bool ActivationImp::deleteProperty(ExecState* exec, const Identifier& propertyName) 554 554 { 555 if (propertyName == exec-> dynamicInterpreter()->argumentsIdentifier())555 if (propertyName == exec->propertyNames().arguments) 556 556 return false; 557 557 return JSObject::deleteProperty(exec, propertyName); … … 585 585 586 586 587 GlobalFuncImp::GlobalFuncImp(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)587 GlobalFuncImp::GlobalFuncImp(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 588 588 : InternalFunctionImp(funcProto, name) 589 589 , id(i) 590 590 { 591 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);591 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 592 592 } 593 593 -
trunk/JavaScriptCore/kjs/function_object.cpp
r20004 r20310 44 44 static const Identifier* callPropertyName = new Identifier("call"); 45 45 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); 48 48 putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2, *applyPropertyName), DontEnum); 49 49 putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1, *callPropertyName), DontEnum); … … 62 62 // ------------------------------ FunctionProtoFunc ------------------------- 63 63 64 FunctionProtoFunc::FunctionProtoFunc(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)64 FunctionProtoFunc::FunctionProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 65 65 : InternalFunctionImp(funcProto, name) 66 66 , id(i) 67 67 { 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 71 JSValue* FunctionProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args) 72 { 73 JSValue* result = NULL; 74 74 75 75 switch (id) { … … 114 114 115 115 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); 117 117 for (unsigned int i = 0; i < length; i++) 118 118 applyArgs.append(argArrayObj->get(exec,i)); … … 147 147 // ------------------------------ FunctionObjectImp ---------------------------- 148 148 149 FunctionObjectImp::FunctionObjectImp(ExecState* , FunctionPrototype* funcProto)149 FunctionObjectImp::FunctionObjectImp(ExecState* exec, FunctionPrototype* funcProto) 150 150 : InternalFunctionImp(funcProto) 151 151 { 152 putDirect( prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);152 putDirect(exec->propertyNames().prototype, funcProto, DontEnum|DontDelete|ReadOnly); 153 153 154 154 // no. of arguments for constructor 155 putDirect( lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);155 putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 156 156 } 157 157 … … 244 244 List consArgs; 245 245 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); 250 250 return fimp; 251 251 } -
trunk/JavaScriptCore/kjs/grammar.y
r20304 r20310 33 33 #include "lexer.h" 34 34 #include "internal.h" 35 35 #include "CommonIdentifiers.h" 36 36 37 // Not sure why, but yacc doesn't add this define along with the others. 37 38 #define yylloc kjsyylloc … … 816 817 817 818 TryStatement: 818 TRY Block FINALLY Block { $$ = new TryNode($2, Identifier::null(), 0, $4); DBG($$, @1, @2); }819 TRY Block FINALLY Block { $$ = new TryNode($2, CommonIdentifiers::shared()->nullIdentifier, 0, $4); DBG($$, @1, @2); } 819 820 | TRY Block CATCH '(' IDENT ')' Block { $$ = new TryNode($2, *$5, $7, 0); DBG($$, @1, @2); } 820 821 | TRY Block CATCH '(' IDENT ')' Block FINALLY Block … … 834 835 835 836 FunctionExpr: 836 FUNCTION '(' ')' FunctionBody { $$ = new FuncExprNode( Identifier::null(), $4); }837 FUNCTION '(' ')' FunctionBody { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $4); } 837 838 | FUNCTION '(' FormalParameterList ')' FunctionBody 838 { $$ = new FuncExprNode( Identifier::null(), $5, $3); }839 { $$ = new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, $5, $3); } 839 840 | FUNCTION IDENT '(' ')' FunctionBody { $$ = new FuncExprNode(*$2, $5); } 840 841 | FUNCTION IDENT '(' FormalParameterList ')' FunctionBody … … 1002 1003 1003 1004 result = new PropertyNode(new PropertyNameNode(name), 1004 new FuncExprNode( Identifier::null(), body, params), type);1005 new FuncExprNode(CommonIdentifiers::shared()->nullIdentifier, body, params), type); 1005 1006 1006 1007 return true; -
trunk/JavaScriptCore/kjs/identifier.cpp
r20004 r20310 21 21 22 22 #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 completely26 // portable, and it would be good to figure out a 100% clean way that still avoids code that27 // runs at init time.28 29 #if !PLATFORM(WIN_OS) // can't get this to compile on Visual C++ yet30 #define AVOID_STATIC_CONSTRUCTORS 131 #else32 #define AVOID_STATIC_CONSTRUCTORS 033 #endif34 35 #if AVOID_STATIC_CONSTRUCTORS36 #define KJS_IDENTIFIER_HIDE_GLOBALS 137 #endif38 23 39 24 #include "identifier.h" … … 210 195 } 211 196 212 // Global constants for property name strings.213 214 #if !AVOID_STATIC_CONSTRUCTORS215 // Define an Identifier in the normal way.216 #define DEFINE_GLOBAL(name, string) extern const Identifier name(string);217 #else218 // 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 #endif223 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_CONSTRUCTORS235 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 #endif248 }249 250 197 } // namespace KJS -
trunk/JavaScriptCore/kjs/identifier.h
r20295 r20310 30 30 friend class PropertyMap; 31 31 public: 32 static void init();33 34 32 Identifier() { } 35 33 Identifier(const char* s) : _ustring(add(s)) { } … … 57 55 double toDouble() const { return _ustring.toDouble(); } 58 56 59 static const Identifier& null();60 61 57 friend bool operator==(const Identifier&, const Identifier&); 62 58 friend bool operator!=(const Identifier&, const Identifier&); … … 83 79 }; 84 80 85 #ifndef KJS_IDENTIFIER_HIDE_GLOBALS86 extern const Identifier nullIdentifier;87 88 inline const Identifier& Identifier::null()89 { return nullIdentifier; }90 #endif91 92 81 inline bool operator==(const Identifier& a, const Identifier& b) 93 82 { return Identifier::equal(a, b); } … … 99 88 { return Identifier::equal(a, b); } 100 89 101 // List of property names, passed to a macro so we can do set them up various102 // 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_GLOBALS122 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_GLOBAL127 #endif128 129 90 } // namespace KJS 130 91 -
trunk/JavaScriptCore/kjs/interpreter.cpp
r20004 r20310 97 97 JSLock lock; 98 98 99 Identifier::init();100 101 99 m_refCount = 0; 102 100 m_timeoutTime = 0; … … 109 107 110 108 m_compatMode = NativeMode; 111 m_argumentsPropertyName = &argumentsPropertyName;112 m_specialPrototypePropertyName = &specialPrototypePropertyName;113 109 114 110 if (s_hook) { … … 228 224 m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype); 229 225 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); 246 242 247 243 // Set global object prototype -
trunk/JavaScriptCore/kjs/interpreter.h
r20004 r20310 328 328 virtual bool isSafeScript(const Interpreter*) { return true; } 329 329 330 // This is a workaround to avoid accessing the global variables for these identifiers in331 // important property lookup functions, to avoid taking PIC branches in Mach-O binaries332 const Identifier& argumentsIdentifier() { return *m_argumentsPropertyName; }333 const Identifier& specialPrototypeIdentifier() { return *m_specialPrototypePropertyName; }334 335 330 // Chained list of interpreters (ring) 336 331 static Interpreter* firstInterpreter() { return s_hook; } … … 376 371 377 372 ExecState m_globalExec; 378 379 const Identifier *m_argumentsPropertyName;380 const Identifier *m_specialPrototypePropertyName;381 373 382 374 // Chained list of interpreters (ring) - for collector -
trunk/JavaScriptCore/kjs/lookup.h
r18912 r20310 353 353 , id(i) \ 354 354 { \ 355 put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \355 put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum); \ 356 356 } \ 357 357 /* Macro user needs to implement the callAsFunction function. */ \ -
trunk/JavaScriptCore/kjs/math_object.cpp
r17372 r20310 122 122 , id(i) 123 123 { 124 putDirect( lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);124 putDirect(exec->propertyNames().length, l, DontDelete|ReadOnly|DontEnum); 125 125 } 126 126 -
trunk/JavaScriptCore/kjs/nodes.cpp
r20291 r20310 446 446 array = static_cast<JSObject*>(element->evaluate(exec)); 447 447 KJS_CHECKEXCEPTIONVALUE 448 length = opt ? array->get(exec, lengthPropertyName)->toInt32(exec) : 0;448 length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0; 449 449 } else { 450 450 JSValue *newArr = exec->lexicalInterpreter()->builtinArray()->construct(exec,List::empty()); … … 454 454 455 455 if (opt) 456 array->put(exec, lengthPropertyName, jsNumber(elision + length), DontEnum | DontDelete);456 array->put(exec, exec->propertyNames().length, jsNumber(elision + length), DontEnum | DontDelete); 457 457 458 458 return array; … … 2370 2370 2371 2371 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); 2374 2374 2375 2375 int plen = 0; … … 2377 2377 func->addParameter(p->ident()); 2378 2378 2379 func->put(exec, lengthPropertyName, jsNumber(plen), ReadOnly|DontDelete|DontEnum);2379 func->put(exec, exec->propertyNames().length, jsNumber(plen), ReadOnly|DontDelete|DontEnum); 2380 2380 2381 2381 // ECMA 10.2.2 … … 2416 2416 } 2417 2417 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); 2422 2422 2423 2423 int plen = 0; -
trunk/JavaScriptCore/kjs/number_object.cpp
r17372 r20310 53 53 // The constructor will be added later, after NumberObjectImp has been constructed 54 54 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); 61 61 } 62 62 … … 64 64 // ------------------------------ NumberProtoFunc --------------------------- 65 65 66 NumberProtoFunc::NumberProtoFunc(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)66 NumberProtoFunc::NumberProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 67 67 : InternalFunctionImp(funcProto, name) 68 68 , id(i) 69 69 { 70 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);70 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 71 71 } 72 72 … … 417 417 @end 418 418 */ 419 NumberObjectImp::NumberObjectImp(ExecState* , FunctionPrototype* funcProto, NumberPrototype* numberProto)419 NumberObjectImp::NumberObjectImp(ExecState* exec, FunctionPrototype* funcProto, NumberPrototype* numberProto) 420 420 : InternalFunctionImp(funcProto) 421 421 { 422 422 // Number.Prototype 423 putDirect( prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);423 putDirect(exec->propertyNames().prototype, numberProto,DontEnum|DontDelete|ReadOnly); 424 424 425 425 // no. of arguments for constructor 426 putDirect( lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);426 putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 427 427 } 428 428 -
trunk/JavaScriptCore/kjs/object.cpp
r18963 r20310 206 206 207 207 // ECMA 8.6.2.2 208 void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)208 void JSObject::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr) 209 209 { 210 210 assert(value); 211 211 212 212 // non-standard netscape extension 213 if (propertyName == exec-> dynamicInterpreter()->specialPrototypeIdentifier()) {213 if (propertyName == exec->propertyNames().underscoreProto) { 214 214 setPrototype(value); 215 215 return; … … 354 354 355 355 // ECMA 8.6.2.6 356 JSValue *JSObject::defaultValue(ExecState *exec, JSType hint) const356 JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const 357 357 { 358 358 Identifier firstPropertyName; … … 360 360 /* Prefer String for Date objects */ 361 361 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; 364 364 } else { 365 firstPropertyName = valueOfPropertyName;366 secondPropertyName = toStringPropertyName;365 firstPropertyName = exec->propertyNames().valueOf; 366 secondPropertyName = exec->propertyNames().toString; 367 367 } 368 368 … … 456 456 bool JSObject::hasInstance(ExecState* exec, JSValue* value) 457 457 { 458 JSValue* proto = get(exec, prototypePropertyName);458 JSValue* proto = get(exec, exec->propertyNames().prototype); 459 459 if (!proto->isObject()) { 460 460 throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property."); -
trunk/JavaScriptCore/kjs/object.h
r20004 r20310 27 27 28 28 #include "JSType.h" 29 #include "CommonIdentifiers.h" 29 30 #include "interpreter.h" 30 31 #include "property_map.h" … … 246 247 * @param propertyValue The value to set 247 248 */ 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); 250 251 251 252 /** … … 565 566 // but it makes a big difference to property lookup that derived classes can inline their 566 567 // base class call to this. 567 ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)568 ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 568 569 { 569 570 if (JSValue **location = getDirectLocation(propertyName)) { … … 576 577 577 578 // non-standard Netscape extension 578 if (propertyName == exec-> dynamicInterpreter()->specialPrototypeIdentifier()) {579 if (propertyName == exec->propertyNames().underscoreProto) { 579 580 slot.setValueSlot(this, &_proto); 580 581 return true; -
trunk/JavaScriptCore/kjs/object_object.cpp
r20004 r20310 42 42 static const Identifier* lookupSetterPropertyName = new Identifier("__lookupSetter__"); 43 43 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); 47 47 putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty, 1, *hasOwnPropertyPropertyName), DontEnum); 48 48 putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1, *propertyIsEnumerablePropertyName), DontEnum); … … 59 59 // ------------------------------ ObjectProtoFunc -------------------------------- 60 60 61 ObjectProtoFunc::ObjectProtoFunc(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)61 ObjectProtoFunc::ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 62 62 : InternalFunctionImp(funcProto, name) 63 63 , id(i) 64 64 { 65 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);65 putDirect(exec->propertyNames().length, len, DontDelete|ReadOnly|DontEnum); 66 66 } 67 67 … … 154 154 // ------------------------------ ObjectObjectImp -------------------------------- 155 155 156 ObjectObjectImp::ObjectObjectImp(ExecState* , ObjectPrototype* objProto, FunctionPrototype* funcProto)156 ObjectObjectImp::ObjectObjectImp(ExecState* exec, ObjectPrototype* objProto, FunctionPrototype* funcProto) 157 157 : InternalFunctionImp(funcProto) 158 158 { 159 159 // ECMA 15.2.3.1 160 putDirect( prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);160 putDirect(exec->propertyNames().prototype, objProto, DontEnum|DontDelete|ReadOnly); 161 161 162 162 // no. of arguments for constructor 163 putDirect( lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);163 putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 164 164 } 165 165 -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r20004 r20310 54 54 putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Exec, 0, *execPropertyName), DontEnum); 55 55 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); 57 57 } 58 58 59 59 // ------------------------------ RegExpProtoFunc --------------------------- 60 60 61 RegExpProtoFunc::RegExpProtoFunc(ExecState* , FunctionPrototype* funcProto, int i, int len, const Identifier& name)61 RegExpProtoFunc::RegExpProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 62 62 : InternalFunctionImp(funcProto, name), id(i) 63 63 { 64 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);64 putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum); 65 65 } 66 66 … … 181 181 */ 182 182 183 RegExpObjectImp::RegExpObjectImp(ExecState* , FunctionPrototype* funcProto, RegExpPrototype* regProto)183 RegExpObjectImp::RegExpObjectImp(ExecState* exec, FunctionPrototype* funcProto, RegExpPrototype* regProto) 184 184 185 185 : InternalFunctionImp(funcProto), lastInput(""), lastNumSubPatterns(0), multiline(false) 186 186 { 187 187 // ECMA 15.10.5.1 RegExp.prototype 188 putDirect( prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);188 putDirect(exec->propertyNames().prototype, regProto, DontEnum | DontDelete | ReadOnly); 189 189 190 190 // no. of arguments for constructor 191 putDirect( lengthPropertyName, jsNumber(2), ReadOnly|DontDelete|DontEnum);191 putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum); 192 192 } 193 193 -
trunk/JavaScriptCore/kjs/string_object.cpp
r18718 r20310 71 71 bool StringInstance::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) 72 72 { 73 if (propertyName == lengthPropertyName) {73 if (propertyName == exec->propertyNames().length) { 74 74 slot.setCustom(this, lengthGetter); 75 75 return true; … … 92 92 void StringInstance::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) 93 93 { 94 if (propertyName == lengthPropertyName)94 if (propertyName == exec->propertyNames().length) 95 95 return; 96 96 JSObject::put(exec, propertyName, value, attr); … … 99 99 bool StringInstance::deleteProperty(ExecState *exec, const Identifier &propertyName) 100 100 { 101 if (propertyName == lengthPropertyName)101 if (propertyName == exec->propertyNames().length) 102 102 return false; 103 103 return JSObject::deleteProperty(exec, propertyName); … … 155 155 */ 156 156 // ECMA 15.5.4 157 StringPrototype::StringPrototype(ExecState* , ObjectPrototype* objProto)157 StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto) 158 158 : StringInstance(objProto) 159 159 { 160 160 // 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); 162 162 } 163 163 … … 169 169 // ------------------------------ StringProtoFunc --------------------------- 170 170 171 StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name)171 StringProtoFunc::StringProtoFunc(ExecState* exec, int i, int len, const Identifier& name) 172 172 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 173 173 , id(i) 174 174 { 175 putDirect( lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);175 putDirect(exec->propertyNames().length, len, DontDelete | ReadOnly | DontEnum); 176 176 } 177 177 … … 419 419 420 420 // 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;421 JSValue* StringProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 422 { 423 JSValue* result = NULL; 424 424 425 425 // toString and valueOf are no generic function. … … 591 591 if (u.isEmpty() && !reg->match(u, 0).isNull()) { 592 592 // empty string matched by regexp -> empty array 593 res->put(exec, lengthPropertyName, jsNumber(0));593 res->put(exec, exec->propertyNames().length, jsNumber(0)); 594 594 break; 595 595 } … … 615 615 if (u.isEmpty()) { 616 616 // empty separator matches empty string -> empty array 617 put(exec, lengthPropertyName, jsNumber(0));617 put(exec, exec->propertyNames().length, jsNumber(0)); 618 618 break; 619 619 } else { … … 632 632 if (static_cast<uint32_t>(i) != limit) 633 633 res->put(exec, i++, jsString(u.substr(p0))); 634 res->put(exec, lengthPropertyName, jsNumber(i));634 res->put(exec, exec->propertyNames().length, jsNumber(i)); 635 635 } 636 636 break; … … 761 761 // ------------------------------ StringObjectImp ------------------------------ 762 762 763 StringObjectImp::StringObjectImp(ExecState *exec,764 FunctionPrototype *funcProto,765 StringPrototype *stringProto)763 StringObjectImp::StringObjectImp(ExecState* exec, 764 FunctionPrototype* funcProto, 765 StringPrototype* stringProto) 766 766 : InternalFunctionImp(funcProto) 767 767 { 768 768 // 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); 772 772 773 773 // no. of arguments for constructor 774 putDirect( lengthPropertyName, jsNumber(1), ReadOnly|DontDelete|DontEnum);774 putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 775 775 } 776 776 … … 804 804 805 805 // ECMA 15.5.3.2 fromCharCode() 806 StringObjectFuncImp::StringObjectFuncImp(ExecState* , FunctionPrototype* funcProto, const Identifier& name)806 StringObjectFuncImp::StringObjectFuncImp(ExecState* exec, FunctionPrototype* funcProto, const Identifier& name) 807 807 : InternalFunctionImp(funcProto, name) 808 808 { 809 putDirect( lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);809 putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum); 810 810 } 811 811 -
trunk/JavaScriptCore/kjs/testkjs.cpp
r19894 r20310 119 119 TestFunctionImp::TestFunctionImp(int i, int length) : JSObject(), id(i) 120 120 { 121 putDirect( lengthPropertyName,length,DontDelete|ReadOnly|DontEnum);121 putDirect(Identifier("length"), length, DontDelete | ReadOnly | DontEnum); 122 122 } 123 123
Note:
See TracChangeset
for help on using the changeset viewer.