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/bytecompiler/BytecodeGenerator.cpp

    r47062 r47089  
    257257
    258258        for (size_t i = 0; i < functionStack.size(); ++i) {
    259             FuncDeclNode* funcDecl = functionStack[i];
    260             globalObject->removeDirect(funcDecl->m_ident); // Make sure our new function is not shadowed by an old property.
    261             emitNewFunction(addGlobalVar(funcDecl->m_ident, false), funcDecl);
     259            FunctionBodyNode* function = functionStack[i];
     260            globalObject->removeDirect(function->ident()); // Make sure our new function is not shadowed by an old property.
     261            emitNewFunction(addGlobalVar(function->ident(), false), function);
    262262        }
    263263
     
    273273    } else {
    274274        for (size_t i = 0; i < functionStack.size(); ++i) {
    275             FuncDeclNode* funcDecl = functionStack[i];
    276             globalObject->putWithAttributes(exec, funcDecl->m_ident, funcDecl->makeFunction(exec, scopeChain.node()), DontDelete);
     275            FunctionBodyNode* function = functionStack[i];
     276            globalObject->putWithAttributes(exec, function->ident(), function->make(exec, scopeChain.node()), DontDelete);
    277277        }
    278278        for (size_t i = 0; i < varStack.size(); ++i) {
     
    340340    const DeclarationStacks::FunctionStack& functionStack = functionBody->functionStack();
    341341    for (size_t i = 0; i < functionStack.size(); ++i) {
    342         FuncDeclNode* funcDecl = functionStack[i];
    343         const Identifier& ident = funcDecl->m_ident;
     342        FunctionBodyNode* function = functionStack[i];
     343        const Identifier& ident = function->ident();
    344344        m_functions.add(ident.ustring().rep());
    345         emitNewFunction(addVar(ident, false), funcDecl);
     345        emitNewFunction(addVar(ident, false), function);
    346346    }
    347347
     
    767767}
    768768
    769 unsigned BytecodeGenerator::addConstant(FuncDeclNode* n)
     769unsigned BytecodeGenerator::addConstant(FunctionBodyNode* n)
    770770{
    771771    // No need to explicitly unique function body nodes -- they're unique already.
    772772    return m_codeBlock->addFunction(n);
    773 }
    774 
    775 unsigned BytecodeGenerator::addConstant(FuncExprNode* n)
    776 {
    777     // No need to explicitly unique function expression nodes -- they're unique already.
    778     return m_codeBlock->addFunctionExpression(n);
    779773}
    780774
     
    13151309}
    13161310
    1317 RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FuncDeclNode* n)
     1311RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* body)
    13181312{
    13191313    emitOpcode(op_new_func);
    13201314    instructions().append(dst->index());
    1321     instructions().append(addConstant(n));
     1315    instructions().append(addConstant(body));
    13221316    return dst;
    13231317}
     
    13361330    emitOpcode(op_new_func_exp);
    13371331    instructions().append(r0->index());
    1338     instructions().append(addConstant(n));
     1332    instructions().append(addConstant(n->body()));
    13391333    return r0;
    13401334}
Note: See TracChangeset for help on using the changeset viewer.