Changeset 32807 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
- Timestamp:
- May 2, 2008, 3:07:53 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r32687 r32807 103 103 } 104 104 105 JSGlobalObject* JSGlobalObject::s_head = 0;106 107 105 void JSGlobalObject::deleteActivationStack() 108 106 { … … 123 121 d()->next->d()->prev = d()->prev; 124 122 d()->prev->d()->next = d()->next; 125 s_head = d()->next; 126 if (s_head == this) 127 s_head = 0; 123 JSGlobalObject*& headObject = head(); 124 if (headObject == this) 125 headObject = d()->next; 126 if (headObject == this) 127 headObject = 0; 128 128 129 129 deleteActivationStack(); … … 187 187 } 188 188 189 JSGlobalObject*& JSGlobalObject::head() 190 { 191 #if USE(MULTIPLE_THREADS) 192 static ThreadSpecific<JSGlobalObject*> sharedInstance; 193 return *sharedInstance; 194 #else 195 static JSGlobalObject* sharedInstance; 196 return sharedInstance; 197 #endif 198 } 199 189 200 void JSGlobalObject::init(JSObject* thisValue) 190 201 { 191 202 ASSERT(JSLock::currentThreadIsHoldingLock()); 192 203 193 if ( s_head) {194 d()->prev = s_head;195 d()->next = s_head->d()->next;196 s_head->d()->next->d()->prev = this;197 s_head->d()->next = this;204 if (JSGlobalObject*& headObject = head()) { 205 d()->prev = headObject; 206 d()->next = headObject->d()->next; 207 headObject->d()->next->d()->prev = this; 208 headObject->d()->next = this; 198 209 } else 199 s_head= d()->next = d()->prev = this;210 headObject = d()->next = d()->prev = this; 200 211 201 212 resetTimeoutCheck(); … … 219 230 d()->perThreadData.stringTable = &threadClassInfoHashTables()->stringTable; 220 231 d()->perThreadData.propertyNames = CommonIdentifiers::shared(); 232 d()->perThreadData.heap = Heap::threadHeap(); 221 233 222 234 d()->globalExec.set(new GlobalExecState(this, thisValue)); … … 236 248 void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value) 237 249 { 250 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 251 238 252 if (symbolTablePut(propertyName, value)) 239 253 return; … … 314 328 315 329 // Prototypes 316 d()->functionPrototype = new FunctionPrototype(exec);317 d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype);330 d()->functionPrototype = new (exec) FunctionPrototype(exec); 331 d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype); 318 332 d()->functionPrototype->setPrototype(d()->objectPrototype); 319 333 320 d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype);321 d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype);322 d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);323 d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);324 d()->datePrototype = new DatePrototype(exec, d()->objectPrototype);325 d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);326 d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);327 328 d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError");329 d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError");330 d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError");331 d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError");332 d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError");333 d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError");334 d()->arrayPrototype = new (exec) ArrayPrototype(exec, d()->objectPrototype); 335 d()->stringPrototype = new (exec) StringPrototype(exec, d()->objectPrototype); 336 d()->booleanPrototype = new (exec) BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype); 337 d()->numberPrototype = new (exec) NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype); 338 d()->datePrototype = new (exec) DatePrototype(exec, d()->objectPrototype); 339 d()->regExpPrototype = new (exec) RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype); 340 d()->errorPrototype = new (exec) ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype); 341 342 d()->evalErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError"); 343 d()->rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError"); 344 d()->referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError"); 345 d()->syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError"); 346 d()->typeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError"); 347 d()->URIErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError"); 334 348 335 349 // Constructors 336 d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype);337 d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype);338 d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype);339 d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype);340 d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype);341 d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype);342 d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype);343 d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype);344 d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype);345 346 d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype);347 d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype);348 d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype);349 d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype);350 d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype);351 d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype);350 d()->objectConstructor = new (exec) ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype); 351 d()->functionConstructor = new (exec) FunctionObjectImp(exec, d()->functionPrototype); 352 d()->arrayConstructor = new (exec) ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype); 353 d()->stringConstructor = new (exec) StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype); 354 d()->booleanConstructor = new (exec) BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype); 355 d()->numberConstructor = new (exec) NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype); 356 d()->dateConstructor = new (exec) DateObjectImp(exec, d()->functionPrototype, d()->datePrototype); 357 d()->regExpConstructor = new (exec) RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype); 358 d()->errorConstructor = new (exec) ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype); 359 360 d()->evalErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype); 361 d()->rangeErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype); 362 d()->referenceErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype); 363 d()->syntaxErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype); 364 d()->typeErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype); 365 d()->URIErrorConstructor = new (exec) NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype); 352 366 353 367 d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum); … … 391 405 // Set global values. 392 406 Identifier mathIdent = "Math"; 393 JSValue* mathObject = new MathObjectImp(exec, d()->objectPrototype);407 JSValue* mathObject = new (exec) MathObjectImp(exec, d()->objectPrototype); 394 408 symbolTableInsert(mathIdent, mathObject, DontEnum | DontDelete); 395 409 396 410 Identifier nanIdent = "NaN"; 397 JSValue* nanValue = jsNaN( );411 JSValue* nanValue = jsNaN(exec); 398 412 symbolTableInsert(nanIdent, nanValue, DontEnum | DontDelete); 399 413 400 414 Identifier infinityIdent = "Infinity"; 401 JSValue* infinityValue = jsNumber( Inf);415 JSValue* infinityValue = jsNumber(exec, Inf); 402 416 symbolTableInsert(infinityIdent, infinityValue, DontEnum | DontDelete); 403 417 … … 408 422 // Set global functions. 409 423 410 d()->evalFunction = new PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);424 d()->evalFunction = new (exec) PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this); 411 425 putDirectFunction(d()->evalFunction, DontEnum); 412 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum);413 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "parseFloat", globalFuncParseFloat), DontEnum);414 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isNaN", globalFuncIsNaN), DontEnum);415 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "isFinite", globalFuncIsFinite), DontEnum);416 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "escape", globalFuncEscape), DontEnum);417 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "unescape", globalFuncUnescape), DontEnum);418 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURI", globalFuncDecodeURI), DontEnum);419 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURIComponent", globalFuncDecodeURIComponent), DontEnum);420 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURI", globalFuncEncodeURI), DontEnum);421 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURIComponent", globalFuncEncodeURIComponent), DontEnum);426 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, "parseInt", globalFuncParseInt), DontEnum); 427 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "parseFloat", globalFuncParseFloat), DontEnum); 428 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "isNaN", globalFuncIsNaN), DontEnum); 429 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "isFinite", globalFuncIsFinite), DontEnum); 430 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "escape", globalFuncEscape), DontEnum); 431 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "unescape", globalFuncUnescape), DontEnum); 432 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURI", globalFuncDecodeURI), DontEnum); 433 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "decodeURIComponent", globalFuncDecodeURIComponent), DontEnum); 434 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURI", globalFuncEncodeURI), DontEnum); 435 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "encodeURIComponent", globalFuncEncodeURIComponent), DontEnum); 422 436 #ifndef NDEBUG 423 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, "kjsprint", globalFuncKJSPrint), DontEnum);437 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, "kjsprint", globalFuncKJSPrint), DontEnum); 424 438 #endif 425 439 … … 552 566 553 567 ASSERT(exec->codeType() == FunctionCode); 554 ActivationImp* newActivation = new ActivationImp(*oldActivation->d(), leaveRelic);568 ActivationImp* newActivation = new (exec) ActivationImp(*oldActivation->d(), leaveRelic); 555 569 556 570 if (!leaveRelic) { … … 572 586 } 573 587 588 void* JSGlobalObject::operator new(size_t size) 589 { 590 return Heap::threadHeap()->allocate(size); 591 } 574 592 575 593 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.