Show
Ignore:
Timestamp:
08/20/08 13:23:52 (5 months ago)
Author:
mbensi
Message:

merge with webkit revision 35853

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/JavaScriptCore/kjs/JSGlobalData.cpp

    r427 r447  
    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) 
     
    118123    delete opaqueJSClassData; 
    119124 
     125    delete emptyList; 
     126 
    120127    delete propertyNames; 
    121128    deleteIdentifierTable(identifierTable); 
     
    130137} 
    131138 
     139bool JSGlobalData::sharedInstanceExists() 
     140{ 
     141    return sharedInstanceInternal(); 
    132142} 
     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}