Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r33038 r33979 31 31 #include "JSGlobalObject.h" 32 32 33 #include " Activation.h"33 #include "CodeBlock.h" 34 34 #include "array_object.h" 35 35 #include "bool_object.h" … … 105 105 JSGlobalObject* JSGlobalObject::s_head = 0; 106 106 107 void JSGlobalObject::deleteActivationStack()108 {109 ActivationStackNode* prevNode = 0;110 for (ActivationStackNode* currentNode = d()->activations; currentNode; currentNode = prevNode) {111 prevNode = currentNode->prev;112 delete currentNode;113 }114 }115 116 107 JSGlobalObject::~JSGlobalObject() 117 108 { … … 126 117 if (s_head == this) 127 118 s_head = 0; 128 129 deleteActivationStack(); 119 120 HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end(); 121 for (HashSet<ProgramCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it) 122 (*it)->globalObject = 0; 130 123 131 124 delete d(); … … 206 199 d()->debugger = 0; 207 200 208 ActivationStackNode* newStackNode = new ActivationStackNode;209 newStackNode->prev = 0;210 d()->activations = newStackNode;211 d()->activationCount = 0;212 213 201 d()->perThreadData.arrayTable = &threadClassInfoHashTables()->arrayTable; 214 202 d()->perThreadData.dateTable = &threadClassInfoHashTables()->dateTable; … … 220 208 d()->perThreadData.propertyNames = CommonIdentifiers::shared(); 221 209 222 d()->globalExec.set(new GlobalExecState(this, thisValue));210 d()->globalExec.set(new ExecState(this, thisValue, d()->globalScopeChain.node())); 223 211 224 212 d()->pageGroupIdentifier = 0; 225 213 226 214 reset(prototype()); 227 }228 229 bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)230 {231 if (symbolTableGet(propertyName, slot))232 return true;233 return JSVariableObject::getOwnPropertySlot(exec, propertyName, slot);234 215 } 235 216 … … 269 250 270 251 _prop.clear(); 271 localStorage().clear(); 252 registerFileStack().current()->clear(); 253 registerFileStack().current()->addGlobalSlots(1); 272 254 symbolTable().clear(); 273 255 … … 390 372 391 373 // Set global values. 392 Identifier mathIdent = "Math"; 393 JSValue* mathObject = new MathObjectImp(exec, d()->objectPrototype); 394 symbolTableInsert(mathIdent, mathObject, DontEnum | DontDelete); 395 396 Identifier nanIdent = "NaN"; 397 JSValue* nanValue = jsNaN(); 398 symbolTableInsert(nanIdent, nanValue, DontEnum | DontDelete); 399 400 Identifier infinityIdent = "Infinity"; 401 JSValue* infinityValue = jsNumber(Inf); 402 symbolTableInsert(infinityIdent, infinityValue, DontEnum | DontDelete); 403 404 Identifier undefinedIdent = "undefined"; 405 JSValue* undefinedValue = jsUndefined(); 406 symbolTableInsert(undefinedIdent, undefinedValue, DontEnum | DontDelete); 374 GlobalPropertyInfo staticGlobals[] = { 375 GlobalPropertyInfo("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum | DontDelete), 376 GlobalPropertyInfo("NaN", jsNaN(), DontEnum | DontDelete), 377 GlobalPropertyInfo("Infinity", jsNumber(Inf), DontEnum | DontDelete), 378 GlobalPropertyInfo("undefined", jsUndefined(), DontEnum | DontDelete) 379 }; 380 381 addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo)); 407 382 408 383 // Set global functions. … … 493 468 { 494 469 JSVariableObject::mark(); 495 496 ExecStateStack::const_iterator end = d()->activeExecStates.end(); 497 for (ExecStateStack::const_iterator it = d()->activeExecStates.begin(); it != end; ++it) 498 (*it)->m_scopeChain.mark(); 470 471 HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end(); 472 for (HashSet<ProgramCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it) 473 (*it)->mark(); 474 475 registerFileStack().mark(); 499 476 500 477 markIfNeeded(d()->globalExec->exception()); … … 545 522 } 546 523 547 void JSGlobalObject::tearOffActivation(ExecState* exec, bool leaveRelic)548 {549 ActivationImp* oldActivation = exec->activationObject();550 if (!oldActivation || !oldActivation->isOnStack())551 return;552 553 ASSERT(exec->codeType() == FunctionCode);554 ActivationImp* newActivation = new ActivationImp(*oldActivation->d(), leaveRelic);555 556 if (!leaveRelic) {557 checkActivationCount();558 d()->activationCount--;559 }560 561 oldActivation->d()->localStorage.shrink(0);562 563 exec->setActivationObject(newActivation);564 exec->setVariableObject(newActivation);565 exec->setLocalStorage(&newActivation->localStorage());566 exec->replaceScopeChainTop(newActivation);567 }568 569 524 bool JSGlobalObject::isDynamicScope() const 570 525 {
Note:
See TracChangeset
for help on using the changeset viewer.