Changeset 47089 in webkit for trunk/JavaScriptCore/parser


Ignore:
Timestamp:
Aug 11, 2009, 10:22:33 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Restrict use of FuncDeclNode & FuncExprNode to the parser.
https://bugs.webkit.org/show_bug.cgi?id=28209

Reviewed by Oliver Hunt.

These objects were also being referenced from the CodeBlock. By changing this
to just retain pointers to FunctionBodyNodes these classes can be restricted to
use during parsing.

No performance impact (or sub-percent progression).

Update symbols.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::mark):
(JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addFunction):
(JSC::CodeBlock::function):

Unify m_functions & m_functionExpressions into a single Vector<RefPtr<FuncExprNode> >.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::addConstant):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitNewFunctionExpression):

  • bytecompiler/BytecodeGenerator.h:

FunctionStacks now contain FunctionBodyNodes not FuncDeclNodes.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):

Update to reflect chnages in CodeBlock.

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_new_func_exp):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jit/JITStubs.h:

(JSC::):

Update to reflect chnages in CodeBlock.

  • parser/Grammar.y:

FunctionStacks now contain FunctionBodyNodes not FuncDeclNodes.

  • parser/NodeConstructors.h:

(JSC::FuncExprNode::FuncExprNode):
(JSC::FuncDeclNode::FuncDeclNode):

  • parser/Nodes.cpp:

(JSC::ScopeNodeData::mark):
(JSC::FunctionBodyNode::finishParsing):

  • parser/Nodes.h:

(JSC::FunctionBodyNode::ident):

Move m_ident & make methods from FuncDeclNode & FuncExprNode to FunctionBodyNode.

  • runtime/JSFunction.h:

(JSC::FunctionBodyNode::make):

Make this method inline (was FuncDeclNode::makeFunction).

WebCore: Restrict use of FuncDeclNode & FuncExprNode to the parser.
https://bugs.webkit.org/show_bug.cgi?id=28209

Reviewed by Oliver Hunt.

  • inspector/JavaScriptDebugServer.cpp:

(WebCore::JavaScriptDebugServer::recompileAllJSFunctions):

Function signature change.

Location:
trunk/JavaScriptCore/parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Grammar.y

    r45943 r47089  
    11681168
    11691169FunctionDeclaration:
    1170     FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), 0, new (GLOBAL_DATA) ParserArenaData<DeclarationStacks::FunctionStack>, ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)); }
     1170    FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), 0, new (GLOBAL_DATA) ParserArenaData<DeclarationStacks::FunctionStack>, ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)->body()); }
    11711171  | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
    11721172      {
     
    11751175              $7->setUsesArguments();
    11761176          DBG($7, @6, @8);
    1177           $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node));
     1177          $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)->body());
    11781178      }
    11791179;
  • trunk/JavaScriptCore/parser/NodeConstructors.h

    r45730 r47089  
    815815    inline FuncExprNode::FuncExprNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
    816816        : ExpressionNode(globalData)
    817         , ParserArenaRefCounted(globalData)
    818         , m_ident(ident)
    819817        , m_body(body)
    820818    {
    821         m_body->finishParsing(source, parameter);
     819        m_body->finishParsing(source, parameter, ident);
    822820    }
    823821
    824822    inline FuncDeclNode::FuncDeclNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
    825823        : StatementNode(globalData)
    826         , ParserArenaRefCounted(globalData)
    827         , m_ident(ident)
    828824        , m_body(body)
    829825    {
    830         m_body->finishParsing(source, parameter);
     826        m_body->finishParsing(source, parameter, ident);
    831827    }
    832828
  • trunk/JavaScriptCore/parser/Nodes.cpp

    r47062 r47089  
    18291829    FunctionStack::iterator end = m_functionStack.end();
    18301830    for (FunctionStack::iterator ptr = m_functionStack.begin(); ptr != end; ++ptr) {
    1831         FunctionBodyNode* body = (*ptr)->body();
     1831        FunctionBodyNode* body = *ptr;
    18321832        if (!body->isGenerated())
    18331833            continue;
     
    20192019}
    20202020
    2021 void FunctionBodyNode::finishParsing(const SourceCode& source, ParameterNode* firstParameter)
     2021void FunctionBodyNode::finishParsing(const SourceCode& source, ParameterNode* firstParameter, const Identifier& ident)
    20222022{
    20232023    Vector<Identifier> parameters;
     
    20272027
    20282028    setSource(source);
    2029     finishParsing(parameters.releaseBuffer(), count);
    2030 }
    2031 
    2032 void FunctionBodyNode::finishParsing(Identifier* parameters, size_t parameterCount)
     2029    finishParsing(parameters.releaseBuffer(), count, ident);
     2030}
     2031
     2032void FunctionBodyNode::finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident)
    20332033{
    20342034    ASSERT(!source().isNull());
    20352035    m_parameters = parameters;
    20362036    m_parameterCount = parameterCount;
     2037    m_ident = ident;
    20372038}
    20382039
     
    21582159// ------------------------------ FuncDeclNode ---------------------------------
    21592160
    2160 JSFunction* FuncDeclNode::makeFunction(ExecState* exec, ScopeChainNode* scopeChain)
    2161 {
    2162     return new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
    2163 }
    2164 
    21652161RegisterID* FuncDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    21662162{
     
    21772173}
    21782174
    2179 JSFunction* FuncExprNode::makeFunction(ExecState* exec, ScopeChainNode* scopeChain)
    2180 {
    2181     JSFunction* func = new (exec) JSFunction(exec, m_ident, m_body.get(), scopeChain);
    2182 
    2183     /*
    2184         The Identifier in a FunctionExpression can be referenced from inside
    2185         the FunctionExpression's FunctionBody to allow the function to call
    2186         itself recursively. However, unlike in a FunctionDeclaration, the
    2187         Identifier in a FunctionExpression cannot be referenced from and
    2188         does not affect the scope enclosing the FunctionExpression.
    2189      */
    2190 
    2191     if (!m_ident.isNull()) {
    2192         JSStaticScopeObject* functionScopeObject = new (exec) JSStaticScopeObject(exec, m_ident, func, ReadOnly | DontDelete);
    2193         func->scope().push(functionScopeObject);
    2194     }
    2195 
    2196     return func;
    2197 }
    2198 
    21992175} // namespace JSC
  • trunk/JavaScriptCore/parser/Nodes.h

    r47022 r47089  
    8888        enum VarAttrs { IsConstant = 1, HasInitializer = 2 };
    8989        typedef Vector<std::pair<Identifier, unsigned> > VarStack;
    90         typedef Vector<FuncDeclNode*> FunctionStack;
     90        typedef Vector<FunctionBodyNode*> FunctionStack;
    9191    }
    9292
     
    15661566        virtual void markAggregate(MarkStack&);
    15671567
    1568         void finishParsing(const SourceCode&, ParameterNode*);
    1569         void finishParsing(Identifier* parameters, size_t parameterCount);
     1568        void finishParsing(const SourceCode&, ParameterNode*, const Identifier& ident);
     1569        void finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident);
    15701570       
    15711571        UString toSourceString() const { return source().toString(); }
     
    15941594            return *m_code;
    15951595        }
    1596        
     1596
     1597        const Identifier& ident() { return m_ident; }
     1598
     1599        JSFunction* make(ExecState*, ScopeChainNode*);
     1600
    15971601    private:
    15981602        FunctionBodyNode(JSGlobalData*);
     
    16031607        void generateJITCode(ScopeChainNode*);
    16041608#endif
     1609        Identifier m_ident;
    16051610        Identifier* m_parameters;
    16061611        size_t m_parameterCount;
     
    16081613    };
    16091614
    1610     class FuncExprNode : public ExpressionNode, public ParserArenaRefCounted {
     1615    class FuncExprNode : public ExpressionNode {
    16111616    public:
    16121617        FuncExprNode(JSGlobalData*, const Identifier&, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0);
    16131618
    1614         JSFunction* makeFunction(ExecState*, ScopeChainNode*);
    1615 
    16161619        FunctionBodyNode* body() { return m_body.get(); }
    16171620
     
    16211624        virtual bool isFuncExprNode() const { return true; }
    16221625
    1623         Identifier m_ident;
    16241626        RefPtr<FunctionBodyNode> m_body;
    16251627    };
    16261628
    1627     class FuncDeclNode : public StatementNode, public ParserArenaRefCounted {
     1629    class FuncDeclNode : public StatementNode {
    16281630    public:
    16291631        FuncDeclNode(JSGlobalData*, const Identifier&, FunctionBodyNode*, const SourceCode&, ParameterNode* = 0);
    1630 
    1631         JSFunction* makeFunction(ExecState*, ScopeChainNode*);
    1632 
    1633         Identifier m_ident;
    16341632
    16351633        FunctionBodyNode* body() { return m_body.get(); }
Note: See TracChangeset for help on using the changeset viewer.