bool JSLock::currentThreadIsHoldingLock() { ASSERT(!m_hasExclusiveThread || (exclusiveThread() == std::this_thread::get_id())); if (m_hasExclusiveThread) return !!m_lockCount; return m_ownerThreadID == std::this_thread::get_id(); }
// This function returns the number of locks that were dropped. unsigned JSLock::dropAllLocks(DropAllLocks* dropper) { if (m_hasExclusiveThread) { ASSERT(exclusiveThread() == std::this_thread::get_id()); return 0; } // Check if this thread is currently holding the lock. // FIXME: Maybe we want to require this, guard with an ASSERT? if (!currentThreadIsHoldingLock()) return 0; ++m_lockDropDepth; dropper->setDropDepth(m_lockDropDepth); WTFThreadData& threadData = wtfThreadData(); threadData.setSavedStackPointerAtVMEntry(m_vm->stackPointerAtVMEntry()); threadData.setSavedLastStackTop(m_vm->lastStackTop()); unsigned droppedLockCount = m_lockCount; unlock(droppedLockCount); return droppedLockCount; }
// This function returns the number of locks that were dropped. unsigned JSLock::dropAllLocks(DropAllLocks* dropper) { if (m_hasExclusiveThread) { ASSERT(exclusiveThread() == std::this_thread::get_id()); return 0; } if (!currentThreadIsHoldingLock()) return 0; ++m_lockDropDepth; dropper->setDropDepth(m_lockDropDepth); WTFThreadData& threadData = wtfThreadData(); threadData.setSavedStackPointerAtVMEntry(m_vm->stackPointerAtVMEntry()); threadData.setSavedLastStackTop(m_vm->lastStackTop()); unsigned droppedLockCount = m_lockCount; unlock(droppedLockCount); return droppedLockCount; }