Changeset 48774 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 25, 2009, 3:26:44 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Inlined some object creation code, including lexicalGlobalObject access
https://bugs.webkit.org/show_bug.cgi?id=29750

Patch by Geoffrey Garen <[email protected]> on 2009-09-25
Reviewed by Darin Adler.

SunSpider says 0.5% faster.

0.8% speedup on bench-alloc-nonretained.js.
2.5% speedup on v8-splay.js.

  • interpreter/CachedCall.h:

(JSC::CachedCall::CachedCall):

  • interpreter/CallFrame.h:

(JSC::ExecState::lexicalGlobalObject):
(JSC::ExecState::globalThisValue):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::dumpRegisters):
(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/ScopeChain.cpp:

(JSC::ScopeChainNode::print):

  • runtime/ScopeChain.h:

(JSC::ScopeChainNode::ScopeChainNode):
(JSC::ScopeChainNode::~ScopeChainNode):
(JSC::ScopeChainNode::push):
(JSC::ScopeChain::ScopeChain):
(JSC::ScopeChain::globalObject): Added a globalObject data member to ScopeChainNode.
Replaced accessor function for globalObject() with data member. Replaced
globalThisObject() accessor with direct access to globalThis, to match.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObject.h: Inlined array and object construction.

WebCore: Inlined some object creation code, including lexicalGlobalObject access
https://bugs.webkit.org/show_bug.cgi?id=29750

Patch by Geoffrey Garen <[email protected]> on 2009-09-25
Reviewed by Darin Adler.

  • bindings/js/JSInspectorBackendCustom.cpp:

(WebCore::JSInspectorBackend::currentCallFrame):

  • inspector/JavaScriptDebugServer.cpp:

(WebCore::JavaScriptDebugServer::hasBreakpoint): Updated for JavaScriptCore
API changes.

Location:
trunk/JavaScriptCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r48756 r48774  
     12009-09-25  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Darin Adler.
     4
     5        Inlined some object creation code, including lexicalGlobalObject access
     6        https://bugs.webkit.org/show_bug.cgi?id=29750
     7       
     8        SunSpider says 0.5% faster.
     9       
     10        0.8% speedup on bench-alloc-nonretained.js.
     11        2.5% speedup on v8-splay.js.
     12
     13        * interpreter/CachedCall.h:
     14        (JSC::CachedCall::CachedCall):
     15        * interpreter/CallFrame.h:
     16        (JSC::ExecState::lexicalGlobalObject):
     17        (JSC::ExecState::globalThisValue):
     18        * interpreter/Interpreter.cpp:
     19        (JSC::Interpreter::dumpRegisters):
     20        (JSC::Interpreter::execute):
     21        (JSC::Interpreter::privateExecute):
     22        * jit/JITStubs.cpp:
     23        (JSC::DEFINE_STUB_FUNCTION):
     24        * runtime/FunctionConstructor.cpp:
     25        (JSC::constructFunction):
     26        * runtime/ScopeChain.cpp:
     27        (JSC::ScopeChainNode::print):
     28        * runtime/ScopeChain.h:
     29        (JSC::ScopeChainNode::ScopeChainNode):
     30        (JSC::ScopeChainNode::~ScopeChainNode):
     31        (JSC::ScopeChainNode::push):
     32        (JSC::ScopeChain::ScopeChain):
     33        (JSC::ScopeChain::globalObject): Added a globalObject data member to ScopeChainNode.
     34        Replaced accessor function for globalObject() with data member. Replaced
     35        globalThisObject() accessor with direct access to globalThis, to match.
     36
     37        * runtime/JSGlobalObject.cpp:
     38        (JSC::JSGlobalObject::init):
     39        * runtime/JSGlobalObject.h: Inlined array and object construction.
     40
    1412009-09-25  Laszlo Gombos  <[email protected]>
    242
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r48542 r48774  
    140140__ZN3JSC14SamplingThread5startEj
    141141__ZN3JSC14TimeoutChecker5resetEv
    142 __ZN3JSC14constructArrayEPNS_9ExecStateERKNS_7ArgListE
    143142__ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
    144143__ZN3JSC15toInt32SlowCaseEdRb
     
    165164__ZN3JSC18PropertyDescriptor9setGetterENS_7JSValueE
    166165__ZN3JSC18PropertyDescriptor9setSetterENS_7JSValueE
    167 __ZN3JSC19constructEmptyArrayEPNS_9ExecStateE
    168166__ZN3JSC19initializeThreadingEv
    169167__ZN3JSC20MarkedArgumentBuffer10slowAppendENS_7JSValueE
    170 __ZN3JSC20constructEmptyObjectEPNS_9ExecStateE
    171168__ZN3JSC23AbstractSamplingCounter4dumpEv
    172169__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_7JSValueERKNS_7ArgListE
     
    214211__ZN3JSC7CStringaSERKS0_
    215212__ZN3JSC7JSArray4infoE
     213__ZN3JSC7JSArrayC1EN3WTF10PassRefPtrINS_9StructureEEE
     214__ZN3JSC7JSArrayC1EN3WTF10PassRefPtrINS_9StructureEEERKNS_7ArgListE
    216215__ZN3JSC7Profile10restoreAllEv
    217216__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
     
    302301__ZN3WTF12randomNumberEv
    303302__ZN3WTF13currentThreadEv
    304 __ZN3WTF13tryFastMallocEm
    305303__ZN3WTF13tryFastCallocEmm
    306304__ZN3WTF13tryFastMallocEm
     
    356354__ZNK3JSC18PropertyDescriptor16isDataDescriptorEv
    357355__ZNK3JSC18PropertyDescriptor20isAccessorDescriptorEv
     356__ZNK3JSC18PropertyDescriptor6getterEv
    358357__ZNK3JSC18PropertyDescriptor6setterEv
    359 __ZNK3JSC18PropertyDescriptor6getterEv
    360358__ZNK3JSC18PropertyDescriptor8writableEv
    361359__ZNK3JSC4Heap10statisticsEv
  • trunk/JavaScriptCore/interpreter/CachedCall.h

    r47641 r48774  
    3939            , m_interpreter(callFrame->interpreter())
    4040            , m_exception(exception)
    41             , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().node()->globalObject())
     41            , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().globalObject())
    4242        {
    4343            ASSERT(!function->isHostFunction());
  • trunk/JavaScriptCore/interpreter/CallFrame.h

    r46598 r48774  
    5252        JSGlobalObject* lexicalGlobalObject() const
    5353        {
    54             return scopeChain()->globalObject();
     54            return scopeChain()->globalObject;
    5555        }
    5656
     
    5959        JSObject* globalThisValue() const
    6060        {
    61             return scopeChain()->globalThisObject();
     61            return scopeChain()->globalThis;
    6262        }
    6363
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r48590 r48774  
    386386
    387387    CodeBlock* codeBlock = callFrame->codeBlock();
    388     RegisterFile* registerFile = &callFrame->scopeChain()->globalObject()->globalData()->interpreter->registerFile();
     388    RegisterFile* registerFile = &callFrame->scopeChain()->globalObject->globalData()->interpreter->registerFile();
    389389    const Register* it;
    390390    const Register* end;
     
    630630    }
    631631
    632     DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject());
     632    DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
    633633
    634634    JSGlobalObject* lastGlobalObject = m_registerFile.globalObject();
     
    690690    }
    691691
    692     DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject());
     692    DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject);
    693693
    694694    CallFrame* newCallFrame = CallFrame::create(oldEnd);
     
    820820    }
    821821
    822     DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject());
     822    DynamicGlobalObjectScope globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : scopeChain->globalObject);
    823823
    824824    EvalCodeBlock* codeBlock = &eval->bytecode(callFrame, scopeChain);
     
    12431243        int dst = (++vPC)->u.operand;
    12441244        int regExp = (++vPC)->u.operand;
    1245         callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->scopeChain()->globalObject()->regExpStructure(), callFrame->codeBlock()->regexp(regExp)));
     1245        callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->scopeChain()->globalObject->regExpStructure(), callFrame->codeBlock()->regexp(regExp)));
    12461246
    12471247        ++vPC;
     
    29822982        Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
    29832983        JSValue thisValue = argv[0].jsValue();
    2984         JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject();
     2984        JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
    29852985
    29862986        if (thisValue == globalObject && funcVal == globalObject->evalFunction()) {
     
    34303430                structure = asObject(prototype)->inheritorID();
    34313431            else
    3432                 structure = callDataScopeChain->globalObject()->emptyObjectStructure();
     3432                structure = callDataScopeChain->globalObject->emptyObjectStructure();
    34333433            JSObject* newObject = new (globalData) JSObject(structure);
    34343434
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r48590 r48774  
    11831183        // purpose.  The object is in no way exposed, and as such the check will always pass.
    11841184        if (slot.slotBase() == baseValue) {
    1185             JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject()->methodCallDummy(), STUB_RETURN_ADDRESS);
     1185            JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject->methodCallDummy(), STUB_RETURN_ADDRESS);
    11861186            return JSValue::encode(result);
    11871187        }
     
    17391739        structure = asObject(stackFrame.args[3].jsValue())->inheritorID();
    17401740    else
    1741         structure = constructor->scope().node()->globalObject()->emptyObjectStructure();
     1741        structure = constructor->scope().node()->globalObject->emptyObjectStructure();
    17421742    return new (stackFrame.globalData) JSObject(structure);
    17431743}
     
    26422642    Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
    26432643    JSValue thisValue = argv[0].jsValue();
    2644     JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject();
     2644    JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
    26452645
    26462646    if (thisValue == globalObject && funcVal == globalObject->evalFunction()) {
  • trunk/JavaScriptCore/runtime/FunctionConstructor.cpp

    r47738 r48774  
    9393
    9494    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    95     ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue());
     95    ScopeChain scopeChain(globalObject, globalObject->globalData(), globalObject, exec->globalThisValue());
    9696    return new (exec) JSFunction(exec, function, scopeChain.node());
    9797}
  • trunk/JavaScriptCore/runtime/JSArray.cpp

    r48542 r48774  
    10671067#endif
    10681068
    1069 JSArray* constructEmptyArray(ExecState* exec)
    1070 {
    1071     return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure());
    1072 }
    1073 
    1074 JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
    1075 {
    1076     return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength);
    1077 }
    1078 
    1079 JSArray* constructArray(ExecState* exec, JSValue singleItemValue)
    1080 {
    1081     MarkedArgumentBuffer values;
    1082     values.append(singleItemValue);
    1083     return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values);
    1084 }
    1085 
    1086 JSArray* constructArray(ExecState* exec, const ArgList& values)
    1087 {
    1088     return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values);
    1089 }
    1090 
    10911069} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSArray.h

    r48336 r48774  
    116116
    117117    JSArray* asArray(JSValue);
    118 
    119     JSArray* constructEmptyArray(ExecState*);
    120     JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
    121     JSArray* constructArray(ExecState*, JSValue singleItemValue);
    122     JSArray* constructArray(ExecState*, const ArgList& values);
    123118
    124119    inline JSArray* asArray(JSCell* cell)
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r48542 r48774  
    130130
    131131    d()->globalData = Heap::heap(this)->globalData();
    132     d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), thisValue);
     132    d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), this, thisValue);
    133133
    134134    JSGlobalObject::globalExec()->init(0, 0, d()->globalScopeChain.node(), CallFrame::noCaller(), 0, 0, 0);
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r48542 r48774  
    2323#define JSGlobalObject_h
    2424
     25#include "JSArray.h"
    2526#include "JSGlobalData.h"
    2627#include "JSVariableObject.h"
     
    344345    }
    345346
    346     inline JSGlobalObject* ScopeChainNode::globalObject() const
    347     {
    348         const ScopeChainNode* n = this;
    349         while (n->next)
    350             n = n->next;
    351         return asGlobalObject(n->object);
    352     }
    353 
    354347    inline JSValue Structure::prototypeForLookup(ExecState* exec) const
    355348    {
     
    406399    }
    407400
     401    inline JSObject* constructEmptyObject(ExecState* exec)
     402    {
     403        return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
     404    }
     405
     406    inline JSArray* constructEmptyArray(ExecState* exec)
     407    {
     408        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure());
     409    }
     410
     411    inline JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
     412    {
     413        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength);
     414    }
     415
     416    inline JSArray* constructArray(ExecState* exec, JSValue singleItemValue)
     417    {
     418        MarkedArgumentBuffer values;
     419        values.append(singleItemValue);
     420        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values);
     421    }
     422
     423    inline JSArray* constructArray(ExecState* exec, const ArgList& values)
     424    {
     425        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), values);
     426    }
     427
    408428    class DynamicGlobalObjectScope : public Noncopyable {
    409429    public:
  • trunk/JavaScriptCore/runtime/JSObject.cpp

    r48582 r48774  
    512512{
    513513    allocatePropertyStorageInline(oldSize, newSize);
    514 }
    515 
    516 JSObject* constructEmptyObject(ExecState* exec)
    517 {
    518     return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
    519514}
    520515
  • trunk/JavaScriptCore/runtime/JSObject.h

    r48542 r48774  
    265265    };
    266266   
    267 JSObject* constructEmptyObject(ExecState*);
    268 
    269267inline JSObject* asObject(JSCell* cell)
    270268{
  • trunk/JavaScriptCore/runtime/ScopeChain.cpp

    r47288 r48774  
    3737    for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) {
    3838        JSObject* o = *scopeIter;
    39         PropertyNameArray propertyNames(globalObject()->globalExec());
    40         o->getPropertyNames(globalObject()->globalExec(), propertyNames);
     39        PropertyNameArray propertyNames(globalObject->globalExec());
     40        o->getPropertyNames(globalObject->globalExec(), propertyNames);
    4141        PropertyNameArray::const_iterator propEnd = propertyNames.end();
    4242
  • trunk/JavaScriptCore/runtime/ScopeChain.h

    r47025 r48774  
    3434    class ScopeChainNode : public FastAllocBase {
    3535    public:
    36         ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSObject* globalThis)
     36        ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
    3737            : next(next)
    3838            , object(object)
    3939            , globalData(globalData)
     40            , globalObject(globalObject)
    4041            , globalThis(globalThis)
    4142            , refCount(1)
    4243        {
    4344            ASSERT(globalData);
     45            ASSERT(globalObject);
    4446        }
    4547#ifndef NDEBUG
     
    5254            object = 0;
    5355            globalData = 0;
     56            globalObject = 0;
    5457            globalThis = 0;
    5558        }
     
    5962        JSObject* object;
    6063        JSGlobalData* globalData;
     64        JSGlobalObject* globalObject;
    6165        JSObject* globalThis;
    6266        int refCount;
     
    8387        ScopeChainIterator end() const;
    8488
    85         JSGlobalObject* globalObject() const; // defined in JSGlobalObject.h
    86         JSObject* globalThisObject() const { return globalThis; }
    87 
    8889#ifndef NDEBUG       
    8990        void print() const;
     
    9495    {
    9596        ASSERT(o);
    96         return new ScopeChainNode(this, o, globalData, globalThis);
     97        return new ScopeChainNode(this, o, globalData, globalObject, globalThis);
    9798    }
    9899
     
    164165        }
    165166
    166         ScopeChain(JSObject* o, JSGlobalData* globalData, JSObject* globalThis)
    167             : m_node(new ScopeChainNode(0, o, globalData, globalThis))
     167        ScopeChain(JSObject* o, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
     168            : m_node(new ScopeChainNode(0, o, globalData, globalObject, globalThis))
    168169        {
    169170        }
     
    204205        void clear() { m_node->deref(); m_node = 0; }
    205206       
    206         JSGlobalObject* globalObject() const { return m_node->globalObject(); }
     207        JSGlobalObject* globalObject() const { return m_node->globalObject; }
    207208
    208209        void markAggregate(MarkStack&) const;
Note: See TracChangeset for help on using the changeset viewer.