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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.