Changeset 26811 in webkit


Ignore:
Timestamp:
Oct 20, 2007, 12:11:53 AM (18 years ago)
Author:
ggaren
Message:

Reviewed by Maciej Stachowiak.

Fixed http://bugs.webkit.org/show_bug.cgi?id=15570
Store gathered declaration nodes in the function body node.


This means that you only have to gather the declaration nodes the first
time the function executes. Performance gain of 2.10% on SunSpider,
0.90% on command-line JS iBench.

  • kjs/nodes.cpp: Split declaration stack initialization code off into initializeDeclarationStacks(). (FunctionBodyNode::FunctionBodyNode): (FunctionBodyNode::initializeDeclarationStacks): (FunctionBodyNode::processDeclarations):
  • kjs/nodes.h: Changed DeclarationStacks structure to hold references, since the actual Vectors are now stored either on the stack or in the function body node.
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26809 r26811  
     12007-10-20  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Fixed http://bugs.webkit.org/show_bug.cgi?id=15570
     6        Store gathered declaration nodes in the function body node.
     7       
     8        This means that you only have to gather the declaration nodes the first
     9        time the function executes. Performance gain of 2.10% on SunSpider,
     10        0.90% on command-line JS iBench.
     11
     12        * kjs/nodes.cpp: Split declaration stack initialization code off into
     13        initializeDeclarationStacks().
     14        (FunctionBodyNode::FunctionBodyNode):
     15        (FunctionBodyNode::initializeDeclarationStacks):
     16        (FunctionBodyNode::processDeclarations):
     17
     18        * kjs/nodes.h: Changed DeclarationStacks structure to hold references,
     19        since the actual Vectors are now stored either on the stack or in the
     20        function body node.
     21
    1222007-10-19  Geoffrey Garen  <[email protected]>
    223
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r26808 r26811  
    24232423    , m_sourceURL(Lexer::curr()->sourceURL())
    24242424    , m_sourceId(Parser::sid)
    2425 {
    2426 
     2425    , m_initializedDeclarationStacks(false)
     2426{
    24272427  setLoc(-1, -1);
    24282428}
    24292429
    2430 void FunctionBodyNode::processDeclarations(ExecState* exec)
     2430void FunctionBodyNode::initializeDeclarationStacks()
    24312431{
    24322432    Node* node = source.get();
     
    24342434        return;
    24352435
    2436     DeclarationStacks stacks;
    2437     DeclarationStacks::NodeStack& nodeStack = stacks.nodeStack;
     2436    DeclarationStacks::NodeStack nodeStack;
     2437    DeclarationStacks stacks(nodeStack, m_varStack, m_functionStack);
    24382438   
    24392439    while (true) {
     
    24482448        nodeStack.shrink(size);
    24492449    }
    2450    
     2450
     2451    m_initializedDeclarationStacks = true;
     2452}
     2453
     2454void FunctionBodyNode::processDeclarations(ExecState* exec)
     2455{
     2456    if (!m_initializedDeclarationStacks)
     2457        initializeDeclarationStacks();
     2458
    24512459    size_t i, size;
    24522460
    2453     DeclarationStacks::FunctionStack& functionStack = stacks.functionStack;
    2454     for (i = 0, size = functionStack.size(); i < size; ++i)
    2455         functionStack[i]->processDeclaration(exec);
    2456 
    2457     DeclarationStacks::VarStack& varStack = stacks.varStack;
    2458     for (i = 0, size = varStack.size(); i < size; ++i)
    2459         varStack[i]->processDeclaration(exec);
     2461    for (i = 0, size = m_functionStack.size(); i < size; ++i)
     2462        m_functionStack[i]->processDeclaration(exec);
     2463
     2464    for (i = 0, size = m_varStack.size(); i < size; ++i)
     2465        m_varStack[i]->processDeclaration(exec);
    24602466}
    24612467
  • trunk/JavaScriptCore/kjs/nodes.h

    r26808 r26811  
    9090      typedef Vector<FuncDeclNode*, 16> FunctionStack;
    9191     
    92       NodeStack nodeStack;
    93       VarStack varStack;
    94       FunctionStack functionStack;
     92      DeclarationStacks(NodeStack& n, VarStack& v, FunctionStack& f)
     93        : nodeStack(n)
     94        , varStack(v)
     95        , functionStack(f)
     96      {
     97      }
     98       
     99      NodeStack& nodeStack;
     100      VarStack& varStack;
     101      FunctionStack& functionStack;
    95102  };
    96103
     
    10571064    int m_sourceId;
    10581065    Vector<Identifier> m_parameters;
     1066
     1067    void initializeDeclarationStacks();
     1068    bool m_initializedDeclarationStacks;
     1069    DeclarationStacks::VarStack m_varStack;
     1070    DeclarationStacks::FunctionStack m_functionStack;
    10591071  };
    10601072
Note: See TracChangeset for help on using the changeset viewer.