Ignore:
Timestamp:
Sep 7, 2012, 4:59:10 PM (13 years ago)
Author:
[email protected]
Message:

Refactored bytecode generator initialization to support moving captured vars around
https://bugs.webkit.org/show_bug.cgi?id=96159

Reviewed by Gavin Barraclough.

This patch separates the stages of allocating registers, declaring identifiers
in the symbol table, and initializing registers, so you can change
allocation decisions without breaking the world.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator): Call a set of helper functions
instead of inlining all the code, to help clarity.

(JSC::BytecodeGenerator::allocateCapturedVars):
(JSC::BytecodeGenerator::allocateUncapturedVars):
(JSC::BytecodeGenerator::allocateActivationVar):
(JSC::BytecodeGenerator::allocateArgumentsVars):
(JSC::BytecodeGenerator::allocateCalleeVarUndeclared):
(JSC::BytecodeGenerator::declareParameters):
(JSC::BytecodeGenerator::declareCallee):
(JSC::BytecodeGenerator::initCalleeVar):
(JSC::BytecodeGenerator::initArgumentsVars):
(JSC::BytecodeGenerator::initActivationVar):
(JSC::BytecodeGenerator::initThisParameter):
(JSC::BytecodeGenerator::initFunctionDeclarations):
(JSC::BytecodeGenerator::declareParameter):
(JSC::BytecodeGenerator::createLazyRegisterIfNecessary):
(JSC::BytecodeGenerator::createActivationIfNecessary): Factored these
helper functions out from pre-existing code.

  • bytecompiler/BytecodeGenerator.h:

(BytecodeGenerator):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFuncDeclStatement):
(JSC::ASTBuilder::addVar):

  • parser/Nodes.h:

(JSC::DeclarationStacks::VarDeclaration::VarDeclaration):
(VarDeclaration):
(JSC::DeclarationStacks::FunctionDeclaration::FunctionDeclaration):
(FunctionDeclaration): Declaration stacks get a little more data now,
to support allocating registers before putting things in the symbol
table. I'm convinced that we should eventually just expand the symbol
table to understand these things.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r127810 r127939  
    8686
    8787    namespace DeclarationStacks {
     88        struct VarDeclaration {
     89            VarDeclaration(const Identifier* name, unsigned attributes)
     90                : name(name)
     91                , attributes(attributes)
     92                , reg(0)
     93            {
     94            }
     95            const Identifier* name;
     96            unsigned attributes;
     97            RegisterID* reg;
     98        };
     99        struct FunctionDeclaration {
     100            explicit FunctionDeclaration(FunctionBodyNode* node)
     101                : node(node)
     102                , reg(0)
     103            {
     104            }
     105            FunctionBodyNode* node;
     106            RegisterID* reg;
     107        };
    88108        enum VarAttrs { IsConstant = 1, HasInitializer = 2 };
    89         typedef Vector<std::pair<const Identifier*, unsigned> > VarStack;
    90         typedef Vector<FunctionBodyNode*> FunctionStack;
     109        typedef Vector<VarDeclaration> VarStack;
     110        typedef Vector<FunctionDeclaration> FunctionStack;
    91111    }
    92112
Note: See TracChangeset for help on using the changeset viewer.