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


Ignore:
Timestamp:
Oct 31, 2007, 10:02:30 PM (18 years ago)
Author:
mjs
Message:

Reviewed by Oliver.


  • shave some cycles off of local storage access for a 1% SunSpider speedup


Keep the LocalStorage pointer in the ExecState, not

  • kjs/ExecState.cpp: (KJS::ExecState::updateLocalStorage):
  • kjs/ExecState.h: (KJS::ExecState::localStorage):
  • kjs/nodes.cpp: (KJS::LocalVarAccessNode::evaluate): (KJS::LocalVarFunctionCallNode::evaluate): (KJS::PostIncLocalVarNode::evaluate): (KJS::PostDecLocalVarNode::evaluate): (KJS::LocalVarTypeOfNode::evaluate): (KJS::PreIncLocalVarNode::evaluate): (KJS::PreDecLocalVarNode::evaluate): (KJS::ReadModifyLocalVarNode::evaluate): (KJS::AssignLocalVarNode::evaluate): (KJS::FunctionBodyNode::processDeclarationsForFunctionCode):
File:
1 edited

Legend:

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

    r27308 r27339  
    429429JSValue* LocalVarAccessNode::evaluate(ExecState* exec)
    430430{
    431     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    432     ASSERT(variableObject->isActivation());
    433     ASSERT(variableObject == exec->scopeChain().top());
    434     return variableObject->localStorage()[index].value;
     431    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     432    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     433    return exec->localStorage()[index].value;
    435434}
    436435
     
    766765JSValue* LocalVarFunctionCallNode::evaluate(ExecState* exec)
    767766{
    768     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    769     ASSERT(variableObject->isActivation());
    770     ASSERT(variableObject == exec->scopeChain().top());
    771 
    772     JSValue* v = variableObject->localStorage()[index].value;
     767    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     768    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     769
     770    JSValue* v = exec->localStorage()[index].value;
    773771
    774772    if (!v->isObject())
     
    933931JSValue* PostIncLocalVarNode::evaluate(ExecState* exec)
    934932{
    935     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    936     ASSERT(variableObject->isActivation());
    937     ASSERT(variableObject == exec->scopeChain().top());
    938 
    939     JSValue** slot = &variableObject->localStorage()[index].value;
     933    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     934    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     935
     936    JSValue** slot = &exec->localStorage()[index].value;
    940937    double n = (*slot)->toNumber(exec);
    941938    *slot = jsNumber(n + 1);
     
    984981JSValue* PostDecLocalVarNode::evaluate(ExecState* exec)
    985982{
    986     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    987     ASSERT(variableObject->isActivation());
    988     ASSERT(variableObject == exec->scopeChain().top());
    989 
    990     JSValue** slot = &variableObject->localStorage()[index].value;
     983    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     984    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     985
     986    JSValue** slot = &exec->localStorage()[index].value;
    991987    double n = (*slot)->toNumber(exec);
    992988    *slot = jsNumber(n - 1);
     
    12821278JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec)
    12831279{
    1284     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    1285     ASSERT(variableObject->isActivation());
    1286     ASSERT(variableObject == exec->scopeChain().top());
    1287     return typeStringForValue(variableObject->localStorage()[m_index].value);
     1280    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     1281    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1282
     1283    return typeStringForValue(exec->localStorage()[m_index].value);
    12881284}
    12891285
     
    13351331JSValue* PreIncLocalVarNode::evaluate(ExecState* exec)
    13361332{
    1337     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    1338     ASSERT(variableObject->isActivation());
    1339     ASSERT(variableObject == exec->scopeChain().top());
    1340     JSValue* v = variableObject->localStorage()[m_index].value;
    1341 
    1342     double n = v->toNumber(exec);
     1333    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     1334    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1335    JSValue** slot = &exec->localStorage()[m_index].value;
     1336
     1337    double n = (*slot)->toNumber(exec);
    13431338    JSValue* n2 = jsNumber(n + 1);
    1344     variableObject->localStorage()[m_index].value = n2;
     1339    *slot = n2;
    13451340    return n2;
    13461341}
     
    13841379JSValue* PreDecLocalVarNode::evaluate(ExecState* exec)
    13851380{
    1386     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    1387     ASSERT(variableObject->isActivation());
    1388     ASSERT(variableObject == exec->scopeChain().top());
    1389     JSValue* v = variableObject->localStorage()[m_index].value;
    1390 
    1391     double n = v->toNumber(exec);
     1381    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     1382    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     1383    JSValue** slot = &exec->localStorage()[m_index].value;
     1384
     1385    double n = (*slot)->toNumber(exec);
    13921386    JSValue* n2 = jsNumber(n - 1);
    1393     variableObject->localStorage()[m_index].value = n2;
     1387    *slot = n2;
    13941388    return n2;
    13951389}
     
    22012195JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec)
    22022196{
    2203     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    2204     ASSERT(variableObject->isActivation());
    2205     ASSERT(variableObject == exec->scopeChain().top());
    2206     JSValue* v;
    2207     JSValue** slot = &variableObject->localStorage()[m_index].value;
     2197    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     2198    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
     2199    JSValue** slot = &exec->localStorage()[m_index].value;
    22082200
    22092201    ASSERT(m_oper != OpEqual);
    22102202    JSValue* v2 = m_right->evaluate(exec);
    2211     v = valueForReadModifyAssignment(exec, *slot, v2, m_oper);
     2203    JSValue* v = valueForReadModifyAssignment(exec, *slot, v2, m_oper);
    22122204
    22132205    KJS_CHECKEXCEPTIONVALUE
     
    22192211JSValue* AssignLocalVarNode::evaluate(ExecState* exec)
    22202212{
    2221     ActivationImp* variableObject = static_cast<ActivationImp*>(exec->variableObject());
    2222     ASSERT(variableObject->isActivation());
    2223     ASSERT(variableObject == exec->scopeChain().top());
     2213    ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation());
     2214    ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top());
    22242215    JSValue* v = m_right->evaluate(exec);
    22252216
    22262217    KJS_CHECKEXCEPTIONVALUE
    22272218
    2228     variableObject->localStorage()[m_index].value = v;
     2219    exec->localStorage()[m_index].value = v;
    22292220   
    22302221    return v;
     
    35693560        localStorage.append(LocalStorageEntry(node->makeFunction(exec), minAttributes));
    35703561    }
     3562
     3563    exec->updateLocalStorage();
    35713564}
    35723565
Note: See TracChangeset for help on using the changeset viewer.