Changeset 29059 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Jan 1, 2008, 12:43:59 AM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Oliver.

Speeds SunSpider up 1.003x. That's a small amount, but measurable.

  • JavaScriptCore.exp: Updated.
  • kjs/Parser.h: (KJS::Parser::parse): Create the node with a static member function named create() instead of using new explicitly.
  • kjs/grammar.y: Changed calls to new FunctionBodyNode to use FunctionBodyNode::create().
  • kjs/nodes.cpp: (KJS::ProgramNode::create): Added. Calls new. (KJS::EvalNode::create): Ditto. (KJS::FunctionBodyNode::create): Ditto, but creates FunctionBodyNodeWithDebuggerHooks when a debugger is present. (KJS::FunctionBodyNode::execute): Removed debugger hooks. (KJS::FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks): Added. (KJS::FunctionBodyNodeWithDebuggerHooks::execute): Calls the debugger, then the code, then the debugger again.
  • kjs/nodes.h: Added create functions, made the constructors private and protected.
File:
1 edited

Legend:

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

    r29022 r29059  
    4444
    4545namespace KJS {
     46
     47    class FunctionBodyNodeWithDebuggerHooks : public FunctionBodyNode {
     48    public:
     49        FunctionBodyNodeWithDebuggerHooks(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
     50        virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
     51    };
    4652
    4753#define KJS_CHECKEXCEPTION \
     
    42264232}
    42274233
     4234ProgramNode* ProgramNode::create(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
     4235{
     4236    return new ProgramNode(children, varStack, funcStack);
     4237}
     4238
    42284239EvalNode::EvalNode(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
    42294240    : ScopeNode(children, varStack, funcStack)
    42304241{
     4242}
     4243
     4244EvalNode* EvalNode::create(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
     4245{
     4246    return new EvalNode(children, varStack, funcStack);
    42314247}
    42324248
     
    42354251    , m_initialized(false)
    42364252{
     4253}
     4254
     4255FunctionBodyNode* FunctionBodyNode::create(SourceElements* children, DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
     4256{
     4257    if (Debugger::debuggersPresent)
     4258        return new FunctionBodyNodeWithDebuggerHooks(children, varStack, funcStack);
     4259    return new FunctionBodyNode(children, varStack, funcStack);
    42374260}
    42384261
     
    44754498{
    44764499    processDeclarations(exec);
    4477 
     4500    return ScopeNode::execute(exec);
     4501}
     4502
     4503// ------------------------------ FunctionBodyNodeWithDebuggerHooks ---------------------------------
     4504
     4505FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks(SourceElements* children,
     4506        DeclarationStacks::VarStack* varStack, DeclarationStacks::FunctionStack* funcStack)
     4507    : FunctionBodyNode(children, varStack, funcStack)
     4508{
     4509}
     4510
     4511JSValue* FunctionBodyNodeWithDebuggerHooks::execute(ExecState* exec)
     4512{
    44784513    if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) {
    44794514        if (!dbg->callEvent(exec, sourceId(), lineNo(), exec->function(), *exec->arguments())) {
     
    44814516            return exec->setInterruptedCompletion();
    44824517        }
    4483     }   
    4484    
    4485     JSValue* result = ScopeNode::execute(exec);
    4486    
     4518    }
     4519
     4520    JSValue* result = FunctionBodyNode::execute(exec);
     4521
    44874522    if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) {
    44884523        if (exec->completionType() == Throw)
     
    44944529    }
    44954530
    4496    
    44974531    return result;
    44984532}
Note: See TracChangeset for help on using the changeset viewer.