Changeset 27339 in webkit


Ignore:
Timestamp:
Oct 31, 2007 10:02:30 PM (16 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):
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r27336 r27339  
     12007-10-31  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Oliver.
     4       
     5        - shave some cycles off of local storage access for a 1% SunSpider speedup
     6       
     7        Keep the LocalStorage pointer in the ExecState, not
     8
     9        * kjs/ExecState.cpp:
     10        (KJS::ExecState::updateLocalStorage):
     11        * kjs/ExecState.h:
     12        (KJS::ExecState::localStorage):
     13        * kjs/nodes.cpp:
     14        (KJS::LocalVarAccessNode::evaluate):
     15        (KJS::LocalVarFunctionCallNode::evaluate):
     16        (KJS::PostIncLocalVarNode::evaluate):
     17        (KJS::PostDecLocalVarNode::evaluate):
     18        (KJS::LocalVarTypeOfNode::evaluate):
     19        (KJS::PreIncLocalVarNode::evaluate):
     20        (KJS::PreDecLocalVarNode::evaluate):
     21        (KJS::ReadModifyLocalVarNode::evaluate):
     22        (KJS::AssignLocalVarNode::evaluate):
     23        (KJS::FunctionBodyNode::processDeclarationsForFunctionCode):
     24
    1252007-10-31  Adam Roben  <aroben@apple.com>
    226
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r27100 r27339  
    115115    return dynamicInterpreter();
    116116}
    117 
     117   
     118void ExecState::updateLocalStorage()
     119{
     120    m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();
     121}
    118122
    119123} // namespace KJS
  • trunk/JavaScriptCore/kjs/ExecState.h

    r27101 r27339  
    4545    class GlobalFuncImp;
    4646    class FunctionBodyNode;
     47    class LocalStorageEntry;
    4748   
    4849    /**
     
    103104        // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
    104105        const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
    105        
     106
     107        LocalStorageEntry* localStorage() { return m_localStorageBuffer; }
     108        void updateLocalStorage();
     109   
    106110    private:
    107111        ExecState(Interpreter* interp, JSGlobalObject* glob, JSObject* thisV,
     
    124128        const List* m_arguments;
    125129        JSObject* m_activation;
    126        
     130        LocalStorageEntry* m_localStorageBuffer;
     131
    127132        ScopeChain scope;
    128133        JSObject* m_variable;
  • 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.