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


Ignore:
Timestamp:
Nov 3, 2007, 3:09:45 AM (18 years ago)
Author:
mjs
Message:

Reviewed by Oliver.


  • remove VarDeclListNode and simplify VarDeclNode evaluation for 0.4% SunSpider speedup
  • kjs/grammar.y:
  • kjs/nodes.cpp: (KJS::VarDeclNode::optimizeVariableAccess): (KJS::VarDeclNode::getDeclarations): (KJS::VarDeclNode::handleSlowCase): (KJS::VarDeclNode::evaluateSingle): (KJS::VarDeclNode::evaluate): (KJS::VarStatementNode::execute):
  • kjs/nodes.h: (KJS::VarDeclNode::): (KJS::VarStatementNode::):
  • kjs/nodes2string.cpp: (KJS::VarDeclNode::streamTo):
File:
1 edited

Legend:

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

    r27389 r27394  
    5656
    5757#define KJS_CHECKEXCEPTIONLIST \
     58  if (exec->hadException()) { \
     59    handleException(exec); \
     60    return; \
     61  }
     62
     63#define KJS_CHECKEXCEPTIONVOID \
    5864  if (exec->hadException()) { \
    5965    handleException(exec); \
     
    24732479void VarDeclNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack& nodeStack)
    24742480{
     2481    if (next)
     2482        nodeStack.append(next.get());
    24752483    if (init)
    24762484        nodeStack.append(init.get());
    24772485}
    2478    
     2486
    24792487void VarDeclNode::getDeclarations(DeclarationStacks& stacks)
    24802488{
     2489    if (next) {
     2490        ASSERT(next->mayHaveDeclarations());
     2491        stacks.nodeStack.append(next.get());
     2492    }
     2493
    24812494    // The normal check to avoid overwriting pre-existing values with variable
    24822495    // declarations doesn't work for the "arguments" property because we
     
    24882501}
    24892502
    2490 JSValue* VarDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val)
     2503void VarDeclNode::handleSlowCase(ExecState* exec, const ScopeChain& chain, JSValue* val)
    24912504{
    24922505    ScopeChainIterator iter = chain.begin();
     
    25132526   
    25142527    base->put(exec, ident, val, flags);
    2515     return 0;
    25162528}
    25172529
    25182530// ECMA 12.2
    2519 JSValue* VarDeclNode::evaluate(ExecState* exec)
     2531inline void VarDeclNode::evaluateSingle(ExecState* exec)
    25202532{
    25212533    const ScopeChain& chain = exec->scopeChain();
     
    25362548    } else if (init) {
    25372549        JSValue* val = init->evaluate(exec);
    2538         KJS_CHECKEXCEPTIONVALUE
     2550        KJS_CHECKEXCEPTIONVOID
    25392551           
    25402552        // if the variable object is the top of the scope chain, then that must
     
    25522564        variableObject->put(exec, ident, val, flags);
    25532565    }
    2554 
    2555     // no caller of this function actually uses the return value.
    2556     // FIXME: It would be better to change the inheritence hierarchy so this
    2557     // node doesn't even have an evaluate method, but instead a differently named
    2558     // one with a void return.
    2559     return 0;
    2560 }
    2561 
    2562 // ------------------------------ VarDeclListNode ------------------------------
    2563 
    2564 void VarDeclListNode::optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack& nodeStack)
    2565 {
    2566     if (next)
    2567         nodeStack.append(next.get());
    2568     nodeStack.append(var.get());
    2569 }
    2570 
    2571 // ECMA 12.2
    2572 JSValue *VarDeclListNode::evaluate(ExecState *exec)
    2573 {
    2574   for (VarDeclListNode *n = this; n; n = n->next.get()) {
    2575     n->var->evaluate(exec);
    2576     KJS_CHECKEXCEPTIONVALUE
    2577   }
    2578   return jsUndefined();
    2579 }
    2580 
    2581 void VarDeclListNode::getDeclarations(DeclarationStacks& stacks)
    2582 {
    2583     if (next) {
    2584         ASSERT(next->mayHaveDeclarations());
    2585         stacks.nodeStack.append(next.get());
     2566}
     2567
     2568JSValue* VarDeclNode::evaluate(ExecState* exec)
     2569{
     2570    evaluateSingle(exec);
     2571
     2572    if (VarDeclNode* n = next.get()) {
     2573        do {
     2574            n->evaluateSingle(exec);
     2575            KJS_CHECKEXCEPTIONVALUE
     2576            n = n->next.get();
     2577        } while (n);
    25862578    }
    2587     stacks.nodeStack.append(var.get());
     2579    return jsUndefined();
    25882580}
    25892581
     
    25992591Completion VarStatementNode::execute(ExecState *exec)
    26002592{
    2601   KJS_BREAKPOINT;
    2602 
    2603   (void) next->evaluate(exec);
    2604   KJS_CHECKEXCEPTION
    2605 
    2606   return Completion(Normal);
     2593    KJS_BREAKPOINT;
     2594
     2595    next->evaluate(exec);
     2596    KJS_CHECKEXCEPTION
     2597
     2598    return Completion(Normal);
    26072599}
    26082600
Note: See TracChangeset for help on using the changeset viewer.