Changeset 163820 in webkit
- Timestamp:
- Feb 10, 2014 2:27:10 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r163815 r163820 1 2014-02-10 Mark Lam <mark.lam@apple.com> 2 3 Change JSLock::dropAllLocks() and friends to use lock() and unlock(). 4 <https://webkit.org/b/128451> 5 6 Reviewed by Geoffrey Garen. 7 8 Currently, JSLock's dropAllLocks(), dropAllLocksUnconditionally(), and 9 grabAllLocks() implement locking / unlocking by duplicating the code from 10 lock() and unlock(). Instead, they should just call lock() and unlock(). 11 12 * runtime/JSLock.cpp: 13 (JSC::JSLock::lock): 14 (JSC::JSLock::unlock): 15 - Modified lock() and unlock() into a version that takes an entry count 16 to lock / unlock. The previous lock() and unlock() now calls these 17 new versions with an entry count of 1. 18 19 (JSC::JSLock::dropAllLocks): 20 (JSC::JSLock::dropAllLocksUnconditionally): 21 (JSC::JSLock::grabAllLocks): 22 - Delegate to unlock() and lock() instead of duplicating the lock / unlock 23 code. 24 - There a some differences with calling lock() instead of duplicating its 25 code in grabAllLock() i.e. lock() does the following additional work: 26 27 1. lock() does a re-entry check that is not needed by grabAllLocks(). 28 However, this is effectively a no-op since we never own the JSLock 29 before calling grabAllLocks(). 30 31 2. set VM stackPointerAtVMEntry. 32 3. update VM stackLimit and reservedZoneSize. 33 4. set VM lastStackTop. 34 These 3 steps are just busy work which are also effective no-ops 35 because immediately after lock() returns, grabAllLocks() will write 36 over those values with their saved versions in the threadData. 37 38 * runtime/JSLock.h: 39 1 40 2014-02-10 Anders Carlsson <andersca@apple.com> 2 41 -
trunk/Source/JavaScriptCore/runtime/JSLock.cpp
r163804 r163820 101 101 void JSLock::lock() 102 102 { 103 lock(1); 104 } 105 106 void JSLock::lock(intptr_t lockCount) 107 { 108 ASSERT(lockCount > 0); 103 109 ThreadIdentifier currentThread = WTF::currentThread(); 104 110 if (currentThreadIsHoldingLock()) { 105 m_lockCount ++;111 m_lockCount += lockCount; 106 112 return; 107 113 } … … 111 117 setOwnerThread(currentThread); 112 118 ASSERT(!m_lockCount); 113 m_lockCount = 1;119 m_lockCount = lockCount; 114 120 115 121 WTFThreadData& threadData = wtfThreadData(); … … 126 132 void JSLock::unlock() 127 133 { 134 unlock(1); 135 } 136 137 void JSLock::unlock(intptr_t unlockCount) 138 { 128 139 RELEASE_ASSERT(currentThreadIsHoldingLock()); 129 130 m_lockCount--; 140 ASSERT(m_lockCount >= unlockCount); 141 142 m_lockCount -= unlockCount; 131 143 132 144 if (!m_lockCount) { … … 219 231 220 232 unsigned droppedLockCount = m_lockCount; 221 m_lockCount = 0; 222 if (m_vm) { 223 m_vm->stackPointerAtVMEntry = nullptr; 224 m_vm->updateStackLimitWithReservedZoneSize(wtfThreadData().savedReservedZoneSize()); 225 } 226 setOwnerThread(0); 227 m_lock.unlock(); 233 unlock(droppedLockCount); 234 228 235 return droppedLockCount; 229 236 } … … 245 252 246 253 unsigned droppedLockCount = m_lockCount; 247 m_lockCount = 0; 248 if (m_vm) { 249 m_vm->stackPointerAtVMEntry = nullptr; 250 m_vm->updateStackLimitWithReservedZoneSize(wtfThreadData().savedReservedZoneSize()); 251 } 252 setOwnerThread(0); 253 m_lock.unlock(); 254 unlock(droppedLockCount); 255 254 256 return droppedLockCount; 255 257 } … … 262 264 263 265 ASSERT(!currentThreadIsHoldingLock()); 264 265 m_lock.lock(); 266 267 setOwnerThread(WTF::currentThread()); 268 ASSERT(!m_lockCount); 269 m_lockCount = droppedLockCount; 266 lock(droppedLockCount); 267 270 268 --m_lockDropDepth; 271 269 -
trunk/Source/JavaScriptCore/runtime/JSLock.h
r163804 r163820 113 113 114 114 private: 115 void lock(intptr_t lockCount); 116 void unlock(intptr_t unlockCount); 115 117 void setOwnerThread(ThreadIdentifier owner) { m_ownerThread = owner; } 116 118
Note: See TracChangeset
for help on using the changeset viewer.