Changeset 32652 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Apr 28, 2008, 11:22:14 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Fix run-webkit-tests --threading
and provisionally fix <https://bugs.webkit.org/show_bug.cgi?id=18661>
Proxy server issue in Sunday's Nightly

Changed ClassInfo objects for built-in objects to hold a getter function returning
a per-thread instance. This makes it safe to share these ClassInfo objects between threads -
and these are the only ones that need to be shared.

Location:
trunk/JavaScriptCore
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackConstructor.cpp

    r29663 r32652  
    3535namespace KJS {
    3636
    37 const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0};
     37const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
    3838
    3939JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r29663 r32652  
    3737namespace KJS {
    3838
    39 const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0};
     39const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0, 0 };
    4040
    4141JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r29663 r32652  
    3434
    3535// Define the two types of JSCallbackObjects we support.
    36 template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0 };
    37 template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0 };
     36template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
     37template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
    3838
    3939COMPILE_ASSERT(sizeof(JSCallbackObject<JSGlobalObject>) <= CELL_SIZE, global_callback_object_fits_in_cell);
  • trunk/JavaScriptCore/ChangeLog

    r32650 r32652  
     12008-04-28  Alexey Proskuryakov  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Fix run-webkit-tests --threading
     6        and provisionally fix <https://bugs.webkit.org/show_bug.cgi?id=18661>
     7        Proxy server issue in Sunday's Nightly
     8
     9        Changed ClassInfo objects for built-in objects to hold a getter function returning
     10        a per-thread instance. This makes it safe to share these ClassInfo objects between threads -
     11        and these are the only ones that need to be shared.
     12
     13        * kjs/lexer.cpp:
     14        (KJS::Lexer::Lexer):
     15        (KJS::Lexer::~Lexer):
     16        * kjs/lexer.h:
     17        Made mainTable a member of Lexer, so that it no longer needs to be shared between threads.
     18
     19        * kjs/object.cpp:
     20        (KJS::JSObject::deleteProperty):
     21        (KJS::JSObject::findPropertyHashEntry):
     22        (KJS::JSObject::propertyIsEnumerable):
     23        (KJS::JSObject::getPropertyAttributes):
     24        (KJS::JSObject::getPropertyNames):
     25        * kjs/object.h:
     26        (KJS::ClassInfo::propHashTable):
     27        Added a new classPropHashTableGetterFunction field to ClassInfo. If it is non-zero, the
     28        static table is not used.
     29
     30        * kjs/JSGlobalObject.cpp:
     31        (KJS::ThreadClassInfoHashTables::ThreadClassInfoHashTables): This new class holds per-thread
     32        HashTables for built-in classes. The old static structs are copied to create per-thread
     33        instances.
     34        (KJS::JSGlobalObject::threadClassInfoHashTables): An accessor/initializer for the above.
     35        (KJS::JSGlobalObject::init): Copy per-thread data into a single structure for faster access.
     36        Also, construct globalExec.
     37        (KJS::JSGlobalObject::reset): Adapted for globalExec now being an OwnPtr.
     38        (KJS::JSGlobalObject::mark): Ditto.
     39        (KJS::JSGlobalObject::globalExec): Ditto.
     40        * kjs/JSGlobalObject.h:
     41        (KJS::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): Made JSGlobalObject::JSGlobalObjectData::globalExec an OwnPtr, so that it can
     42        be initialized from JSGlobalObject::init() after them. Otherwise, ExecState constructor was
     43        trying to access half-initialized JSGlobalObject to make its own copy of these table
     44        references, and failed.
     45        (KJS::JSGlobalObject::JSGlobalObject): Pass "this" value to init() to create globalExec.
     46        (KJS::JSGlobalObject::perThreadData): An accessor for per-thread data.
     47
     48        * kjs/ExecState.cpp:
     49        (KJS::ExecState::ExecState):
     50        * kjs/ExecState.h:
     51        (KJS::ExecState::propertyNames):
     52        (KJS::ExecState::emptyList):
     53        (KJS::ExecState::arrayTable):
     54        (KJS::ExecState::dateTable):
     55        (KJS::ExecState::mathTable):
     56        (KJS::ExecState::numberTable):
     57        (KJS::ExecState::RegExpImpTable):
     58        (KJS::ExecState::RegExpObjectImpTable):
     59        (KJS::ExecState::stringTable):
     60        * kjs/ExecStateInlines.h:
     61        (KJS::ExecState::ExecState):
     62        Each ExecState holds its own reference to per-thread data, for even faster access. Moved
     63        m_emptyList and m_propertyNames to the same structure, making ExecState faster to construct
     64        and take less space on the stack.
     65
     66        * kjs/InitializeThreading.cpp: (KJS::initializeThreading): Initialize thread-static data
     67        added to JSGlobalObject.
     68
     69        * API/JSCallbackConstructor.cpp:
     70        (KJS::):
     71        * API/JSCallbackFunction.cpp:
     72        (KJS::):
     73        * API/JSCallbackObject.cpp:
     74        (KJS::):
     75        * JavaScriptCore.exp:
     76        * kjs/JSVariableObject.cpp:
     77        (KJS::JSVariableObject::getPropertyAttributes):
     78        * kjs/JSVariableObject.h:
     79        * kjs/array_instance.cpp:
     80        (KJS::):
     81        * kjs/array_object.cpp:
     82        (KJS::):
     83        (KJS::ArrayPrototype::getOwnPropertySlot):
     84        * kjs/bool_object.cpp:
     85        (KJS::):
     86        * kjs/create_hash_table:
     87        * kjs/date_object.cpp:
     88        (KJS::):
     89        (KJS::DatePrototype::getOwnPropertySlot):
     90        (KJS::DateObjectImp::DateObjectImp):
     91        * kjs/error_object.cpp:
     92        (KJS::):
     93        * kjs/function.cpp:
     94        (KJS::):
     95        * kjs/function_object.cpp:
     96        (KJS::FunctionPrototype::FunctionPrototype):
     97        * kjs/internal.cpp:
     98        (KJS::):
     99        * kjs/lookup.h:
     100        * kjs/math_object.cpp:
     101        (KJS::):
     102        (KJS::MathObjectImp::getOwnPropertySlot):
     103        * kjs/number_object.cpp:
     104        (KJS::):
     105        (KJS::NumberObjectImp::getOwnPropertySlot):
     106        * kjs/object_object.cpp:
     107        (KJS::ObjectPrototype::ObjectPrototype):
     108        * kjs/regexp_object.cpp:
     109        (KJS::):
     110        (KJS::RegExpPrototype::RegExpPrototype):
     111        (KJS::RegExpImp::getOwnPropertySlot):
     112        (KJS::RegExpImp::put):
     113        (KJS::RegExpObjectImp::getOwnPropertySlot):
     114        (KJS::RegExpObjectImp::put):
     115        * kjs/string_object.cpp:
     116        (KJS::):
     117        (KJS::StringPrototype::getOwnPropertySlot):
     118        Adjust for the above changes.
     119
    11202008-04-28  Darin Adler  <[email protected]>
    2121
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r32609 r32652  
    108108__ZN3KJS14JSGlobalObject18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
    109109__ZN3KJS14JSGlobalObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
    110 __ZN3KJS14JSGlobalObject4initEv
     110__ZN3KJS14JSGlobalObject4initEPNS_8JSObjectE
    111111__ZN3KJS14JSGlobalObject4markEv
    112112__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
     
    121121__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
    122122__ZN3KJS15GlobalExecStateC1EPNS_14JSGlobalObjectEPNS_8JSObjectE
     123__ZN3KJS15GlobalExecStateD1Ev
    123124__ZN3KJS15JSWrapperObject4markEv
    124125__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
     
    238239__ZNK3KJS14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE
    239240__ZNK3KJS16JSVariableObject16isVariableObjectEv
    240 __ZNK3KJS16JSVariableObject21getPropertyAttributesERKNS_10IdentifierERj
     241__ZNK3KJS16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
    241242__ZNK3KJS19InternalFunctionImp14implementsCallEv
    242243__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
     
    267268__ZNK3KJS8JSObject14toGlobalObjectEPNS_9ExecStateE
    268269__ZNK3KJS8JSObject19implementsConstructEv
    269 __ZNK3KJS8JSObject21getPropertyAttributesERKNS_10IdentifierERj
     270__ZNK3KJS8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
    270271__ZNK3KJS8JSObject21implementsHasInstanceEv
    271272__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r31746 r32652  
    3434namespace KJS {
    3535
    36 static inline List* globalEmptyList()
    37 {
    38     static List staticEmptyList;
    39     return &staticEmptyList;
    40 }
    41 
    4236// ECMA 10.2
    4337
     
    4640    : m_globalObject(globalObject)
    4741    , m_exception(0)
    48     , m_propertyNames(CommonIdentifiers::shared())
    49     , m_emptyList(globalEmptyList())
    5042    , m_callingExec(0)
     43    , m_perThreadData(globalObject->perThreadData())
    5144    , m_scopeNode(0)
    5245    , m_function(0)
     
    6861    : m_globalObject(globalObject)
    6962    , m_exception(0)
    70     , m_propertyNames(CommonIdentifiers::shared())
    71     , m_emptyList(globalEmptyList())
    7263    , m_callingExec(0)
     64    , m_perThreadData(globalObject->perThreadData())
    7365    , m_scopeNode(programNode)
    7466    , m_function(0)
     
    9183    : m_globalObject(globalObject)
    9284    , m_exception(0)
    93     , m_propertyNames(callingExec->m_propertyNames)
    94     , m_emptyList(callingExec->m_emptyList)
    9585    , m_callingExec(callingExec)
     86    , m_perThreadData(callingExec->m_perThreadData)
    9687    , m_scopeNode(evalNode)
    9788    , m_function(0)
  • trunk/JavaScriptCore/kjs/ExecState.h

    r32259 r32652  
    3939    class FunctionImp;
    4040    class GlobalFuncImp;
     41    struct HashTable;
    4142    class Interpreter;
    4243    class JSGlobalObject;
     
    4647   
    4748    enum CodeType { GlobalCode, EvalCode, FunctionCode };
     49
     50    struct PerThreadData {
     51        const HashTable* arrayTable;
     52        const HashTable* dateTable;
     53        const HashTable* mathTable;
     54        const HashTable* numberTable;
     55        const HashTable* RegExpImpTable;
     56        const HashTable* RegExpObjectImpTable;
     57        const HashTable* stringTable;
     58
     59        CommonIdentifiers* propertyNames;
     60        const List emptyList;
     61    };
    4862
    4963    // Represents the current state of script execution.
     
    97111        // These pointers are used to avoid accessing global variables for these,
    98112        // to avoid taking PIC branches in Mach-O binaries.
    99         const CommonIdentifiers& propertyNames() const { return *m_propertyNames; }
    100         const List& emptyList() const { return *m_emptyList; }
     113        const CommonIdentifiers& propertyNames() const { return *m_perThreadData->propertyNames; }
     114        const List& emptyList() const { return m_perThreadData->emptyList; }
     115        static const HashTable* arrayTable(ExecState* exec) { return exec->m_perThreadData->arrayTable; }
     116        static const HashTable* dateTable(ExecState* exec) { return exec->m_perThreadData->dateTable; }
     117        static const HashTable* mathTable(ExecState* exec) { return exec->m_perThreadData->mathTable; }
     118        static const HashTable* numberTable(ExecState* exec) { return exec->m_perThreadData->numberTable; }
     119        static const HashTable* RegExpImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpImpTable; }
     120        static const HashTable* RegExpObjectImpTable(ExecState* exec) { return exec->m_perThreadData->RegExpObjectImpTable; }
     121        static const HashTable* stringTable(ExecState* exec) { return exec->m_perThreadData->stringTable; }
    101122
    102123        LocalStorage& localStorage() { return *m_localStorage; }
     
    177198        JSGlobalObject* m_globalObject;
    178199        JSValue* m_exception;
    179         CommonIdentifiers* m_propertyNames;
    180         const List* m_emptyList;
    181200
    182201        ExecState* m_callingExec;
     202
     203        const PerThreadData* m_perThreadData;
    183204
    184205        ScopeNode* m_scopeNode;
  • trunk/JavaScriptCore/kjs/ExecStateInlines.h

    r31746 r32652  
    3636        : m_globalObject(globalObject)
    3737        , m_exception(0)
    38         , m_propertyNames(callingExec->m_propertyNames)
    39         , m_emptyList(callingExec->m_emptyList)
    4038        , m_callingExec(callingExec)
     39        , m_perThreadData(callingExec->m_perThreadData)
    4140        , m_scopeNode(functionBodyNode)
    4241        , m_function(func)
  • trunk/JavaScriptCore/kjs/InitializeThreading.cpp

    r32322 r32652  
    3434#include "dtoa.h"
    3535#include "identifier.h"
     36#include "JSGlobalObject.h"
    3637#include "lexer.h"
    3738#include "Parser.h"
     
    5556        lexer();
    5657        initDateMath();
     58        JSGlobalObject::threadClassInfoHashTables();
    5759    }
    5860#endif
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r32587 r32652  
    4545#include "string_object.h"
    4646
     47#if USE(MULTIPLE_THREADS)
     48#include <wtf/ThreadSpecific.h>
     49using namespace WTF;
     50#endif
     51
    4752#if HAVE(SYS_TIME_H)
    4853#include <sys/time.h>
     
    5863
    5964namespace KJS {
     65
     66extern HashTable arrayTable;
     67extern HashTable dateTable;
     68extern HashTable mathTable;
     69extern HashTable numberTable;
     70extern HashTable RegExpImpTable;
     71extern HashTable RegExpObjectImpTable;
     72extern HashTable stringTable;
    6073
    6174// Default number of ticks before a timeout check should be done.
     
    119132}
    120133
    121 void JSGlobalObject::init()
     134struct ThreadClassInfoHashTables {
     135    ThreadClassInfoHashTables()
     136        : arrayTable(KJS::arrayTable)
     137        , dateTable(KJS::dateTable)
     138        , mathTable(KJS::mathTable)
     139        , numberTable(KJS::numberTable)
     140        , RegExpImpTable(KJS::RegExpImpTable)
     141        , RegExpObjectImpTable(KJS::RegExpObjectImpTable)
     142        , stringTable(KJS::stringTable)
     143    {
     144    }
     145
     146    ~ThreadClassInfoHashTables()
     147    {
     148#if USE(MULTIPLE_THREADS)
     149        delete[] arrayTable.table;
     150        delete[] dateTable.table;
     151        delete[] mathTable.table;
     152        delete[] numberTable.table;
     153        delete[] RegExpImpTable.table;
     154        delete[] RegExpObjectImpTable.table;
     155        delete[] stringTable.table;
     156#endif
     157    }
     158
     159#if USE(MULTIPLE_THREADS)
     160    HashTable arrayTable;
     161    HashTable dateTable;
     162    HashTable mathTable;
     163    HashTable numberTable;
     164    HashTable RegExpImpTable;
     165    HashTable RegExpObjectImpTable;
     166    HashTable stringTable;
     167#else
     168    HashTable& arrayTable;
     169    HashTable& dateTable;
     170    HashTable& mathTable;
     171    HashTable& numberTable;
     172    HashTable& RegExpImpTable;
     173    HashTable& RegExpObjectImpTable;
     174    HashTable& stringTable;
     175#endif
     176};
     177
     178ThreadClassInfoHashTables* JSGlobalObject::threadClassInfoHashTables()
     179{
     180#if USE(MULTIPLE_THREADS)
     181    static ThreadSpecific<ThreadClassInfoHashTables> sharedInstance;
     182    return sharedInstance;
     183#else
     184    static ThreadClassInfoHashTables sharedInstance;
     185    return &sharedInstance;
     186#endif
     187}
     188
     189void JSGlobalObject::init(JSObject* thisValue)
    122190{
    123191    ASSERT(JSLock::currentThreadIsHoldingLock());
     
    142210    d()->activations = newStackNode;
    143211    d()->activationCount = 0;
     212
     213    d()->perThreadData.arrayTable = &threadClassInfoHashTables()->arrayTable;
     214    d()->perThreadData.dateTable = &threadClassInfoHashTables()->dateTable;
     215    d()->perThreadData.mathTable = &threadClassInfoHashTables()->mathTable;
     216    d()->perThreadData.numberTable = &threadClassInfoHashTables()->numberTable;
     217    d()->perThreadData.RegExpImpTable = &threadClassInfoHashTables()->RegExpImpTable;
     218    d()->perThreadData.RegExpObjectImpTable = &threadClassInfoHashTables()->RegExpObjectImpTable;
     219    d()->perThreadData.stringTable = &threadClassInfoHashTables()->stringTable;
     220    d()->perThreadData.propertyNames = CommonIdentifiers::shared();
     221
     222    d()->globalExec.set(new GlobalExecState(this, thisValue));
    144223
    145224    d()->pageGroupIdentifier = 0;
     
    232311    d()->evalFunction = 0;
    233312
    234     ExecState* exec = &d()->globalExec;
     313    ExecState* exec = d()->globalExec.get();
    235314
    236315    // Prototypes
     
    419498        (*it)->m_scopeChain.mark();
    420499
    421     markIfNeeded(d()->globalExec.exception());
     500    markIfNeeded(d()->globalExec->exception());
    422501
    423502    markIfNeeded(d()->objectConstructor);
     
    463542ExecState* JSGlobalObject::globalExec()
    464543{
    465     return &d()->globalExec;
     544    return d()->globalExec.get();
    466545}
    467546
     
    493572}
    494573
     574
    495575} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r32587 r32652  
    4343    class FunctionObjectImp;
    4444    class FunctionPrototype;
     45    struct HashTable;
    4546    class JSGlobalObject;
    4647    class NativeErrorImp;
     
    6869    class UriErrorPrototype;
    6970    struct ActivationStackNode;
     71    struct ThreadClassInfoHashTables;
    7072
    7173    typedef Vector<ExecState*, 16> ExecStateStack;
     
    7678
    7779        struct JSGlobalObjectData : public JSVariableObjectData {
    78             JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
     80            JSGlobalObjectData()
    7981                : JSVariableObjectData(&inlineSymbolTable)
    80                 , globalExec(globalObject, thisValue)
    8182            {
    8283            }
     
    8788            Debugger* debugger;
    8889           
    89             GlobalExecState globalExec;
     90            OwnPtr<GlobalExecState> globalExec;
    9091            int recursion;
    9192
     
    141142
    142143            OwnPtr<HashSet<JSObject*> > arrayVisitedElements; // Global data shared by array prototype functions.
     144
     145            PerThreadData perThreadData;
    143146        };
    144147
    145148    public:
    146149        JSGlobalObject()
    147             : JSVariableObject(new JSGlobalObjectData(this, this))
     150            : JSVariableObject(new JSGlobalObjectData)
    148151        {
    149             init();
     152            init(this);
    150153        }
    151154
    152155    protected:
    153156        JSGlobalObject(JSValue* proto, JSObject* globalThisValue)
    154             : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue))
     157            : JSVariableObject(proto, new JSGlobalObjectData)
    155158        {
    156             init();
     159            init(globalThisValue);
    157160        }
    158161
     
    247250        HashSet<JSObject*>& arrayVisitedElements() { if (!d()->arrayVisitedElements) d()->arrayVisitedElements.set(new HashSet<JSObject*>); return *d()->arrayVisitedElements; }
    248251
     252        // Per-thread hash tables, cached on the global object for faster access.
     253        const PerThreadData* perThreadData() const { return &d()->perThreadData; }
     254
     255        // Initialize and/or retrieve per-thread hash tables - use perThreadData() for faster access instead.
     256        static ThreadClassInfoHashTables* threadClassInfoHashTables();
     257
    249258    private:
    250         void init();
     259        void init(JSObject* thisValue);
    251260       
    252261        JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
  • trunk/JavaScriptCore/kjs/JSVariableObject.cpp

    r32609 r32652  
    5454}
    5555
    56 bool JSVariableObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
     56bool JSVariableObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const
    5757{
    5858    size_t index = symbolTable().get(propertyName.ustring().rep());
     
    6161        return true;
    6262    }
    63     return JSObject::getPropertyAttributes(propertyName, attributes);
     63    return JSObject::getPropertyAttributes(exec, propertyName, attributes);
    6464}
    6565
  • trunk/JavaScriptCore/kjs/JSVariableObject.h

    r32609 r32652  
    5151        virtual bool isDynamicScope() const = 0;
    5252
    53         virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
     53        virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const;
    5454
    5555    protected:
  • trunk/JavaScriptCore/kjs/array_instance.cpp

    r32609 r32652  
    5151static const unsigned copyingSortCutoff = 50000;
    5252
    53 const ClassInfo ArrayInstance::info = {"Array", 0, 0};
     53const ClassInfo ArrayInstance::info = {"Array", 0, 0, 0};
    5454
    5555static inline size_t storageSize(unsigned vectorLength)
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r31807 r32652  
    3939// ------------------------------ ArrayPrototype ----------------------------
    4040
    41 const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, &arrayTable};
     41const ClassInfo ArrayPrototype::info = {"Array", &ArrayInstance::info, 0, ExecState::arrayTable};
    4242
    4343/* Source for array_object.lut.h
     
    7373bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    7474{
    75     return getStaticFunctionSlot<ArrayInstance>(exec, &arrayTable, this, propertyName, slot);
     75    return getStaticFunctionSlot<ArrayInstance>(exec, ExecState::arrayTable(exec), this, propertyName, slot);
    7676}
    7777
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r31730 r32652  
    3131// ------------------------------ BooleanInstance ---------------------------
    3232
    33 const ClassInfo BooleanInstance::info = { "Boolean", 0, 0 };
     33const ClassInfo BooleanInstance::info = { "Boolean", 0, 0, 0 };
    3434
    3535BooleanInstance::BooleanInstance(JSObject* proto)
  • trunk/JavaScriptCore/kjs/create_hash_table

    r31147 r32652  
    203203    print "   { 0, 0, 0, 0 }\n";
    204204    print "};\n\n";
    205     print "const struct HashTable $name = ";
     205    print "extern const struct HashTable $name = ";
    206206    print "\{ ", $size - 1, ", $nameEntries, 0 \};\n\n";
    207207    print "} // namespace\n";
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r31943 r32652  
    331331// ------------------------------ DateInstance ------------------------------
    332332
    333 const ClassInfo DateInstance::info = {"Date", 0, 0};
     333const ClassInfo DateInstance::info = {"Date", 0, 0, 0};
    334334
    335335DateInstance::DateInstance(JSObject *proto)
     
    417417// ------------------------------ DatePrototype -----------------------------
    418418
    419 const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, &dateTable};
     419const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, 0, ExecState::dateTable};
    420420
    421421/* Source for date_object.lut.h
     
    479479bool DatePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    480480{
    481     return getStaticFunctionSlot<JSObject>(exec, &dateTable, this, propertyName, slot);
     481    return getStaticFunctionSlot<JSObject>(exec, ExecState::dateTable(exec), this, propertyName, slot);
    482482}
    483483
     
    490490{
    491491  putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
    492   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, CommonIdentifiers::shared()->parse), DontEnum);
    493   putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, CommonIdentifiers::shared()->UTC), DontEnum);
     492  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, exec->propertyNames().parse), DontEnum);
     493  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, exec->propertyNames().UTC), DontEnum);
    494494  putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
    495495}
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r30040 r32652  
    3232// ------------------------------ ErrorInstance ----------------------------
    3333
    34 const ClassInfo ErrorInstance::info = { "Error", 0, 0 };
     34const ClassInfo ErrorInstance::info = { "Error", 0, 0, 0 };
    3535
    3636ErrorInstance::ErrorInstance(JSObject* prototype)
     
    115115// ------------------------------ NativeErrorImp -------------------------------
    116116
    117 const ClassInfo NativeErrorImp::info = { "Function", &InternalFunctionImp::info, 0 };
     117const ClassInfo NativeErrorImp::info = { "Function", &InternalFunctionImp::info, 0, 0 };
    118118
    119119NativeErrorImp::NativeErrorImp(ExecState* exec, FunctionPrototype* funcProto, NativeErrorPrototype* prot)
  • trunk/JavaScriptCore/kjs/function.cpp

    r32609 r32652  
    5858// ----------------------------- FunctionImp ----------------------------------
    5959
    60 const ClassInfo FunctionImp::info = { "Function", &InternalFunctionImp::info, 0 };
     60const ClassInfo FunctionImp::info = { "Function", &InternalFunctionImp::info, 0, 0 };
    6161
    6262FunctionImp::FunctionImp(ExecState* exec, const Identifier& name, FunctionBodyNode* b, const ScopeChain& sc)
     
    280280// ------------------------------ Arguments ---------------------------------
    281281
    282 const ClassInfo Arguments::info = { "Arguments", 0, 0 };
     282const ClassInfo Arguments::info = { "Arguments", 0, 0, 0 };
    283283
    284284// ECMA 10.1.8
     
    343343// ------------------------------ ActivationImp --------------------------------
    344344
    345 const ClassInfo ActivationImp::info = { "Activation", 0, 0 };
     345const ClassInfo ActivationImp::info = { "Activation", 0, 0, 0 };
    346346
    347347ActivationImp::ActivationImp(const ActivationData& oldData, bool leaveRelic)
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r31746 r32652  
    4848
    4949    putDirectFunction(new PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    50     putDirectFunction(new PrototypeFunction(exec, this, 2, CommonIdentifiers::shared()->apply, functionProtoFuncApply), DontEnum);
    51     putDirectFunction(new PrototypeFunction(exec, this, 1, CommonIdentifiers::shared()->call, functionProtoFuncCall), DontEnum);
     50    putDirectFunction(new PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
     51    putDirectFunction(new PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
    5252}
    5353
  • trunk/JavaScriptCore/kjs/internal.cpp

    r32609 r32652  
    221221// ------------------------------ InternalFunctionImp --------------------------
    222222
    223 const ClassInfo InternalFunctionImp::info = { "Function", 0, 0 };
     223const ClassInfo InternalFunctionImp::info = { "Function", 0, 0, 0 };
    224224
    225225InternalFunctionImp::InternalFunctionImp()
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r31948 r32652  
    8989    , next2(0)
    9090    , next3(0)
     91    , mainTable(KJS::mainTable)
    9192{
    9293    m_buffer8.reserveCapacity(initialReadBufferCapacity);
     
    9495    m_strings.reserveCapacity(initialStringTableCapacity);
    9596    m_identifiers.reserveCapacity(initialStringTableCapacity);
     97}
     98
     99Lexer::~Lexer()
     100{
     101    delete[] mainTable.table;
    96102}
    97103
  • trunk/JavaScriptCore/kjs/lexer.h

    r31944 r32652  
    2525#define Lexer_h
    2626
     27#include "lookup.h"
    2728#include "ustring.h"
    2829#include <wtf/Vector.h>
     
    9596    friend class WTF::ThreadSpecific<Lexer>;
    9697    Lexer();
     98    ~Lexer();
    9799
    98100    int yylineno;
     
    146148    UString m_pattern;
    147149    UString m_flags;
     150
     151    const HashTable mainTable;
    148152  };
    149153 
  • trunk/JavaScriptCore/kjs/lookup.h

    r31208 r32652  
    282282
    283283#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype) \
    284     const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table  }; \
     284    const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table, 0  }; \
    285285    JSObject* ClassPrototype::self(ExecState* exec) \
    286286    { \
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r31560 r32652  
    3232// ------------------------------ MathObjectImp --------------------------------
    3333
    34 const ClassInfo MathObjectImp::info = { "Math", 0, &mathTable };
     34const ClassInfo MathObjectImp::info = { "Math", 0, 0, ExecState::mathTable };
    3535
    3636/* Source for math_object.lut.h
     
    7474bool MathObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot &slot)
    7575{
    76     return getStaticPropertySlot<MathObjectImp, JSObject>(exec, &mathTable, this, propertyName, slot);
     76    return getStaticPropertySlot<MathObjectImp, JSObject>(exec, ExecState::mathTable(exec), this, propertyName, slot);
    7777}
    7878
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r31948 r32652  
    3535// ------------------------------ NumberInstance ----------------------------
    3636
    37 const ClassInfo NumberInstance::info = { "Number", 0, 0 };
     37const ClassInfo NumberInstance::info = { "Number", 0, 0, 0 };
    3838
    3939NumberInstance::NumberInstance(JSObject* proto)
     
    451451// ------------------------------ NumberObjectImp ------------------------------
    452452
    453 const ClassInfo NumberObjectImp::info = { "Function", &InternalFunctionImp::info, &numberTable };
     453const ClassInfo NumberObjectImp::info = { "Function", &InternalFunctionImp::info, 0, ExecState::numberTable };
    454454
    455455/* Source for number_object.lut.h
     
    474474bool NumberObjectImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    475475{
    476     return getStaticValueSlot<NumberObjectImp, InternalFunctionImp>(exec, &numberTable, this, propertyName, slot);
     476    return getStaticValueSlot<NumberObjectImp, InternalFunctionImp>(exec, ExecState::numberTable(exec), this, propertyName, slot);
    477477}
    478478
  • trunk/JavaScriptCore/kjs/object.cpp

    r32609 r32652  
    2828#include "date_object.h"
    2929#include "error_object.h"
    30 #include "lookup.h"
    3130#include "nodes.h"
    3231#include "operations.h"
     
    319318
    320319// ECMA 8.6.2.5
    321 bool JSObject::deleteProperty(ExecState* /*exec*/, const Identifier &propertyName)
     320bool JSObject::deleteProperty(ExecState* exec, const Identifier &propertyName)
    322321{
    323322  unsigned attributes;
     
    333332
    334333  // Look in the static hashtable of properties
    335   const HashEntry* entry = findPropertyHashEntry(propertyName);
     334  const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
    336335  if (entry && entry->attributes & DontDelete)
    337336    return false; // this builtin property can't be deleted
     
    396395}
    397396
    398 const HashEntry* JSObject::findPropertyHashEntry(const Identifier& propertyName) const
     397const HashEntry* JSObject::findPropertyHashEntry(ExecState* exec, const Identifier& propertyName) const
    399398{
    400399    for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
    401         if (const HashTable* propHashTable = info->propHashTable) {
     400        if (const HashTable* propHashTable = info->propHashTable(exec)) {
    402401            if (const HashEntry* e = propHashTable->entry(propertyName))
    403402                return e;
     
    530529}
    531530
    532 bool JSObject::propertyIsEnumerable(ExecState*, const Identifier& propertyName) const
     531bool JSObject::propertyIsEnumerable(ExecState* exec, const Identifier& propertyName) const
    533532{
    534533  unsigned attributes;
    535534 
    536   if (!getPropertyAttributes(propertyName, attributes))
     535  if (!getPropertyAttributes(exec, propertyName, attributes))
    537536    return false;
    538537  else
     
    540539}
    541540
    542 bool JSObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
     541bool JSObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const
    543542{
    544543  if (_prop.get(propertyName, attributes))
     
    546545   
    547546  // Look in the static hashtable of properties
    548   const HashEntry* e = findPropertyHashEntry(propertyName);
     547  const HashEntry* e = findPropertyHashEntry(exec, propertyName);
    549548  if (e) {
    550549    attributes = e->attributes;
     
    561560    // Add properties from the static hashtables of properties
    562561    for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
    563         const HashTable* table = info->propHashTable;
     562        const HashTable* table = info->propHashTable(exec);
    564563        if (!table)
    565564            continue;
  • trunk/JavaScriptCore/kjs/object.h

    r32587 r32652  
    6666    /**
    6767     * Static hash-table of properties.
    68      */
    69     const HashTable* propHashTable;
     68     * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
     69     */
     70    const HashTable* propHashTable(ExecState* exec) const
     71    {
     72        if (classPropHashTableGetterFunction)
     73            return classPropHashTableGetterFunction(exec);
     74        return staticPropHashTable;
     75    }
     76
     77    const HashTable* staticPropHashTable;
     78    typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
     79    const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
    7080  };
    7181 
     
    146156     *
    147157     * \code
    148      *   const ClassInfo BarImp::info = { "Bar", 0, 0 }; // no parent class
    149      *   const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0 };
     158     *   const ClassInfo BarImp::info = { "Bar", 0, 0, 0 }; // no parent class
     159     *   const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0, 0 };
    150160     * \endcode
    151161     *
     
    410420    virtual JSGlobalObject* toGlobalObject(ExecState*) const;
    411421
    412     virtual bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
     422    virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const;
    413423   
    414424    // WebCore uses this to make document.all and style.filter undetectable
     
    444454
    445455  private:
    446     const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const;
     456    const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
    447457    JSValue *_proto;
    448458  };
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r31746 r32652  
    4747    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    4848    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    49     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
    50     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
    51     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
     49    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     50    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     51    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    5252
    5353    // Mozilla extensions
    54     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
    55     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, CommonIdentifiers::shared()->__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
    56     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
    57     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, CommonIdentifiers::shared()->__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
     54    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     55    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     56    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     57    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    5858}
    5959
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r31208 r32652  
    4747// ECMA 15.10.5
    4848
    49 const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0 };
     49const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0, 0 };
    5050
    5151RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
    5252    : JSObject(objectPrototype)
    5353{
    54     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->compile, regExpProtoFuncCompile), DontEnum);
    55     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->exec, regExpProtoFuncExec), DontEnum);
    56     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, CommonIdentifiers::shared()->test, regExpProtoFuncTest), DontEnum);
     54    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
     55    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
     56    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
    5757    putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
    5858}
     
    123123// ------------------------------ RegExpImp ------------------------------------
    124124
    125 const ClassInfo RegExpImp::info = { "RegExp", 0, &RegExpImpTable };
     125const ClassInfo RegExpImp::info = { "RegExp", 0, 0, ExecState::RegExpImpTable };
    126126
    127127/* Source for regexp_object.lut.h
     
    148148bool RegExpImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    149149{
    150   return getStaticValueSlot<RegExpImp, JSObject>(exec, &RegExpImpTable, this, propertyName, slot);
     150  return getStaticValueSlot<RegExpImp, JSObject>(exec, ExecState::RegExpImpTable(exec), this, propertyName, slot);
    151151}
    152152
     
    172172void RegExpImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
    173173{
    174     lookupPut<RegExpImp, JSObject>(exec, propertyName, value, &RegExpImpTable, this);
     174    lookupPut<RegExpImp, JSObject>(exec, propertyName, value, ExecState::RegExpImpTable(exec), this);
    175175}
    176176
     
    243243// ------------------------------ RegExpObjectImp ------------------------------
    244244
    245 const ClassInfo RegExpObjectImp::info = { "Function", &InternalFunctionImp::info, &RegExpObjectImpTable };
     245const ClassInfo RegExpObjectImp::info = { "Function", &InternalFunctionImp::info, 0, ExecState::RegExpObjectImpTable };
    246246
    247247/* Source for regexp_object.lut.h
     
    364364bool RegExpObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    365365{
    366   return getStaticValueSlot<RegExpObjectImp, InternalFunctionImp>(exec, &RegExpObjectImpTable, this, propertyName, slot);
     366  return getStaticValueSlot<RegExpObjectImp, InternalFunctionImp>(exec, ExecState::RegExpObjectImpTable(exec), this, propertyName, slot);
    367367}
    368368
     
    409409void RegExpObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value)
    410410{
    411     lookupPut<RegExpObjectImp, InternalFunctionImp>(exec, propertyName, value, &RegExpObjectImpTable, this);
     411    lookupPut<RegExpObjectImp, InternalFunctionImp>(exec, propertyName, value, ExecState::RegExpObjectImpTable(exec), this);
    412412}
    413413
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r31746 r32652  
    3939// ------------------------------ StringInstance ----------------------------
    4040
    41 const ClassInfo StringInstance::info = { "String", 0, 0 };
     41const ClassInfo StringInstance::info = { "String", 0, 0, 0 };
    4242
    4343StringInstance::StringInstance(JSObject *proto)
     
    126126
    127127// ------------------------------ StringPrototype ---------------------------
    128 const ClassInfo StringPrototype::info = { "String", &StringInstance::info, &stringTable };
     128const ClassInfo StringPrototype::info = { "String", &StringInstance::info, 0, ExecState::stringTable };
    129129/* Source for string_object.lut.h
    130130@begin stringTable 26
     
    174174bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot)
    175175{
    176   return getStaticFunctionSlot<StringInstance>(exec, &stringTable, this, propertyName, slot);
     176  return getStaticFunctionSlot<StringInstance>(exec, ExecState::stringTable(exec), this, propertyName, slot);
    177177}
    178178
Note: See TracChangeset for help on using the changeset viewer.