Changeset 29059 in webkit


Ignore:
Timestamp:
Jan 1, 2008, 12:43:59 AM (18 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.
Location:
trunk/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r29047 r29059  
     12008-01-01  Darin Adler  <[email protected]>
     2
     3        Reviewed by Oliver.
     4
     5        - http://bugs.webkit.org/show_bug.cgi?id=16684
     6          eliminate debugger overhead from function body execution
     7
     8        Speeds SunSpider up 1.003x. That's a small amount, but measurable.
     9
     10        * JavaScriptCore.exp: Updated.
     11        * kjs/Parser.h:
     12        (KJS::Parser::parse): Create the node with a static member function named create() instead
     13        of using new explicitly.
     14
     15        * kjs/grammar.y: Changed calls to new FunctionBodyNode to use FunctionBodyNode::create().
     16
     17        * kjs/nodes.cpp:
     18        (KJS::ProgramNode::create): Added. Calls new.
     19        (KJS::EvalNode::create): Ditto.
     20        (KJS::FunctionBodyNode::create): Ditto, but creates FunctionBodyNodeWithDebuggerHooks
     21        when a debugger is present.
     22        (KJS::FunctionBodyNode::execute): Removed debugger hooks.
     23        (KJS::FunctionBodyNodeWithDebuggerHooks::FunctionBodyNodeWithDebuggerHooks): Added.
     24        (KJS::FunctionBodyNodeWithDebuggerHooks::execute): Calls the debugger, then the code,
     25        then the debugger again.
     26
     27        * kjs/nodes.h: Added create functions, made the constructors private and protected.
     28
    1292007-12-30  Eric Seidel  <[email protected]>
    230
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r28973 r29059  
    121121__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
    122122__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
    123 __ZN3KJS11ProgramNodeC1EPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
     123__ZN3KJS11ProgramNode6createEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS4_IPNS_12FuncDeclNodeELm16EEE
    124124__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE
    125125__ZN3KJS11PropertyMap5clearEv
  • trunk/JavaScriptCore/kjs/Parser.h

    r28937 r29059  
    8585            return 0;
    8686        }
    87         RefPtr<ParsedNode> node = new ParsedNode(m_sourceElements.release().get(),
    88                                                  m_varDeclarations ? &m_varDeclarations->data : 0,
    89                                                  m_funcDeclarations ? &m_funcDeclarations->data : 0);
     87        RefPtr<ParsedNode> node = ParsedNode::create(m_sourceElements.release().get(),
     88                                                     m_varDeclarations ? &m_varDeclarations->data : 0,
     89                                                     m_funcDeclarations ? &m_funcDeclarations->data : 0);
    9090        m_varDeclarations = 0;
    9191        m_funcDeclarations = 0;
  • trunk/JavaScriptCore/kjs/grammar.y

    r28975 r29059  
    10021002
    10031003FunctionBody:
    1004     /* not in spec */           { $$ = new FunctionBodyNode(0, 0, 0); }
    1005   | SourceElements              { $$ = new FunctionBodyNode($1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0,
    1006                                                             $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0);
     1004    /* not in spec */           { $$ = FunctionBodyNode::create(0, 0, 0); }
     1005  | SourceElements              { $$ = FunctionBodyNode::create($1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0,
     1006                                                                $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0);
    10071007                                  // As in mergeDeclarationLists() we have to ref/deref to safely get rid of
    10081008                                  // the declaration lists.
  • 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}
  • trunk/JavaScriptCore/kjs/nodes.h

    r29022 r29059  
    19691969  class ProgramNode : public ScopeNode {
    19701970  public:
    1971     ProgramNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
     1971    static ProgramNode* create(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19721972    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
    19731973   
    19741974  private:
     1975    ProgramNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19751976    void initializeSymbolTable(ExecState*) KJS_FAST_CALL;
    19761977    ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL;
     
    19821983  class EvalNode : public ScopeNode {
    19831984  public:
    1984     EvalNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
     1985    static EvalNode* create(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19851986    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
    19861987   
    19871988  private:
     1989    EvalNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19881990    ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL;
    19891991  };
     
    19911993  class FunctionBodyNode : public ScopeNode {
    19921994  public:
    1993     FunctionBodyNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
     1995    static FunctionBodyNode* create(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    19941996
    19951997    virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
     
    19992001    Vector<Identifier>& parameters() KJS_FAST_CALL { return m_parameters; }
    20002002    UString paramString() const KJS_FAST_CALL;
     2003
     2004  protected:
     2005    FunctionBodyNode(SourceElements*, DeclarationStacks::VarStack*, DeclarationStacks::FunctionStack*) KJS_FAST_CALL;
    20012006
    20022007  private:
Note: See TracChangeset for help on using the changeset viewer.