Changeset 58133 in webkit
- Timestamp:
- Apr 22, 2010 5:11:37 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/APIShims.h
r57879 r58133 67 67 APIEntryShim(JSGlobalData* globalData, bool registerThread = true) 68 68 : APIEntryShimWithoutLock(globalData, registerThread) 69 , m_lock(globalData->isSharedInstance ? LockForReal : SilenceAssertionsOnly)69 , m_lock(globalData->isSharedInstance() ? LockForReal : SilenceAssertionsOnly) 70 70 { 71 71 } -
trunk/JavaScriptCore/API/JSContextRef.cpp
r58012 r58133 47 47 { 48 48 initializeThreading(); 49 return toRef(JSGlobalData::create NonDefault(ThreadStackTypeSmall).releaseRef());49 return toRef(JSGlobalData::createContextGroup(ThreadStackTypeSmall).releaseRef()); 50 50 } 51 51 … … 85 85 86 86 JSLock lock(LockForReal); 87 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create NonDefault(ThreadStackTypeSmall);87 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createContextGroup(ThreadStackTypeSmall); 88 88 89 89 APIEntryShim entryShim(globalData.get(), false); -
trunk/JavaScriptCore/ChangeLog
r58118 r58133 1 2010-04-22 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Geoff Garen. 4 5 https://bugs.webkit.org/show_bug.cgi?id=38006 6 Change lifetime of JSC::IdentifierTables used by WebCores to match AtomicStringTable 7 8 Presently JSC's IdentifierTables are owned by the JSGlobalData. For 9 JSGlobalData objects created via the API this should continue to be the case, 10 but for the JSGlobalData objects used by WebCore (the main thread's common 11 global data, and those for workers) use a IdentifierTable provided (and owned) 12 by wtfThreadData. This allow the lifetime of these IdentifierTable to match 13 those of the corresponding AtomicStringTables. 14 15 * API/APIShims.h: 16 (JSC::APIEntryShim::APIEntryShim): 17 * API/JSContextRef.cpp: 18 (JSContextGroupCreate): 19 * runtime/Collector.cpp: 20 (JSC::Heap::protect): 21 (JSC::Heap::unprotect): 22 (JSC::Heap::markRoots): 23 * runtime/JSGlobalData.cpp: 24 (JSC::JSGlobalData::JSGlobalData): 25 (JSC::JSGlobalData::~JSGlobalData): 26 (JSC::JSGlobalData::createContextGroup): 27 (JSC::JSGlobalData::create): 28 (JSC::JSGlobalData::sharedInstance): 29 * runtime/JSGlobalData.h: 30 (JSC::JSGlobalData::): 31 (JSC::JSGlobalData::isSharedInstance): 32 * runtime/JSLock.cpp: 33 (JSC::JSLock::JSLock): 34 (JSC::JSLock::lock): 35 (JSC::JSLock::unlock): 36 (JSC::JSLock::DropAllLocks::DropAllLocks): 37 * wtf/WTFThreadData.cpp: 38 (WTF::WTFThreadData::WTFThreadData): 39 (WTF::WTFThreadData::~WTFThreadData): 40 1 41 2010-04-22 Sheriff Bot <webkit.review.bot@gmail.com> 2 42 -
trunk/JavaScriptCore/runtime/Collector.cpp
r58012 r58133 973 973 { 974 974 ASSERT(k); 975 ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance);975 // ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance()); 976 976 977 977 if (!k.isCell()) … … 984 984 { 985 985 ASSERT(k); 986 ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance);986 // ASSERT(JSLock::currentThreadIsHoldingLock() || !m_globalData->isSharedInstance()); 987 987 988 988 if (!k.isCell()) … … 1065 1065 { 1066 1066 #ifndef NDEBUG 1067 if (m_globalData->isSharedInstance ) {1067 if (m_globalData->isSharedInstance()) { 1068 1068 ASSERT(JSLock::lockCount() > 0); 1069 1069 ASSERT(JSLock::currentThreadIsHoldingLock()); -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r58114 r58133 104 104 } 105 105 106 JSGlobalData::JSGlobalData( bool isShared, ThreadStackType threadStackType)107 : isSharedInstance(isShared)106 JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType threadStackType) 107 : globalDataType(globalDataType) 108 108 , clientData(0) 109 109 , arrayTable(fastNew<HashTable>(JSC::arrayTable)) … … 129 129 , numberStructure(JSNumberCell::createStructure(jsNull())) 130 130 #endif 131 , identifierTable( createIdentifierTable())131 , identifierTable(globalDataType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable()) 132 132 , literalTable(createLiteralTable()) 133 133 , propertyNames(new CommonIdentifiers(this)) … … 194 194 195 195 delete propertyNames; 196 deleteIdentifierTable(identifierTable); 196 if (globalDataType != Default) 197 deleteIdentifierTable(identifierTable); 197 198 deleteLiteralTable(literalTable); 198 199 … … 200 201 } 201 202 202 PassRefPtr<JSGlobalData> JSGlobalData::create NonDefault(ThreadStackType type)203 { 204 return adoptRef(new JSGlobalData( false, type));203 PassRefPtr<JSGlobalData> JSGlobalData::createContextGroup(ThreadStackType type) 204 { 205 return adoptRef(new JSGlobalData(APIContextGroup, type)); 205 206 } 206 207 207 208 PassRefPtr<JSGlobalData> JSGlobalData::create(ThreadStackType type) 208 209 { 209 JSGlobalData* globalData = new JSGlobalData(false, type); 210 wtfThreadData().initializeIdentifierTable(globalData->identifierTable); 211 return adoptRef(globalData); 210 return adoptRef(new JSGlobalData(Default, type)); 212 211 } 213 212 … … 229 228 JSGlobalData*& instance = sharedInstanceInternal(); 230 229 if (!instance) { 231 instance = new JSGlobalData( true, ThreadStackTypeSmall);230 instance = new JSGlobalData(APIShared, ThreadStackTypeSmall); 232 231 #if ENABLE(JSC_MULTIPLE_THREADS) 233 232 instance->makeUsableFromMultipleThreads(); -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r58114 r58133 93 93 class JSGlobalData : public RefCounted<JSGlobalData> { 94 94 public: 95 // WebCore has a one-to-one mapping of threads to JSGlobalDatas; 96 // either create() or createLeaked() should only be called once 97 // on a thread, this is the 'default' JSGlobalData (it uses the 98 // thread's default string uniquing table from wtfThreadData). 99 // API contexts created using the new context group aware interface 100 // create APIContextGroup objects which require less locking of JSC 101 // than the old singleton APIShared JSGlobalData created for use by 102 // the original API. 103 enum GlobalDataType { Default, APIContextGroup, APIShared }; 104 95 105 struct ClientData { 96 106 virtual ~ClientData() = 0; 97 107 }; 98 108 109 bool isSharedInstance() { return globalDataType == APIShared; } 99 110 static bool sharedInstanceExists(); 100 111 static JSGlobalData& sharedInstance(); … … 102 113 static PassRefPtr<JSGlobalData> create(ThreadStackType); 103 114 static PassRefPtr<JSGlobalData> createLeaked(ThreadStackType); 104 static PassRefPtr<JSGlobalData> create NonDefault(ThreadStackType);115 static PassRefPtr<JSGlobalData> createContextGroup(ThreadStackType); 105 116 ~JSGlobalData(); 106 117 … … 110 121 #endif 111 122 112 bool isSharedInstance;123 GlobalDataType globalDataType; 113 124 ClientData* clientData; 114 125 … … 206 217 void dumpSampleData(ExecState* exec); 207 218 private: 208 JSGlobalData( bool isShared, ThreadStackType);219 JSGlobalData(GlobalDataType, ThreadStackType); 209 220 static JSGlobalData*& sharedInstanceInternal(); 210 221 void createNativeThunk(); -
trunk/JavaScriptCore/runtime/JSLock.cpp
r46436 r58133 61 61 62 62 JSLock::JSLock(ExecState* exec) 63 : m_lockBehavior(exec->globalData().isSharedInstance ? LockForReal : SilenceAssertionsOnly)63 : m_lockBehavior(exec->globalData().isSharedInstance() ? LockForReal : SilenceAssertionsOnly) 64 64 { 65 65 lock(m_lockBehavior); … … 106 106 void JSLock::lock(ExecState* exec) 107 107 { 108 lock(exec->globalData().isSharedInstance ? LockForReal : SilenceAssertionsOnly);108 lock(exec->globalData().isSharedInstance() ? LockForReal : SilenceAssertionsOnly); 109 109 } 110 110 111 111 void JSLock::unlock(ExecState* exec) 112 112 { 113 unlock(exec->globalData().isSharedInstance ? LockForReal : SilenceAssertionsOnly);113 unlock(exec->globalData().isSharedInstance() ? LockForReal : SilenceAssertionsOnly); 114 114 } 115 115 … … 163 163 164 164 JSLock::DropAllLocks::DropAllLocks(ExecState* exec) 165 : m_lockBehavior(exec->globalData().isSharedInstance ? LockForReal : SilenceAssertionsOnly)165 : m_lockBehavior(exec->globalData().isSharedInstance() ? LockForReal : SilenceAssertionsOnly) 166 166 { 167 167 pthread_once(&createJSLockCountOnce, createJSLockCount); -
trunk/JavaScriptCore/wtf/WTFThreadData.cpp
r58114 r58133 40 40 : m_atomicStringTable(new WebCore::AtomicStringTable()) 41 41 #if USE(JSC) 42 , m_defaultIdentifierTable( 0)43 , m_currentIdentifierTable( 0)42 , m_defaultIdentifierTable(new JSC::IdentifierTable()) 43 , m_currentIdentifierTable(m_defaultIdentifierTable) 44 44 #endif 45 45 { … … 49 49 { 50 50 delete m_atomicStringTable; 51 #if USE(JSC) 52 delete m_defaultIdentifierTable; 53 #endif 51 54 } 52 55
Note: See TracChangeset
for help on using the changeset viewer.