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


Ignore:
Timestamp:
Nov 6, 2007, 10:03:20 PM (18 years ago)
Author:
oliver
Message:

Avoid unnecessarily boxing the result from post inc/decrement for 0.3% gain in sunspider

Reviewed by Maciej

We now convert the common 'for (...; ...; <var>++) ...' to the semantically identical
'for (...; ...; ++<var>) ...'.

File:
1 edited

Legend:

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

    r27494 r27501  
    935935}
    936936
     937void PostIncResolveNode::optimizeForUnnecessaryResult()
     938{
     939    new (this) PreIncResolveNode(PlacementNewAdopt);
     940}
     941   
    937942JSValue* PostIncLocalVarNode::evaluate(ExecState* exec)
    938943{
     
    940945    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
    941946
    942     JSValue** slot = &exec->localStorage()[index].value;
     947    JSValue** slot = &exec->localStorage()[m_index].value;
    943948    JSValue* v = (*slot)->toJSNumber(exec);
    944949    *slot = jsNumber(v->toNumber(exec) + 1);
    945950    return v;
     951}
     952
     953void PostIncLocalVarNode::optimizeForUnnecessaryResult()
     954{
     955    new (this) PreIncLocalVarNode(m_index);
    946956}
    947957
     
    982992  return throwUndefinedVariableError(exec, m_ident);
    983993}
    984 
     994   
     995void PostDecResolveNode::optimizeForUnnecessaryResult()
     996{
     997    new (this) PreDecResolveNode(PlacementNewAdopt);
     998}
     999   
    9851000JSValue* PostDecLocalVarNode::evaluate(ExecState* exec)
    9861001{
     
    9881003    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
    9891004
    990     JSValue** slot = &exec->localStorage()[index].value;
     1005    JSValue** slot = &exec->localStorage()[m_index].value;
    9911006    JSValue* v = (*slot)->toJSNumber(exec);
    9921007    *slot = jsNumber(v->toNumber(exec) - 1);
     
    9941009}
    9951010
     1011void PostDecLocalVarNode::optimizeForUnnecessaryResult()
     1012{
     1013    new (this) PreDecLocalVarNode(m_index);
     1014}
     1015   
    9961016// ------------------------------ PostfixBracketNode ----------------------------------
    9971017
Note: See TracChangeset for help on using the changeset viewer.