Changeset 34319 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
Jun 2, 2008, 1:45:13 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-02 Geoffrey Garen <[email protected]>

Reviewed by Darin Adler.


A little cleanup in the CodeGenerator.

  • VM/CodeGenerator.cpp: A few changes here.

(1) Removed remaining cases of the old hack of putting "this" into the
symbol table; replaced with explicit tracking of m_thisRegister.

(2) Made m_thisRegister behave the same for function, eval, and program
code, removing the static programCodeThis() function.

(3) Added a feature to nix a ScopeNode's declaration stacks when done
compiling, to save memory.

(4) Removed code that copied eval declarations into special vectors: we
just use the originals in the ScopeNode now.


  • VM/CodeGenerator.h: Removed unneded parameters from the CodeGenerator constructor: we just use get that data from the ScopeNode now.
  • VM/Machine.cpp: (KJS::Machine::execute): When executing an eval node, don't iterate a special copy of its declarations; iterate the originals, instead.
  • kjs/nodes.cpp: Moved responsibility for knowing what AST data to throw away into the CodeGenerator. Nodes no longer call shrinkCapacity on their data directly.


  • kjs/nodes.h: Changed FunctionStack to ref its contents, so declaration data stays around even after we've thrown away the AST, unless we explicitly throw away the declaration data, too. This is useful for eval code, which needs to reference its declaration data at execution time. (Soon, it will be useful for program code, too, since program code should do the same.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Machine.cpp

    r34303 r34319  
    763763    }
    764764   
    765     for (Vector<Identifier>::const_iterator iter = codeBlock->declaredVariableNames.begin(); iter != codeBlock->declaredVariableNames.end(); ++iter) {
    766         Identifier ident = *iter;
    767        
     765    const Node::VarStack& varStack = codeBlock->ownerNode->varStack();
     766    Node::VarStack::const_iterator varStackEnd = varStack.end();
     767    for (Node::VarStack::const_iterator it = varStack.begin(); it != varStackEnd; ++it) {
     768        const Identifier& ident = (*it).first;
    768769        if (!variableObject->hasProperty(exec, ident))
    769770            variableObject->put(exec, ident, jsUndefined());
    770771    }
    771772   
    772     ASSERT(codeBlock->functions.size() == codeBlock->declaredFunctionNames.size());
    773     for (size_t i = 0; i < codeBlock->functions.size(); ++i)
    774         variableObject->put(exec, codeBlock->declaredFunctionNames[i], codeBlock->functions[i]->makeFunction(exec, scopeChain));
     773    const Node::FunctionStack& functionStack = codeBlock->ownerNode->functionStack();
     774    Node::FunctionStack::const_iterator functionStackEnd = functionStack.end();
     775    for (Node::FunctionStack::const_iterator it = functionStack.begin(); it != functionStackEnd; ++it)
     776        variableObject->put(exec, (*it)->m_ident, (*it)->makeFunction(exec, scopeChain));
    775777   
    776778    size_t oldSize = registerFile->size();
Note: See TracChangeset for help on using the changeset viewer.