Ignore:
Timestamp:
May 21, 2008, 6:20:45 PM (17 years ago)
Author:
[email protected]
Message:

Merge squirrelfish branch into trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r33038 r33979  
    3131#include "JSGlobalObject.h"
    3232
    33 #include "Activation.h"
     33#include "CodeBlock.h"
    3434#include "array_object.h"
    3535#include "bool_object.h"
     
    105105JSGlobalObject* JSGlobalObject::s_head = 0;
    106106
    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 
    116107JSGlobalObject::~JSGlobalObject()
    117108{
     
    126117    if (s_head == this)
    127118        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;
    130123   
    131124    delete d();
     
    206199    d()->debugger = 0;
    207200   
    208     ActivationStackNode* newStackNode = new ActivationStackNode;
    209     newStackNode->prev = 0;   
    210     d()->activations = newStackNode;
    211     d()->activationCount = 0;
    212 
    213201    d()->perThreadData.arrayTable = &threadClassInfoHashTables()->arrayTable;
    214202    d()->perThreadData.dateTable = &threadClassInfoHashTables()->dateTable;
     
    220208    d()->perThreadData.propertyNames = CommonIdentifiers::shared();
    221209
    222     d()->globalExec.set(new GlobalExecState(this, thisValue));
     210    d()->globalExec.set(new ExecState(this, thisValue, d()->globalScopeChain.node()));
    223211
    224212    d()->pageGroupIdentifier = 0;
    225213
    226214    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);
    234215}
    235216
     
    269250
    270251    _prop.clear();
    271     localStorage().clear();
     252    registerFileStack().current()->clear();
     253    registerFileStack().current()->addGlobalSlots(1);
    272254    symbolTable().clear();
    273255
     
    390372
    391373    // 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));
    407382
    408383    // Set global functions.
     
    493468{
    494469    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();
    499476
    500477    markIfNeeded(d()->globalExec->exception());
     
    545522}
    546523
    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 
    569524bool JSGlobalObject::isDynamicScope() const
    570525{
Note: See TracChangeset for help on using the changeset viewer.