Changeset 34977 in webkit for trunk/JavaScriptCore/kjs/JSGlobalData.cpp
- Timestamp:
- Jul 3, 2008, 12:44:43 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalData.cpp
r34974 r34977 32 32 #include "collector.h" 33 33 #include "CommonIdentifiers.h" 34 #include "JSLock.h" 34 35 #include "lexer.h" 35 36 #include "list.h" … … 120 121 } 121 122 123 bool JSGlobalData::threadInstanceExists() 124 { 125 return threadInstanceInternal(); 126 } 127 128 bool JSGlobalData::sharedInstanceExists() 129 { 130 return sharedInstanceInternal(); 131 } 132 122 133 JSGlobalData& JSGlobalData::threadInstance() 123 134 { 124 #if USE(MULTIPLE_THREADS) 125 static ThreadSpecific<JSGlobalData> sharedInstance; 126 return *sharedInstance; 127 #else 128 static JSGlobalData sharedInstance; 129 return sharedInstance; 130 #endif 135 JSGlobalData*& instance = threadInstanceInternal(); 136 if (!instance) 137 instance = new JSGlobalData; 138 return *instance; 131 139 } 132 140 133 141 JSGlobalData& JSGlobalData::sharedInstance() 134 142 { 143 JSGlobalData*& instance = sharedInstanceInternal(); 144 if (!instance) 145 instance = new JSGlobalData(true); 146 return *instance; 147 } 148 149 JSGlobalData*& JSGlobalData::threadInstanceInternal() 150 { 135 151 #if USE(MULTIPLE_THREADS) 136 MutexLocker locker(*atomicallyInitializedStaticMutex); 152 static ThreadSpecific<DataInstance> threadInstance; 153 return *threadInstance; 154 #else 155 static JSGlobalData threadInstance; 156 return &threadInstance; 137 157 #endif 158 } 159 160 JSGlobalData*& JSGlobalData::sharedInstanceInternal() 161 { 162 ASSERT(JSLock::currentThreadIsHoldingLock()); 138 163 static JSGlobalData* sharedInstance; 139 if (!sharedInstance) 140 sharedInstance = new JSGlobalData(true); 141 return *sharedInstance; 164 return sharedInstance; 142 165 } 143 166
Note:
See TracChangeset
for help on using the changeset viewer.