Ignore:
Timestamp:
Aug 20, 2008, 12:23:06 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoff Garen.

Bring back shared JSGlobalData and implicit locking, because too many clients rely on it.

File:
1 edited

Legend:

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

    r35815 r35853  
    3333#include "CommonIdentifiers.h"
    3434#include "JSClassRef.h"
     35#include "JSLock.h"
    3536#include "Machine.h"
    3637#include "Parser.h"
     
    5657extern const HashTable stringTable;
    5758
    58 JSGlobalData::JSGlobalData()
     59JSGlobalData::JSGlobalData(bool isShared)
    5960    : machine(new Machine)
    6061    , heap(new Heap(this))
     
    8586    , parser(new Parser)
    8687    , head(0)
     88    , isSharedInstance(isShared)
    8789{
    8890}
     
    9193{
    9294    delete heap;
    93     heap = 0; // zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
    9495    delete machine;
     96#ifndef NDEBUG
     97    // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
     98    heap = 0;
    9599    machine = 0;
     100#endif
    96101
    97102#if ENABLE(JSC_MULTIPLE_THREADS)
     
    132137}
    133138
     139bool JSGlobalData::sharedInstanceExists()
     140{
     141    return sharedInstanceInternal();
    134142}
     143
     144JSGlobalData& JSGlobalData::sharedInstance()
     145{
     146    JSGlobalData*& instance = sharedInstanceInternal();
     147    if (!instance)
     148        instance = new JSGlobalData(true);
     149    return *instance;
     150}
     151
     152JSGlobalData*& JSGlobalData::sharedInstanceInternal()
     153{
     154    ASSERT(JSLock::currentThreadIsHoldingLock());
     155    static JSGlobalData* sharedInstance;
     156    return sharedInstance;
     157}
     158
     159}
Note: See TracChangeset for help on using the changeset viewer.