Changeset 164683 in webkit
- Timestamp:
- Feb 25, 2014 5:03:37 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/APIShims.h
r164667 r164683 59 59 APIEntryShim(ExecState* exec, bool registerThread = true) 60 60 : APIEntryShimWithoutLock(&exec->vm(), registerThread) 61 , m_lockHolder( exec->vm().exclusiveThread ? 0 : exec)61 , m_lockHolder(&exec->vm()) 62 62 { 63 63 } … … 65 65 APIEntryShim(VM* vm, bool registerThread = true) 66 66 : APIEntryShimWithoutLock(vm, registerThread) 67 , m_lockHolder(vm ->exclusiveThread ? 0 : vm)67 , m_lockHolder(vm) 68 68 { 69 69 } … … 103 103 static bool shouldDropAllLocks(VM& vm) 104 104 { 105 if (vm.exclusiveThread)106 return false;107 108 105 // If the VM is in the middle of being destroyed then we don't want to resurrect it 109 106 // by allowing DropAllLocks to ref it. By this point the APILock has already been -
trunk/Source/JavaScriptCore/ChangeLog
r164673 r164683 1 2014-02-25 Mark Lam <mark.lam@apple.com> 2 3 Need to initialize VM stack data even when the VM is on an exclusive thread. 4 <https://webkit.org/b/129265> 5 6 Not reviewed. 7 8 Relanding r164627 now that <https://webkit.org/b/129341> is fixed. 9 10 * API/APIShims.h: 11 (JSC::APIEntryShim::APIEntryShim): 12 (JSC::APICallbackShim::shouldDropAllLocks): 13 * heap/MachineStackMarker.cpp: 14 (JSC::MachineThreads::addCurrentThread): 15 * runtime/JSLock.cpp: 16 (JSC::JSLockHolder::JSLockHolder): 17 (JSC::JSLockHolder::init): 18 (JSC::JSLockHolder::~JSLockHolder): 19 (JSC::JSLock::JSLock): 20 (JSC::JSLock::setExclusiveThread): 21 (JSC::JSLock::lock): 22 (JSC::JSLock::unlock): 23 (JSC::JSLock::currentThreadIsHoldingLock): 24 (JSC::JSLock::dropAllLocks): 25 (JSC::JSLock::grabAllLocks): 26 * runtime/JSLock.h: 27 (JSC::JSLock::hasExclusiveThread): 28 (JSC::JSLock::exclusiveThread): 29 * runtime/VM.cpp: 30 (JSC::VM::VM): 31 * runtime/VM.h: 32 (JSC::VM::hasExclusiveThread): 33 (JSC::VM::exclusiveThread): 34 (JSC::VM::setExclusiveThread): 35 (JSC::VM::currentThreadIsHoldingAPILock): 36 1 37 2014-02-25 Filip Pizlo <fpizlo@apple.com> 2 38 -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp
r164667 r164683 183 183 void MachineThreads::addCurrentThread() 184 184 { 185 ASSERT(!m_heap->vm()-> exclusiveThread || m_heap->vm()->exclusiveThread == currentThread());185 ASSERT(!m_heap->vm()->hasExclusiveThread() || m_heap->vm()->exclusiveThread() == std::this_thread::get_id()); 186 186 187 187 if (!m_threadSpecific || threadSpecificGet(m_threadSpecific)) -
trunk/Source/JavaScriptCore/runtime/JSLock.cpp
r164667 r164683 51 51 52 52 JSLockHolder::JSLockHolder(ExecState* exec) 53 : m_vm( exec ? &exec->vm() : 0)53 : m_vm(&exec->vm()) 54 54 { 55 55 init(); … … 70 70 void JSLockHolder::init() 71 71 { 72 if (m_vm) 73 m_vm->apiLock().lock(); 72 m_vm->apiLock().lock(); 74 73 } 75 74 76 75 JSLockHolder::~JSLockHolder() 77 76 { 78 if (!m_vm)79 return;80 81 77 RefPtr<JSLock> apiLock(&m_vm->apiLock()); 82 78 m_vm.clear(); … … 85 81 86 82 JSLock::JSLock(VM* vm) 87 : m_lockCount(0) 83 : m_ownerThreadID(std::thread::id()) 84 , m_lockCount(0) 88 85 , m_lockDropDepth(0) 86 , m_hasExclusiveThread(false) 89 87 , m_vm(vm) 90 88 { … … 99 97 ASSERT_UNUSED(vm, m_vm == vm); 100 98 m_vm = 0; 99 } 100 101 void JSLock::setExclusiveThread(std::thread::id threadId) 102 { 103 RELEASE_ASSERT(!m_lockCount && m_ownerThreadID == std::thread::id()); 104 m_hasExclusiveThread = (threadId != std::thread::id()); 105 m_ownerThreadID = threadId; 101 106 } 102 107 … … 114 119 } 115 120 116 m_lock.lock(); 117 118 m_ownerThreadID = std::this_thread::get_id(); 121 if (!m_hasExclusiveThread) { 122 m_lock.lock(); 123 m_ownerThreadID = std::this_thread::get_id(); 124 } 119 125 ASSERT(!m_lockCount); 120 126 m_lockCount = lockCount; … … 122 128 if (!m_vm) 123 129 return; 124 125 WTFThreadData& threadData = wtfThreadData();126 130 127 131 RELEASE_ASSERT(!m_vm->stackPointerAtVMEntry()); … … 129 133 m_vm->setStackPointerAtVMEntry(p); 130 134 135 WTFThreadData& threadData = wtfThreadData(); 131 136 m_vm->setLastStackTop(threadData.savedLastStackTop()); 132 137 } … … 147 152 if (m_vm) 148 153 m_vm->setStackPointerAtVMEntry(nullptr); 149 m_ownerThreadID = std::thread::id(); 150 m_lock.unlock(); 154 155 if (!m_hasExclusiveThread) { 156 m_ownerThreadID = std::thread::id(); 157 m_lock.unlock(); 158 } 151 159 } 152 160 } … … 164 172 bool JSLock::currentThreadIsHoldingLock() 165 173 { 174 ASSERT(!m_hasExclusiveThread || (exclusiveThread() == std::this_thread::get_id())); 175 if (m_hasExclusiveThread) 176 return !!m_lockCount; 166 177 return m_ownerThreadID == std::this_thread::get_id(); 167 178 } … … 170 181 unsigned JSLock::dropAllLocks(DropAllLocks* dropper) 171 182 { 183 if (m_hasExclusiveThread) { 184 ASSERT(exclusiveThread() == std::this_thread::get_id()); 185 return 0; 186 } 187 172 188 // Check if this thread is currently holding the lock. 173 189 // FIXME: Maybe we want to require this, guard with an ASSERT? … … 194 210 void JSLock::grabAllLocks(DropAllLocks* dropper, unsigned droppedLockCount) 195 211 { 212 ASSERT(!m_hasExclusiveThread || !droppedLockCount); 213 196 214 // If no locks were dropped, nothing to do! 197 215 if (!droppedLockCount) -
trunk/Source/JavaScriptCore/runtime/JSLock.h
r164667 r164683 95 95 VM* vm() { return m_vm; } 96 96 97 bool hasExclusiveThread() const { return m_hasExclusiveThread; } 98 std::thread::id exclusiveThread() const 99 { 100 ASSERT(m_hasExclusiveThread); 101 return m_ownerThreadID; 102 } 103 JS_EXPORT_PRIVATE void setExclusiveThread(std::thread::id); 97 104 JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock(); 98 105 … … 130 137 intptr_t m_lockCount; 131 138 unsigned m_lockDropDepth; 139 bool m_hasExclusiveThread; 132 140 VM* m_vm; 133 141 }; -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r164667 r164683 209 209 , m_rtTraceList(new RTTraceList()) 210 210 #endif 211 , exclusiveThread(0)212 211 , m_newStringsSinceLastHashCons(0) 213 212 #if ENABLE(ASSEMBLER) -
trunk/Source/JavaScriptCore/runtime/VM.h
r164667 r164683 464 464 #endif 465 465 466 ThreadIdentifier exclusiveThread; 466 bool hasExclusiveThread() const { return m_apiLock->hasExclusiveThread(); } 467 std::thread::id exclusiveThread() const { return m_apiLock->exclusiveThread(); } 468 void setExclusiveThread(std::thread::id threadId) { m_apiLock->setExclusiveThread(threadId); } 467 469 468 470 JS_EXPORT_PRIVATE void resetDateCache(); … … 492 494 void resetNewStringsSinceLastHashCons() { m_newStringsSinceLastHashCons = 0; } 493 495 494 bool currentThreadIsHoldingAPILock() const 495 { 496 return m_apiLock->currentThreadIsHoldingLock() || exclusiveThread == currentThread(); 497 } 496 bool currentThreadIsHoldingAPILock() const { return m_apiLock->currentThreadIsHoldingLock(); } 498 497 499 498 JSLock& apiLock() { return *m_apiLock; } -
trunk/Source/WebCore/ChangeLog
r164679 r164683 1 2014-02-25 Mark Lam <mark.lam@apple.com> 2 3 Need to initialize VM stack data even when the VM is on an exclusive thread. 4 <https://webkit.org/b/129265> 5 6 Not reviewed. 7 8 No new tests. 9 10 Relanding r164627 now that <https://webkit.org/b/129341> is fixed. 11 12 * bindings/js/JSDOMBinding.cpp: 13 (WebCore::reportException): 14 * bindings/js/JSDOMWindowBase.cpp: 15 (WebCore::JSDOMWindowBase::commonVM): 16 1 17 2014-02-25 Mark Lam <mark.lam@apple.com> 2 18 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r164667 r164683 154 154 void reportException(ExecState* exec, JSValue exception, CachedScript* cachedScript) 155 155 { 156 RELEASE_ASSERT(exec->vm().currentThreadIsHoldingAPILock()); 156 157 if (isTerminatedExecutionException(exception)) 157 158 return; -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
r164667 r164683 225 225 vm->heap.machineThreads().addCurrentThread(); 226 226 #else 227 vm-> exclusiveThread = currentThread();227 vm->setExclusiveThread(std::this_thread::get_id()); 228 228 #endif // !PLATFORM(IOS) 229 229 initNormalWorldClientData(vm);
Note: See TracChangeset
for help on using the changeset viewer.