Changeset 179609 in webkit
- Timestamp:
- Feb 4, 2015, 10:00:05 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSContextRef.cpp
r176973 r179609 139 139 140 140 JSLockHolder locker(vm.get()); 141 vm->makeUsableFromMultipleThreads();142 141 143 142 if (!globalObjectClass) { -
trunk/Source/JavaScriptCore/ChangeLog
r179599 r179609 1 2015-02-04 Mark Lam <mark.lam@apple.com> 2 3 Remove concept of makeUsableFromMultipleThreads(). 4 <https://webkit.org/b/141221> 5 6 Reviewed by Mark Hahnenberg. 7 8 Currently, we rely on VM::makeUsableFromMultipleThreads() being called before we 9 start acquiring the JSLock and entering the VM from different threads. 10 Acquisition of the JSLock will register the acquiring thread with the VM's thread 11 registry if not already registered. However, it will only do this if the VM's 12 thread specific key has been initialized by makeUsableFromMultipleThreads(). 13 14 This is fragile, and also does not read intuitively because one would expect to 15 acquire the JSLock before calling any methods on the VM. This is exactly what 16 JSGlobalContextCreateInGroup() did (i.e. acquire the lock before calling 17 makeUsableFromMultipleThreads()), but is wrong. The result is that the invoking 18 thread will not have been registered with the VM during that first entry into 19 the VM. 20 21 The fix is to make it so that we initialize the VM's thread specific key on 22 construction of the VM's MachineThreads registry instead of relying on 23 makeUsableFromMultipleThreads() being called. With this, we can eliminate 24 makeUsableFromMultipleThreads() altogether. 25 26 Performance results are neutral in aggregate. 27 28 * API/JSContextRef.cpp: 29 (JSGlobalContextCreateInGroup): 30 * heap/MachineStackMarker.cpp: 31 (JSC::MachineThreads::MachineThreads): 32 (JSC::MachineThreads::~MachineThreads): 33 (JSC::MachineThreads::addCurrentThread): 34 (JSC::MachineThreads::removeThread): 35 (JSC::MachineThreads::gatherConservativeRoots): 36 (JSC::MachineThreads::makeUsableFromMultipleThreads): Deleted. 37 * heap/MachineStackMarker.h: 38 * runtime/VM.cpp: 39 (JSC::VM::sharedInstance): 40 * runtime/VM.h: 41 (JSC::VM::makeUsableFromMultipleThreads): Deleted. 42 1 43 2015-02-04 Chris Dumez <cdumez@apple.com> 2 44 -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp
r179576 r179609 124 124 { 125 125 UNUSED_PARAM(heap); 126 threadSpecificKeyCreate(&m_threadSpecific, removeThread); 126 127 } 127 128 128 129 MachineThreads::~MachineThreads() 129 130 { 130 if (m_threadSpecific) 131 threadSpecificKeyDelete(m_threadSpecific); 131 threadSpecificKeyDelete(m_threadSpecific); 132 132 133 133 MutexLocker registeredThreadsLock(m_registeredThreadsMutex); … … 161 161 } 162 162 163 void MachineThreads::makeUsableFromMultipleThreads() 164 { 165 if (m_threadSpecific) 163 void MachineThreads::addCurrentThread() 164 { 165 ASSERT(!m_heap->vm()->hasExclusiveThread() || m_heap->vm()->exclusiveThread() == std::this_thread::get_id()); 166 167 if (threadSpecificGet(m_threadSpecific)) { 168 ASSERT(threadSpecificGet(m_threadSpecific) == this); 166 169 return; 167 168 threadSpecificKeyCreate(&m_threadSpecific, removeThread); 169 } 170 171 void MachineThreads::addCurrentThread() 172 { 173 ASSERT(!m_heap->vm()->hasExclusiveThread() || m_heap->vm()->exclusiveThread() == std::this_thread::get_id()); 174 175 if (!m_threadSpecific || threadSpecificGet(m_threadSpecific)) 176 return; 170 } 177 171 178 172 threadSpecificSet(m_threadSpecific, this); … … 187 181 void MachineThreads::removeThread(void* p) 188 182 { 189 if (p) 190 static_cast<MachineThreads*>(p)->removeCurrentThread(); 183 static_cast<MachineThreads*>(p)->removeCurrentThread(); 191 184 } 192 185 … … 522 515 gatherFromCurrentThread(conservativeRoots, jitStubRoutines, codeBlocks, stackCurrent, currentThreadRegisters); 523 516 524 if (!m_threadSpecific)525 return;526 527 517 size_t size; 528 518 size_t capacity = 0; -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.h
r179576 r179609 45 45 void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackCurrent, RegisterState& registers); 46 46 47 JS_EXPORT_PRIVATE void makeUsableFromMultipleThreads();48 47 JS_EXPORT_PRIVATE void addCurrentThread(); // Only needs to be called by clients that can use the same heap from multiple threads. 49 48 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r179478 r179609 358 358 GlobalJSLock globalLock; 359 359 VM*& instance = sharedInstanceInternal(); 360 if (!instance) {360 if (!instance) 361 361 instance = adoptRef(new VM(APIShared, SmallHeap)).leakRef(); 362 instance->makeUsableFromMultipleThreads();363 }364 362 return *instance; 365 363 } -
trunk/Source/JavaScriptCore/runtime/VM.h
r179478 r179609 218 218 JS_EXPORT_PRIVATE ~VM(); 219 219 220 void makeUsableFromMultipleThreads() { heap.machineThreads().makeUsableFromMultipleThreads(); }221 222 220 private: 223 221 RefPtr<JSLock> m_apiLock; -
trunk/Source/WebCore/ChangeLog
r179604 r179609 1 2015-02-04 Mark Lam <mark.lam@apple.com> 2 3 Remove concept of makeUsableFromMultipleThreads(). 4 <https://webkit.org/b/141221> 5 6 Reviewed by Mark Hahnenberg. 7 8 No new tests. 9 10 * bindings/js/JSDOMWindowBase.cpp: 11 (WebCore::JSDOMWindowBase::commonVM): 12 1 13 2015-02-04 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
r178820 r179609 213 213 #endif 214 214 vm->heap.setIncrementalSweeper(std::make_unique<WebSafeIncrementalSweeper>(&vm->heap)); 215 vm->makeUsableFromMultipleThreads();216 215 vm->heap.machineThreads().addCurrentThread(); 217 216 #endif
Note:
See TracChangeset
for help on using the changeset viewer.