Changeset 37257 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 3, 2008, 2:39:16 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-03 Darin Adler <Darin Adler>

Reviewed by Geoff Garen.

Remove m_globalObject and m_globalData from ExecState.

SunSpider says this is a wash (slightly faster but not statistically
significant); which is good enough since it's a preparation step and
not supposed to be a spedup.

  • API/JSCallbackFunction.cpp: (JSC::JSCallbackFunction::JSCallbackFunction):
  • kjs/ArrayConstructor.cpp: (JSC::ArrayConstructor::ArrayConstructor):
  • kjs/BooleanConstructor.cpp: (JSC::BooleanConstructor::BooleanConstructor):
  • kjs/DateConstructor.cpp: (JSC::DateConstructor::DateConstructor):
  • kjs/ErrorConstructor.cpp: (JSC::ErrorConstructor::ErrorConstructor):
  • kjs/FunctionPrototype.cpp: (JSC::FunctionPrototype::FunctionPrototype):
  • kjs/JSFunction.cpp: (JSC::JSFunction::JSFunction):
  • kjs/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor::NativeErrorConstructor):
  • kjs/NumberConstructor.cpp: (JSC::NumberConstructor::NumberConstructor):
  • kjs/ObjectConstructor.cpp: (JSC::ObjectConstructor::ObjectConstructor):
  • kjs/PrototypeFunction.cpp: (JSC::PrototypeFunction::PrototypeFunction):
  • kjs/RegExpConstructor.cpp: (JSC::RegExpConstructor::RegExpConstructor):
  • kjs/StringConstructor.cpp: (JSC::StringConstructor::StringConstructor): Pass JSGlobalData* instead of ExecState* to the InternalFunction constructor.
  • API/OpaqueJSString.cpp: Added now-needed include.
  • VM/CTI.cpp: (JSC::CTI::emitSlowScriptCheck): Changed to use ARGS_globalData instead of ARGS_exec.
  • VM/CTI.h: Added a new argument to the CTI, the global data pointer. While it's possible to get to the global data pointer using the ExecState pointer, it's slow enough that it's better to just keep it around in the CTI arguments.
  • VM/CodeBlock.h: Moved the CodeType enum here from ExecState.h.
  • VM/Machine.cpp: (JSC::Machine::execute): Pass fewer arguments when constructing ExecState, and pass the global data pointer when invoking CTI. (JSC::Machine::firstCallFrame): Added. Used to get the dynamic global object, which is in the scope chain of the first call frame. (JSC::Machine::cti_op_add): Use globalData instead of exec when possible, to keep fast cases fast, since it's now more expensive to get to it through the exec pointer. (JSC::Machine::cti_timeout_check): Ditto. (JSC::Machine::cti_op_put_by_id_second): Ditto. (JSC::Machine::cti_op_get_by_id_second): Ditto. (JSC::Machine::cti_op_mul): Ditto. (JSC::Machine::cti_vm_compile): Ditto. (JSC::Machine::cti_op_get_by_val): Ditto. (JSC::Machine::cti_op_sub): Ditto. (JSC::Machine::cti_op_put_by_val): Ditto. (JSC::Machine::cti_op_put_by_val_array): Ditto. (JSC::Machine::cti_op_negate): Ditto. (JSC::Machine::cti_op_div): Ditto. (JSC::Machine::cti_op_pre_dec): Ditto. (JSC::Machine::cti_op_post_inc): Ditto. (JSC::Machine::cti_op_lshift): Ditto. (JSC::Machine::cti_op_bitand): Ditto. (JSC::Machine::cti_op_rshift): Ditto. (JSC::Machine::cti_op_bitnot): Ditto. (JSC::Machine::cti_op_mod): Ditto. (JSC::Machine::cti_op_post_dec): Ditto. (JSC::Machine::cti_op_urshift): Ditto. (JSC::Machine::cti_op_bitxor): Ditto. (JSC::Machine::cti_op_bitor): Ditto. (JSC::Machine::cti_op_call_eval): Ditto. (JSC::Machine::cti_op_throw): Ditto. (JSC::Machine::cti_op_is_string): Ditto. (JSC::Machine::cti_op_debug): Ditto. (JSC::Machine::cti_vm_throw): Ditto.
  • VM/Machine.h: Added firstCallFrame.
  • kjs/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::evaluate): Pass fewer arguments when constructing ExecState.
  • kjs/ExecState.cpp: Deleted contents. Later we'll remove the file altogether.
  • kjs/ExecState.h: Removed m_globalObject and m_globalData. Moved CodeType into another header. (JSC::ExecState::ExecState): Take only a single argument, a call frame pointer. (JSC::ExecState::dynamicGlobalObject): Get the object from the first call frame since it's no longer stored. (JSC::ExecState::globalData): Get the global data from the scope chain, since we no longer store a pointer to it here. (JSC::ExecState::identifierTable): Ditto. (JSC::ExecState::propertyNames): Ditto. (JSC::ExecState::emptyList): Ditto. (JSC::ExecState::lexer): Ditto. (JSC::ExecState::parser): Ditto. (JSC::ExecState::machine): Ditto. (JSC::ExecState::arrayTable): Ditto. (JSC::ExecState::dateTable): Ditto. (JSC::ExecState::mathTable): Ditto. (JSC::ExecState::numberTable): Ditto. (JSC::ExecState::regExpTable): Ditto. (JSC::ExecState::regExpConstructorTable): Ditto. (JSC::ExecState::stringTable): Ditto. (JSC::ExecState::heap): Ditto.
  • kjs/FunctionConstructor.cpp: (JSC::FunctionConstructor::FunctionConstructor): Pass JSGlobalData* instead of ExecState* to the InternalFunction constructor. (JSC::constructFunction): Pass the global data pointer when constructing a new scope chain.
  • kjs/InternalFunction.cpp: (JSC::InternalFunction::InternalFunction): Take a JSGlobalData* instead of an ExecState*. Later we can change more places to work this way -- it's more efficient to take the type you need since the caller might already have it.
  • kjs/InternalFunction.h: Ditto.
  • kjs/JSCell.h: (JSC::JSCell::operator new): Added an overload that takes a JSGlobalData* so you can construct without an ExecState*.
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): Moved creation of the global scope chain in here, since it now requires a pointer to the global data. Moved the initialization of the call frame in here since it requires the global scope chain node. Removed the extra argument to ExecState when creating the global ExecState*.
  • kjs/JSGlobalObject.h: Removed initialization of globalScopeChain and the call frame from the JSGlobalObjectData constructor. Added a thisValue argument to the init function.
  • kjs/JSNumberCell.cpp: Added versions of jsNumberCell that take JSGlobalData* rather than ExecState*.
  • kjs/JSNumberCell.h: (JSC::JSNumberCell::operator new): Added a version that takes JSGlobalData*. (JSC::JSNumberCell::JSNumberCell): Ditto. (JSC::jsNumber): Ditto.
  • kjs/JSString.cpp: (JSC::jsString): Ditto. (JSC::jsSubstring): Ditto. (JSC::jsOwnedString): Ditto.
  • kjs/JSString.h: (JSC::JSString::JSString): Changed to take JSGlobalData*. (JSC::jsEmptyString): Added a version that takes JSGlobalData*. (JSC::jsSingleCharacterString): Ditto. (JSC::jsSingleCharacterSubstring): Ditto. (JSC::jsNontrivialString): Ditto. (JSC::JSString::getIndex): Ditto. (JSC::jsString): Ditto. (JSC::jsSubstring): Ditto. (JSC::jsOwnedString): Ditto.
  • kjs/ScopeChain.h: Added a globalData pointer to each node. (JSC::ScopeChainNode::ScopeChainNode): Initialize the globalData pointer. (JSC::ScopeChainNode::push): Set the global data pointer in the new node. (JSC::ScopeChain::ScopeChain): Take a globalData argument.
  • kjs/SmallStrings.cpp: (JSC::SmallStrings::createEmptyString): Take JSGlobalData* instead of ExecState*. (JSC::SmallStrings::createSingleCharacterString): Ditto.
  • kjs/SmallStrings.h: (JSC::SmallStrings::emptyString): Ditto. (JSC::SmallStrings::singleCharacterString): Ditto.

WebCore:

2008-10-03 Darin Adler <Darin Adler>

Reviewed by Geoff Garen.

Remove m_globalObject and m_globalData from ExecState.

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData): Removed an argument now that JSGlobalObject doesn't need it any more. (WebCore::JSDOMWindowBase::JSDOMWindowBase): Removed the argument from the JSDOMWindowBaseData constructor, and added the this argument to the JSGlobalObject constructor. This is because a couple key bits of initialization moved from the data constructor to the JSGlobalObject constructor.
  • bindings/js/JSDOMWindowBase.h: Ditto.
  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
  • bridge/runtime_method.cpp: (JSC::RuntimeMethod::RuntimeMethod): Pass JSGlobalData* instead of ExecState* to the InternalFunction constructor.
Location:
trunk/JavaScriptCore/kjs
Files:
28 edited

Legend:

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

    r36726 r37257  
    3434
    3535ArrayConstructor::ArrayConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ArrayPrototype* arrayPrototype)
    36     : InternalFunction(exec, structure, Identifier(exec, arrayPrototype->classInfo()->className))
     36    : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className))
    3737{
    3838    // ECMA 15.4.3.1 Array.prototype
  • trunk/JavaScriptCore/kjs/BooleanConstructor.cpp

    r36726 r37257  
    3030
    3131BooleanConstructor::BooleanConstructor(ExecState* exec, PassRefPtr<StructureID> structure, BooleanPrototype* booleanPrototype)
    32     : InternalFunction(exec, structure, Identifier(exec, booleanPrototype->classInfo()->className))
     32    : InternalFunction(&exec->globalData(), structure, Identifier(exec, booleanPrototype->classInfo()->className))
    3333{
    3434    putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
  • trunk/JavaScriptCore/kjs/DateConstructor.cpp

    r36784 r37257  
    5353
    5454DateConstructor::DateConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, DatePrototype* datePrototype)
    55     : InternalFunction(exec, structure, Identifier(exec, datePrototype->classInfo()->className))
     55    : InternalFunction(&exec->globalData(), structure, Identifier(exec, datePrototype->classInfo()->className))
    5656{
    5757      putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
  • trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp

    r37184 r37257  
    6969        return 0;
    7070
    71     ExecState newExec(m_scopeChain->globalObject(), m_registers);
     71    ExecState newExec(m_registers);
    7272
    7373    int errLine;
  • trunk/JavaScriptCore/kjs/ErrorConstructor.cpp

    r36784 r37257  
    3131
    3232ErrorConstructor::ErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ErrorPrototype* errorPrototype)
    33     : InternalFunction(exec, structure, Identifier(exec, errorPrototype->classInfo()->className))
     33    : InternalFunction(&exec->globalData(), structure, Identifier(exec, errorPrototype->classInfo()->className))
    3434{
    3535    // ECMA 15.11.3.1 Error.prototype
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r37125 r37257  
    1 /*
    2  *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    3  *  Copyright (C) 2001 Peter Kelly ([email protected])
    4  *  Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
    5  *
    6  *  This library is free software; you can redistribute it and/or
    7  *  modify it under the terms of the GNU Library General Public
    8  *  License as published by the Free Software Foundation; either
    9  *  version 2 of the License, or (at your option) any later version.
    10  *
    11  *  This library is distributed in the hope that it will be useful,
    12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14  *  Library General Public License for more details.
    15  *
    16  *  You should have received a copy of the GNU Library General Public License
    17  *  along with this library; see the file COPYING.LIB.  If not, write to
    18  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    19  *  Boston, MA 02110-1301, USA.
    20  *
    21  */
    22 
    23 #include "config.h"
    24 #include "ExecState.h"
    25 
    26 #include "JSGlobalObject.h"
    27 #include "JSString.h"
    28 #include "ScopeChainMark.h"
    29 
    30 namespace JSC {
    31 
    32 ExecState::ExecState(JSGlobalObject* globalObject, Register* callFrame)
    33     : m_globalObject(globalObject)
    34     , m_exception(0)
    35     , m_globalData(globalObject->globalData())
    36     , m_callFrame(callFrame)
    37 {
    38 }
    39 
    40 ExecState::ExecState(ExecState* exec, Register* callFrame)
    41     : m_globalObject(exec->m_globalObject)
    42     , m_exception(0)
    43     , m_globalData(exec->m_globalData)
    44     , m_callFrame(callFrame)
    45 {
    46     ASSERT(!exec->m_exception);
    47 }
    48 
    49 } // namespace JSC
     1/* delete me */
  • trunk/JavaScriptCore/kjs/ExecState.h

    r37215 r37257  
    4242        friend class DebuggerCallFrame;
    4343    public:
    44         ExecState(JSGlobalObject*, Register* callFrame);
     44        explicit ExecState(Register* callFrame)
     45            : m_exception(0)
     46            , m_callFrame(callFrame)
     47        {
     48        }
    4549
    4650        // Global object in which execution began.
    47         JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; }
    48        
     51        JSGlobalObject* dynamicGlobalObject() const
     52        {
     53            return Machine::scopeChain(Machine::firstCallFrame(m_callFrame))->globalObject();
     54        }
     55
    4956        // Global object in which the current script was defined. (Can differ
    5057        // from dynamicGlobalObject() during function calls across frames.)
     
    5360            return Machine::scopeChain(m_callFrame)->globalObject();
    5461        }
    55        
    56         JSObject* globalThisValue() const { return Machine::scopeChain(m_callFrame)->globalThisObject(); }
    57                
     62
     63        JSObject* globalThisValue() const
     64        {
     65            return Machine::scopeChain(m_callFrame)->globalThisObject();
     66        }
     67
    5868        // Exception propogation.
    5969        void setException(JSValue* exception) { m_exception = exception; }
     
    6777#endif
    6878
    69         JSGlobalData& globalData() { return *m_globalData; }
     79        JSGlobalData& globalData() const
     80        {
     81            return *Machine::scopeChain(m_callFrame)->globalData;
     82        }
    7083
    71         IdentifierTable* identifierTable() { return m_globalData->identifierTable; }
    72         const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
    73         const ArgList& emptyList() const { return *m_globalData->emptyList; }
    74         Lexer* lexer() { return m_globalData->lexer; }
    75         Parser* parser() { return m_globalData->parser; }
    76         Machine* machine() const { return m_globalData->machine; }
    77         static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; }
    78         static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; }
    79         static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; }
    80         static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; }
    81         static const HashTable* regExpTable(ExecState* exec) { return exec->m_globalData->regExpTable; }
    82         static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->m_globalData->regExpConstructorTable; }
    83         static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
     84        IdentifierTable* identifierTable() { return globalData().identifierTable; }
     85        const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; }
     86        const ArgList& emptyList() const { return *globalData().emptyList; }
     87        Lexer* lexer() { return globalData().lexer; }
     88        Parser* parser() { return globalData().parser; }
     89        Machine* machine() const { return globalData().machine; }
     90        static const HashTable* arrayTable(ExecState* exec) { return exec->globalData().arrayTable; }
     91        static const HashTable* dateTable(ExecState* exec) { return exec->globalData().dateTable; }
     92        static const HashTable* mathTable(ExecState* exec) { return exec->globalData().mathTable; }
     93        static const HashTable* numberTable(ExecState* exec) { return exec->globalData().numberTable; }
     94        static const HashTable* regExpTable(ExecState* exec) { return exec->globalData().regExpTable; }
     95        static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->globalData().regExpConstructorTable; }
     96        static const HashTable* stringTable(ExecState* exec) { return exec->globalData().stringTable; }
    8497
    85         Heap* heap() const { return &m_globalData->heap; }
     98        Heap* heap() const { return &globalData().heap; }
    8699
    87100    private:
     
    89102        ExecState() { }
    90103
    91         ExecState(ExecState*, Register* callFrame);
    92 
    93104        bool isGlobalObject(JSObject*) const;
    94 
    95         JSGlobalObject* m_globalObject;
    96105
    97106        JSValue* m_exception;
     
    99108        void* m_ctiReturnAddress;
    100109#endif
    101         JSGlobalData* m_globalData;
    102 
    103110        Register* m_callFrame; // The most recent call frame.
    104111    };
    105 
    106     enum CodeType { GlobalCode, EvalCode, FunctionCode };
    107112
    108113} // namespace JSC
  • trunk/JavaScriptCore/kjs/FunctionConstructor.cpp

    r37184 r37257  
    3636
    3737FunctionConstructor::FunctionConstructor(ExecState* exec, PassRefPtr<StructureID> structure, FunctionPrototype* functionPrototype)
    38     : InternalFunction(exec, structure, Identifier(exec, functionPrototype->classInfo()->className))
     38    : InternalFunction(&exec->globalData(), structure, Identifier(exec, functionPrototype->classInfo()->className))
    3939{
    4040    putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
     
    128128    functionBody->finishParsing(source, parameters.releaseBuffer(), count);
    129129
    130     ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
     130    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     131    ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue());
    131132    JSFunction* function = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
    132133
  • trunk/JavaScriptCore/kjs/FunctionPrototype.cpp

    r36875 r37257  
    3838
    3939FunctionPrototype::FunctionPrototype(ExecState* exec)
    40     : InternalFunction(exec)
     40    : InternalFunction(&exec->globalData())
    4141{
    4242    putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
  • trunk/JavaScriptCore/kjs/InternalFunction.cpp

    r37103 r37257  
    3838}
    3939
    40 InternalFunction::InternalFunction(ExecState* exec)
    41     : JSObject(exec->globalData().nullProtoStructureID)
     40InternalFunction::InternalFunction(JSGlobalData* globalData)
     41    : JSObject(globalData->nullProtoStructureID)
    4242{
    43     putDirect(exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);
     43    putDirect(globalData->propertyNames->name, jsString(globalData, globalData->propertyNames->nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);
    4444}
    4545
    46 InternalFunction::InternalFunction(ExecState* exec, PassRefPtr<StructureID> structure, const Identifier& name)
     46InternalFunction::InternalFunction(JSGlobalData* globalData, PassRefPtr<StructureID> structure, const Identifier& name)
    4747    : JSObject(structure)
    4848{
    49     putDirect(exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum);
     49    putDirect(globalData->propertyNames->name, jsString(globalData, name.ustring()), DontDelete | ReadOnly | DontEnum);
    5050}
    5151
  • trunk/JavaScriptCore/kjs/InternalFunction.h

    r37103 r37257  
    4646    protected:
    4747        InternalFunction(PassRefPtr<StructureID> structure) : JSObject(structure) { }
    48         InternalFunction(ExecState*);
    49         InternalFunction(ExecState*, PassRefPtr<StructureID>, const Identifier&);
     48        InternalFunction(JSGlobalData*);
     49        InternalFunction(JSGlobalData*, PassRefPtr<StructureID>, const Identifier&);
    5050
    5151    private:
  • trunk/JavaScriptCore/kjs/JSCell.h

    r36764 r37257  
    8080        // Garbage collection.
    8181        void* operator new(size_t, ExecState*);
     82        void* operator new(size_t, JSGlobalData*);
    8283        void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; }
    8384        virtual void mark();
     
    156157    }
    157158
     159    inline void* JSCell::operator new(size_t size, JSGlobalData* globalData)
     160    {
     161#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
     162        return globalData->heap.inlineAllocate(size);
     163#else
     164        return globalData->heap.allocate(size);
     165#endif
     166    }
    158167
    159168    // --- JSValue inlines ----------------------------
  • trunk/JavaScriptCore/kjs/JSFunction.cpp

    r37184 r37257  
    4646
    4747JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
    48     : Base(exec, exec->lexicalGlobalObject()->functionStructure(), name)
     48    : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), name)
    4949    , m_body(body)
    5050    , m_scopeChain(scopeChainNode)
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r37215 r37257  
    123123}
    124124
    125 void JSGlobalObject::init()
     125void JSGlobalObject::init(JSObject* thisValue)
    126126{
    127127    ASSERT(JSLock::currentThreadIsHoldingLock());
    128128
    129129    d()->globalData = Heap::heap(this)->globalData();
     130    d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), thisValue);
     131
     132    Machine::initializeCallFrame(d()->globalCallFrame + RegisterFile::CallFrameHeaderSize, 0, 0, d()->globalScopeChain.node(), makeHostCallFramePointer(0), 0, 0, 0);
    130133
    131134    if (JSGlobalObject*& headObject = head()) {
     
    140143    d()->debugger = 0;
    141144
    142     d()->globalExec.set(new ExecState(this, d()->globalCallFrame + RegisterFile::CallFrameHeaderSize));
     145    d()->globalExec.set(new ExecState(d()->globalCallFrame + RegisterFile::CallFrameHeaderSize));
    143146
    144147    d()->profileGroup = 0;
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r37191 r37257  
    5555
    5656        struct JSGlobalObjectData : public JSVariableObjectData {
    57             JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
     57            JSGlobalObjectData()
    5858                : JSVariableObjectData(&symbolTable, 0)
    5959                , registerArraySize(0)
    60                 , globalScopeChain(globalObject, thisValue)
     60                , globalScopeChain(NoScopeChain())
    6161                , regExpConstructor(0)
    6262                , errorConstructor(0)
     
    7777                , regExpPrototype(0)
    7878            {
    79                 Machine::initializeCallFrame(globalCallFrame + RegisterFile::CallFrameHeaderSize, 0, 0, globalScopeChain.node(), makeHostCallFramePointer(0), 0, 0, 0);
    8079            }
    8180           
     
    144143        void* operator new(size_t, JSGlobalData*);
    145144
    146         JSGlobalObject(JSGlobalData* globalData)
    147             : JSVariableObject(globalData->nullProtoStructureID, new JSGlobalObjectData(this, this))
     145        explicit JSGlobalObject(JSGlobalData* globalData)
     146            : JSVariableObject(globalData->nullProtoStructureID, new JSGlobalObjectData)
    148147        {
    149             init();
     148            init(this);
    150149        }
    151150
    152151    protected:
    153         JSGlobalObject(PassRefPtr<StructureID> structure, JSGlobalObjectData* data)
     152        JSGlobalObject(PassRefPtr<StructureID> structure, JSGlobalObjectData* data, JSObject* thisValue)
    154153            : JSVariableObject(structure, data)
    155154        {
    156             init();
     155            init(thisValue);
    157156        }
    158157
     
    268267    private:
    269268        // FIXME: Fold reset into init.
    270         void init();
     269        void init(JSObject* thisValue);
    271270        void reset(JSValue* prototype);
    272271
     
    333332    }
    334333
    335 
    336334} // namespace JSC
    337335
  • trunk/JavaScriptCore/kjs/JSNumberCell.cpp

    r36726 r37257  
    112112}
    113113
     114NEVER_INLINE JSValue* jsNumberCell(JSGlobalData* globalData, double d)
     115{
     116    return new (globalData) JSNumberCell(globalData, d);
     117}
     118
     119NEVER_INLINE JSValue* jsNaN(JSGlobalData* globalData)
     120{
     121    return new (globalData) JSNumberCell(globalData, NaN);
     122}
     123
    114124} // namespace JSC
  • trunk/JavaScriptCore/kjs/JSNumberCell.h

    r36976 r37257  
    4444    class JSNumberCell : public JSCell {
    4545        friend class CTI;
     46        friend JSValue* jsNumberCell(JSGlobalData*, double);
     47        friend JSValue* jsNaN(JSGlobalData*);
    4648        friend JSValue* jsNumberCell(ExecState*, double);
    4749        friend JSValue* jsNaN(ExecState*);
     
    7274        }
    7375
     76        void* operator new(size_t size, JSGlobalData* globalData)
     77        {
     78    #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
     79            return globalData->heap.inlineAllocateNumber(size);
     80    #else
     81            return globalData->heap.allocateNumber(size);
     82    #endif
     83        }
     84
    7485        static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(NumberType)); }
    7586
    7687    private:
     88        JSNumberCell(JSGlobalData* globalData, double value)
     89            : JSCell(globalData->numberStructureID.get())
     90            , m_value(value)
     91        {
     92        }
     93
    7794        JSNumberCell(ExecState* exec, double value)
    7895            : JSCell(exec->globalData().numberStructureID.get())
     
    100117    }
    101118
     119    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, short i)
     120    {
     121        JSValue* v = JSImmediate::from(i);
     122        return v ? v : jsNumberCell(exec, i);
     123    }
     124
     125    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned short i)
     126    {
     127        JSValue* v = JSImmediate::from(i);
     128        return v ? v : jsNumberCell(exec, i);
     129    }
     130
    102131    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i)
    103132    {
     
    134163        JSValue* v = JSImmediate::from(i);
    135164        return v ? v : jsNumberCell(exec, static_cast<double>(i));
     165    }
     166
     167    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, double d)
     168    {
     169        JSValue* v = JSImmediate::from(d);
     170        return v ? v : jsNumberCell(globalData, d);
     171    }
     172
     173    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, short i)
     174    {
     175        JSValue* v = JSImmediate::from(i);
     176        return v ? v : jsNumberCell(globalData, i);
     177    }
     178
     179    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned short i)
     180    {
     181        JSValue* v = JSImmediate::from(i);
     182        return v ? v : jsNumberCell(globalData, i);
     183    }
     184
     185    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, int i)
     186    {
     187        JSValue* v = JSImmediate::from(i);
     188        return v ? v : jsNumberCell(globalData, i);
     189    }
     190
     191    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned i)
     192    {
     193        JSValue* v = JSImmediate::from(i);
     194        return v ? v : jsNumberCell(globalData, i);
     195    }
     196
     197    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, long i)
     198    {
     199        JSValue* v = JSImmediate::from(i);
     200        return v ? v : jsNumberCell(globalData, i);
     201    }
     202
     203    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned long i)
     204    {
     205        JSValue* v = JSImmediate::from(i);
     206        return v ? v : jsNumberCell(globalData, i);
     207    }
     208
     209    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, long long i)
     210    {
     211        JSValue* v = JSImmediate::from(i);
     212        return v ? v : jsNumberCell(globalData, static_cast<double>(i));
     213    }
     214
     215    ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned long long i)
     216    {
     217        JSValue* v = JSImmediate::from(i);
     218        return v ? v : jsNumberCell(globalData, static_cast<double>(i));
    136219    }
    137220
  • trunk/JavaScriptCore/kjs/JSString.cpp

    r36726 r37257  
    110110}
    111111
    112 JSString* jsString(ExecState* exec, const UString& s)
     112JSString* jsString(JSGlobalData* globalData, const UString& s)
    113113{
    114114    int size = s.size();
    115115    if (!size)
    116         return exec->globalData().smallStrings.emptyString(exec);
     116        return globalData->smallStrings.emptyString(globalData);
    117117    if (size == 1) {
    118118        UChar c = s.data()[0];
    119119        if (c <= 0xFF)
    120             return exec->globalData().smallStrings.singleCharacterString(exec, c);
     120            return globalData->smallStrings.singleCharacterString(globalData, c);
    121121    }
    122     return new (exec) JSString(exec, s);
     122    return new (globalData) JSString(globalData, s);
    123123}
    124124   
    125 JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length)
     125JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
    126126{
    127127    ASSERT(offset <= static_cast<unsigned>(s.size()));
     
    129129    ASSERT(offset + length <= static_cast<unsigned>(s.size()));
    130130    if (!length)
    131         return exec->globalData().smallStrings.emptyString(exec);
     131        return globalData->smallStrings.emptyString(globalData);
    132132    if (length == 1) {
    133133        UChar c = s.data()[offset];
    134134        if (c <= 0xFF)
    135             return exec->globalData().smallStrings.singleCharacterString(exec, c);
     135            return globalData->smallStrings.singleCharacterString(globalData, c);
    136136    }
    137     return new (exec) JSString(exec, UString::Rep::create(s.rep(), offset, length));
     137    return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, length));
    138138}
    139139
    140 JSString* jsOwnedString(ExecState* exec, const UString& s)
     140JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
    141141{
    142142    int size = s.size();
    143143    if (!size)
    144         return exec->globalData().smallStrings.emptyString(exec);
     144        return globalData->smallStrings.emptyString(globalData);
    145145    if (size == 1) {
    146146        UChar c = s.data()[0];
    147147        if (c <= 0xFF)
    148             return exec->globalData().smallStrings.singleCharacterString(exec, c);
     148            return globalData->smallStrings.singleCharacterString(globalData, c);
    149149    }
    150     return new (exec) JSString(exec, s, JSString::HasOtherOwner);
     150    return new (globalData) JSString(globalData, s, JSString::HasOtherOwner);
    151151}
    152152
  • trunk/JavaScriptCore/kjs/JSString.h

    r36755 r37257  
    3434    class JSString;
    3535
     36    JSString* jsEmptyString(JSGlobalData*);
    3637    JSString* jsEmptyString(ExecState*);
     38    JSString* jsString(JSGlobalData*, const UString&); // returns empty string if passed null string
    3739    JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string
    3840
     41    JSString* jsSingleCharacterString(JSGlobalData*, UChar);
    3942    JSString* jsSingleCharacterString(ExecState*, UChar);
     43    JSString* jsSingleCharacterSubstring(JSGlobalData*, const UString&, unsigned offset);
    4044    JSString* jsSingleCharacterSubstring(ExecState*, const UString&, unsigned offset);
     45    JSString* jsSubstring(JSGlobalData*, const UString&, unsigned offset, unsigned length);
    4146    JSString* jsSubstring(ExecState*, const UString&, unsigned offset, unsigned length);
    4247
    4348    // Non-trivial strings are two or more characters long.
    4449    // These functions are faster than just calling jsString.
     50    JSString* jsNontrivialString(JSGlobalData*, const UString&);
    4551    JSString* jsNontrivialString(ExecState*, const UString&);
     52    JSString* jsNontrivialString(JSGlobalData*, const char*);
    4653    JSString* jsNontrivialString(ExecState*, const char*);
    4754
     
    4956    // likely outlive the JSValue this makes, such as the parse tree or a
    5057    // DOM object that contains a UString
     58    JSString* jsOwnedString(JSGlobalData*, const UString&);
    5159    JSString* jsOwnedString(ExecState*, const UString&);
    5260
     
    5664
    5765    public:
    58         JSString(ExecState* exec, const UString& value)
    59             : JSCell(exec->globalData().stringStructureID.get())
     66        JSString(JSGlobalData* globalData, const UString& value)
     67            : JSCell(globalData->stringStructureID.get())
    6068            , m_value(value)
    6169        {
     
    6472
    6573        enum HasOtherOwnerType { HasOtherOwner };
    66         JSString(ExecState* exec, const UString& value, HasOtherOwnerType)
    67             : JSCell(exec->globalData().stringStructureID.get())
     74        JSString(JSGlobalData* globalData, const UString& value, HasOtherOwnerType)
     75            : JSCell(globalData->stringStructureID.get())
    6876            , m_value(value)
    6977        {
    7078        }
    71         JSString(ExecState* exec, PassRefPtr<UString::Rep> value, HasOtherOwnerType)
    72             : JSCell(exec->globalData().stringStructureID.get())
     79        JSString(JSGlobalData* globalData, PassRefPtr<UString::Rep> value, HasOtherOwnerType)
     80            : JSCell(globalData->stringStructureID.get())
    7381            , m_value(value)
    7482        {
     
    8189
    8290        bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); }
    83         JSString* getIndex(ExecState*, unsigned);
     91        JSString* getIndex(JSGlobalData*, unsigned);
    8492
    8593        static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType)); }
     
    110118    };
    111119
    112     inline JSString* jsEmptyString(ExecState* exec)
    113     {
    114         return exec->globalData().smallStrings.emptyString(exec);
    115     }
    116 
    117     inline JSString* jsSingleCharacterString(ExecState* exec, UChar c)
     120    inline JSString* jsEmptyString(JSGlobalData* globalData)
     121    {
     122        return globalData->smallStrings.emptyString(globalData);
     123    }
     124
     125    inline JSString* jsSingleCharacterString(JSGlobalData* globalData, UChar c)
    118126    {
    119127        if (c <= 0xFF)
    120             return exec->globalData().smallStrings.singleCharacterString(exec, c);
    121         return new (exec) JSString(exec, UString(&c, 1));
    122     }
    123 
    124     inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset)
     128            return globalData->smallStrings.singleCharacterString(globalData, c);
     129        return new (globalData) JSString(globalData, UString(&c, 1));
     130    }
     131
     132    inline JSString* jsSingleCharacterSubstring(JSGlobalData* globalData, const UString& s, unsigned offset)
    125133    {
    126134        ASSERT(offset < static_cast<unsigned>(s.size()));
    127135        UChar c = s.data()[offset];
    128136        if (c <= 0xFF)
    129             return exec->globalData().smallStrings.singleCharacterString(exec, c);
    130         return new (exec) JSString(exec, UString::Rep::create(s.rep(), offset, 1));
    131     }
    132 
    133     inline JSString* jsNontrivialString(ExecState* exec, const char* s)
     137            return globalData->smallStrings.singleCharacterString(globalData, c);
     138        return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, 1));
     139    }
     140
     141    inline JSString* jsNontrivialString(JSGlobalData* globalData, const char* s)
    134142    {
    135143        ASSERT(s);
    136144        ASSERT(s[0]);
    137145        ASSERT(s[1]);
    138         return new (exec) JSString(exec, s);
    139     }
    140 
    141     inline JSString* jsNontrivialString(ExecState* exec, const UString& s)
     146        return new (globalData) JSString(globalData, s);
     147    }
     148
     149    inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s)
    142150    {
    143151        ASSERT(s.size() > 1);
    144         return new (exec) JSString(exec, s);
    145     }
    146 
    147     inline JSString* JSString::getIndex(ExecState* exec, unsigned i)
     152        return new (globalData) JSString(globalData, s);
     153    }
     154
     155    inline JSString* JSString::getIndex(JSGlobalData* globalData, unsigned i)
    148156    {
    149157        ASSERT(canGetIndex(i));
    150         return jsSingleCharacterSubstring(exec, m_value, i);
    151     }
     158        return jsSingleCharacterSubstring(globalData, m_value, i);
     159    }
     160
     161    inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&exec->globalData()); }
     162    inline JSString* jsString(ExecState* exec, const UString& s) { return jsString(&exec->globalData(), s); }
     163    inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&exec->globalData(), c); }
     164    inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset) { return jsSingleCharacterSubstring(&exec->globalData(), s, offset); }
     165    inline JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); }
     166    inline JSString* jsNontrivialString(ExecState* exec, const UString& s) { return jsNontrivialString(&exec->globalData(), s); }
     167    inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&exec->globalData(), s); }
     168    inline JSString* jsOwnedString(ExecState* exec, const UString& s) { return jsOwnedString(&exec->globalData(), s); }
    152169
    153170    ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
  • trunk/JavaScriptCore/kjs/NativeErrorConstructor.cpp

    r36755 r37257  
    3333
    3434NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NativeErrorPrototype* nativeErrorPrototype)
    35     : InternalFunction(exec, structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
     35    : InternalFunction(&exec->globalData(), structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
    3636    , m_errorStructure(ErrorInstance::createStructureID(nativeErrorPrototype))
    3737{
  • trunk/JavaScriptCore/kjs/NumberConstructor.cpp

    r36977 r37257  
    5555
    5656NumberConstructor::NumberConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NumberPrototype* numberPrototype)
    57     : InternalFunction(exec, structure, Identifier(exec, numberPrototype->info.className))
     57    : InternalFunction(&exec->globalData(), structure, Identifier(exec, numberPrototype->info.className))
    5858{
    5959    // Number.Prototype
  • trunk/JavaScriptCore/kjs/ObjectConstructor.cpp

    r36726 r37257  
    3030
    3131ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ObjectPrototype* objectPrototype)
    32     : InternalFunction(exec, structure, Identifier(exec, "Object"))
     32    : InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object"))
    3333{
    3434    // ECMA 15.2.3.1
  • trunk/JavaScriptCore/kjs/PrototypeFunction.cpp

    r36726 r37257  
    3434
    3535PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
    36     : InternalFunction(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
     36    : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
    3737    , m_function(function)
    3838{
     
    4242
    4343PrototypeFunction::PrototypeFunction(ExecState* exec, PassRefPtr<StructureID> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
    44     : InternalFunction(exec, prototypeFunctionStructure, name)
     44    : InternalFunction(&exec->globalData(), prototypeFunctionStructure, name)
    4545    , m_function(function)
    4646{
  • trunk/JavaScriptCore/kjs/RegExpConstructor.cpp

    r36977 r37257  
    105105
    106106RegExpConstructor::RegExpConstructor(ExecState* exec, PassRefPtr<StructureID> structure, RegExpPrototype* regExpPrototype)
    107     : InternalFunction(exec, structure, Identifier(exec, "RegExp"))
     107    : InternalFunction(&exec->globalData(), structure, Identifier(exec, "RegExp"))
    108108    , d(new RegExpConstructorPrivate)
    109109{
  • trunk/JavaScriptCore/kjs/ScopeChain.h

    r36263 r37257  
    3232    class ScopeChainNode {
    3333    public:
    34         ScopeChainNode(ScopeChainNode* n, JSObject* o, JSObject* gt)
    35             : next(n)
    36             , object(o)
    37             , globalThis(gt)
     34        ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSObject* globalThis)
     35            : next(next)
     36            , object(object)
     37            , globalData(globalData)
     38            , globalThis(globalThis)
    3839            , refCount(1)
    3940        {
     41            ASSERT(globalData);
    4042        }
    4143
    4244        ScopeChainNode* next;
    4345        JSObject* object;
     46        JSGlobalData* globalData;
    4447        JSObject* globalThis;
    4548        int refCount;
     
    7982    {
    8083        ASSERT(o);
    81         return new ScopeChainNode(this, o, globalThis);
     84        return new ScopeChainNode(this, o, globalData, globalThis);
    8285    }
    8386
     
    156159        }
    157160
    158         ScopeChain(JSObject* o, JSObject* globalThis)
    159             : m_node(new ScopeChainNode(0, o, globalThis))
     161        ScopeChain(JSObject* o, JSGlobalData* globalData, JSObject* globalThis)
     162            : m_node(new ScopeChainNode(0, o, globalData, globalThis))
    160163        {
    161164        }
  • trunk/JavaScriptCore/kjs/SmallStrings.cpp

    r36316 r37257  
    2727#include "SmallStrings.h"
    2828
     29#include "JSGlobalObject.h"
    2930#include "JSString.h"
    3031
     
    8889}
    8990   
    90 void SmallStrings::createEmptyString(ExecState* exec)
     91void SmallStrings::createEmptyString(JSGlobalData* globalData)
    9192{
    9293    ASSERT(!m_emptyString);
    93     m_emptyString = new (exec) JSString(exec, "", JSString::HasOtherOwner);
     94    m_emptyString = new (globalData) JSString(globalData, "", JSString::HasOtherOwner);
    9495}
    9596
    96 void SmallStrings::createSingleCharacterString(ExecState* exec, unsigned char character)
     97void SmallStrings::createSingleCharacterString(JSGlobalData* globalData, unsigned char character)
    9798{
    9899    if (!m_storage)
    99100        m_storage.set(new SmallStringsStorage);
    100101    ASSERT(!m_singleCharacterStrings[character]);
    101     m_singleCharacterStrings[character] = new (exec) JSString(exec, m_storage->rep(character), JSString::HasOtherOwner);
     102    m_singleCharacterStrings[character] = new (globalData) JSString(globalData, m_storage->rep(character), JSString::HasOtherOwner);
    102103}
    103104
  • trunk/JavaScriptCore/kjs/SmallStrings.h

    r36263 r37257  
    3232namespace JSC {
    3333
    34     class ExecState;
     34    class JSGlobalData;
    3535    class JSString;
    3636
     
    4242        ~SmallStrings();
    4343
    44         JSString* emptyString(ExecState* exec)
     44        JSString* emptyString(JSGlobalData* globalData)
    4545        {
    4646            if (!m_emptyString)
    47                 createEmptyString(exec);
     47                createEmptyString(globalData);
    4848            return m_emptyString;
    4949        }
    50         JSString* singleCharacterString(ExecState* exec, unsigned char character)
     50        JSString* singleCharacterString(JSGlobalData* globalData, unsigned char character)
    5151        {
    5252            if (!m_singleCharacterStrings[character])
    53                 createSingleCharacterString(exec, character);
     53                createSingleCharacterString(globalData, character);
    5454            return m_singleCharacterStrings[character];
    5555        }
     
    6060       
    6161    private:
    62         void createEmptyString(ExecState*);
    63         void createSingleCharacterString(ExecState*, unsigned char);
     62        void createEmptyString(JSGlobalData*);
     63        void createSingleCharacterString(JSGlobalData*, unsigned char);
    6464
    6565        JSString* m_emptyString;
  • trunk/JavaScriptCore/kjs/StringConstructor.cpp

    r36726 r37257  
    4848
    4949StringConstructor::StringConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, StringPrototype* stringPrototype)
    50     : InternalFunction(exec, structure, Identifier(exec, stringPrototype->classInfo()->className))
     50    : InternalFunction(&exec->globalData(), structure, Identifier(exec, stringPrototype->classInfo()->className))
    5151{
    5252    // ECMA 15.5.3.1 String.prototype
Note: See TracChangeset for help on using the changeset viewer.