Changeset 34319 in webkit for trunk/JavaScriptCore/kjs


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.)
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

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

    r34303 r34319  
    58515851    m_code.set(new EvalCodeBlock(this, globalObject));
    58525852
    5853     CodeGenerator generator(this, globalObject->debugger(), scopeChain, &symbolTable, m_code.get(), m_varStack, m_functionStack);
     5853    CodeGenerator generator(this, globalObject->debugger(), scopeChain, &symbolTable, m_code.get());
    58545854    generator.generate();
    5855 
    5856     m_children.shrinkCapacity(0);
    58575855}
    58585856
     
    58915889    m_code.set(new CodeBlock(this));
    58925890
    5893     CodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_symbolTable, m_code.get(), m_varStack, m_functionStack, m_parameters);
     5891    CodeGenerator generator(this, globalObject->debugger(), scopeChain, &m_symbolTable, m_code.get());
    58945892    generator.generate();
    5895 
    5896     m_children.shrinkCapacity(0);
    58975893}
    58985894
     
    59315927    CodeGenerator generator(this, globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_code.get(), m_varStack, m_functionStack, canCreateGlobals);
    59325928    generator.generate();
    5933 
    5934     m_children.shrinkCapacity(0);
    59355929}
    59365930
     
    60316025
    60326026    for (size_t i = 0, size = m_functionStack.size(); i < size; ++i) {
    6033         FuncDeclNode* node = m_functionStack[i];
     6027        FuncDeclNode* node = m_functionStack[i].get();
    60346028        LocalStorageEntry entry = LocalStorageEntry(node->makeFunction(exec, exec->scopeChain().node()), minAttributes);
    60356029        size_t index = m_functionIndexes[i];
     
    60816075
    60826076    for (i = 0, size = m_functionStack.size(); i < size; ++i) {
    6083         FuncDeclNode* funcDecl = m_functionStack[i];
     6077        FuncDeclNode* funcDecl = m_functionStack[i].get();
    60846078        variableObject->putWithAttributes(exec, funcDecl->m_ident, funcDecl->makeFunction(exec, exec->scopeChain().node()), 0);
    60856079    }
  • trunk/JavaScriptCore/kjs/nodes.h

    r33979 r34319  
    100100        enum { IsConstant = 1, HasInitializer = 2 } VarAttrs;
    101101        typedef Vector<std::pair<Identifier, unsigned>, 16> VarStack;
    102         typedef Vector<FuncDeclNode*, 16> FunctionStack;
     102        typedef Vector<RefPtr<FuncDeclNode>, 16> FunctionStack;
    103103
    104104        DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f)
     
    26212621        virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    26222622
     2623        StatementVector& children() { return m_children; }
     2624
    26232625    protected:
    26242626        StatementVector m_children;
     
    29592961        bool usesEval() const { return m_usesEval; }
    29602962        bool needsClosure() const { return m_needsClosure; }
    2961 
     2963       
     2964        VarStack& varStack() { return m_varStack; }
     2965        FunctionStack& functionStack() { return m_functionStack; }
     2966       
    29622967    protected:
    29632968        void optimizeVariableAccess(OldInterpreterExecState*) KJS_FAST_CALL;
Note: See TracChangeset for help on using the changeset viewer.