Changeset 34659 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
- Timestamp:
- Jun 19, 2008, 10:29:29 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r34607 r34659 90 90 } 91 91 92 JSGlobalObject* JSGlobalObject::s_head = 0;93 94 92 JSGlobalObject::~JSGlobalObject() 95 93 { 96 ASSERT(JSLock::currentThreadIsHoldingLock());97 98 94 if (d()->debugger) 99 95 d()->debugger->detach(this); … … 101 97 d()->next->d()->prev = d()->prev; 102 98 d()->prev->d()->next = d()->next; 103 s_head = d()->next; 104 if (s_head == this) 105 s_head = 0; 99 JSGlobalObject*& headObject = head(); 100 if (headObject == this) 101 headObject = d()->next; 102 if (headObject == this) 103 headObject = 0; 106 104 107 105 HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end(); … … 116 114 ASSERT(JSLock::currentThreadIsHoldingLock()); 117 115 118 if ( s_head) {119 d()->prev = s_head;120 d()->next = s_head->d()->next;121 s_head->d()->next->d()->prev = this;122 s_head->d()->next = this;116 if (JSGlobalObject*& headObject = head()) { 117 d()->prev = headObject; 118 d()->next = headObject->d()->next; 119 headObject->d()->next->d()->prev = this; 120 headObject->d()->next = this; 123 121 } else 124 s_head= d()->next = d()->prev = this;122 headObject = d()->next = d()->prev = this; 125 123 126 124 resetTimeoutCheck(); … … 142 140 void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value) 143 141 { 142 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); 143 144 144 if (symbolTablePut(propertyName, value)) 145 145 return; … … 235 235 236 236 // Prototypes 237 d()->functionPrototype = new FunctionPrototype(exec);238 d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype);237 d()->functionPrototype = new (exec) FunctionPrototype(exec); 238 d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype); 239 239 d()->functionPrototype->setPrototype(d()->objectPrototype); 240 240 241 d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype);242 d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype);243 d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);244 d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);245 d()->datePrototype = new DatePrototype(exec, d()->objectPrototype);246 d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);247 d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);248 249 d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError");250 d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError");251 d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError");252 d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError");253 d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError");254 d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError");241 d()->arrayPrototype = new (exec) ArrayPrototype(exec, d()->objectPrototype); 242 d()->stringPrototype = new (exec) StringPrototype(exec, d()->objectPrototype); 243 d()->booleanPrototype = new (exec) BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype); 244 d()->numberPrototype = new (exec) NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype); 245 d()->datePrototype = new (exec) DatePrototype(exec, d()->objectPrototype); 246 d()->regExpPrototype = new (exec) RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype); 247 d()->errorPrototype = new (exec) ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype); 248 249 d()->evalErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError"); 250 d()->rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError"); 251 d()->referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError"); 252 d()->syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError"); 253 d()->typeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError"); 254 d()->URIErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError"); 255 255 256 256 // Constructors 257 d()->objectConstructor = new ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);258 d()->functionConstructor = new FunctionConstructor(exec, d()->functionPrototype);259 d()->arrayConstructor = new ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);260 d()->stringConstructor = new StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);261 d()->booleanConstructor = new BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);262 d()->numberConstructor = new NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);263 d()->dateConstructor = new DateConstructor(exec, d()->functionPrototype, d()->datePrototype);264 d()->regExpConstructor = new RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype);265 d()->errorConstructor = new ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype);266 267 d()->evalErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->evalErrorPrototype);268 d()->rangeErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->rangeErrorPrototype);269 d()->referenceErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->referenceErrorPrototype);270 d()->syntaxErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->syntaxErrorPrototype);271 d()->typeErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->typeErrorPrototype);272 d()->URIErrorConstructor = new NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype);257 d()->objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype); 258 d()->functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype); 259 d()->arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype); 260 d()->stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype); 261 d()->booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype); 262 d()->numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype); 263 d()->dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype); 264 d()->regExpConstructor = new (exec) RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype); 265 d()->errorConstructor = new (exec) ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype); 266 267 d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->evalErrorPrototype); 268 d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->rangeErrorPrototype); 269 d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->referenceErrorPrototype); 270 d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->syntaxErrorPrototype); 271 d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->typeErrorPrototype); 272 d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype); 273 273 274 274 d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum); … … 312 312 // Set global values. 313 313 GlobalPropertyInfo staticGlobals[] = { 314 GlobalPropertyInfo(Identifier(exec, "Math"), new MathObject(exec, d()->objectPrototype), DontEnum | DontDelete),315 GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN( ), DontEnum | DontDelete),316 GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber( Inf), DontEnum | DontDelete),314 GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, d()->objectPrototype), DontEnum | DontDelete), 315 GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete), 316 GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete), 317 317 GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete) 318 318 }; … … 322 322 // Set global functions. 323 323 324 d()->evalFunction = new PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);324 d()->evalFunction = new (exec) PrototypeReflexiveFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this); 325 325 putDirectFunction(d()->evalFunction, DontEnum); 326 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);327 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);328 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);329 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);330 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);331 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);332 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);333 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);334 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);335 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);326 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum); 327 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum); 328 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum); 329 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum); 330 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum); 331 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum); 332 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum); 333 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum); 334 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum); 335 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum); 336 336 #ifndef NDEBUG 337 putDirectFunction(new PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);337 putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum); 338 338 #endif 339 339 … … 412 412 (*it)->mark(); 413 413 414 registerFileStack().mark( );414 registerFileStack().mark(globalData()->heap); 415 415 416 416 markIfNeeded(d()->globalExec->exception()); … … 466 466 } 467 467 468 void* JSGlobalObject::operator new(size_t size) 469 { 470 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 471 return JSGlobalData::threadInstance().heap->inlineAllocate(size); 472 #else 473 return JSGlobalData::threadInstance().heap->allocate(size); 474 #endif 475 } 476 477 void* JSGlobalObject::operator new(size_t size, SharedTag) 478 { 479 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 480 return JSGlobalData::sharedInstance().heap->inlineAllocate(size); 481 #else 482 return JSGlobalData::sharedInstance().heap->allocate(size); 483 #endif 484 } 468 485 469 486 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.