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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.