Changeset 161161 in webkit
- Timestamp:
- Dec 30, 2013 5:22:01 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r161159 r161161 1 2013-12-30 Anders Carlsson <andersca@apple.com> 2 3 Stop using ThreadCondition in BlockAllocator 4 https://bugs.webkit.org/show_bug.cgi?id=126313 5 6 Reviewed by Sam Weinig. 7 8 * heap/BlockAllocator.cpp: 9 (JSC::BlockAllocator::~BlockAllocator): 10 (JSC::BlockAllocator::waitForDuration): 11 (JSC::BlockAllocator::blockFreeingThreadMain): 12 * heap/BlockAllocator.h: 13 (JSC::BlockAllocator::deallocate): 14 1 15 2013-12-30 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp
r157537 r161161 62 62 releaseFreeRegions(); 63 63 { 64 MutexLocker locker(m_emptyRegionConditionLock);64 std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex); 65 65 m_blockFreeingThreadShouldQuit = true; 66 m_emptyRegionCondition. broadcast();66 m_emptyRegionCondition.notify_all(); 67 67 } 68 68 if (m_blockFreeingThread) … … 102 102 } 103 103 104 void BlockAllocator::waitFor RelativeTimeWhileHoldingLock(double relative)104 void BlockAllocator::waitForDuration(std::chrono::milliseconds duration) 105 105 { 106 std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex); 107 108 // If this returns early, that's fine, so long as it doesn't do it too 109 // frequently. It would only be a bug if this function failed to return 110 // when it was asked to do so. 106 111 if (m_blockFreeingThreadShouldQuit) 107 112 return; 108 113 109 m_emptyRegionCondition.timedWait(m_emptyRegionConditionLock, currentTime() + relative); 110 } 111 112 void BlockAllocator::waitForRelativeTime(double relative) 113 { 114 // If this returns early, that's fine, so long as it doesn't do it too 115 // frequently. It would only be a bug if this function failed to return 116 // when it was asked to do so. 117 118 MutexLocker locker(m_emptyRegionConditionLock); 119 waitForRelativeTimeWhileHoldingLock(relative); 114 m_emptyRegionCondition.wait_for(lock, duration); 120 115 } 121 116 … … 131 126 // Generally wait for one second before scavenging free blocks. This 132 127 // may return early, particularly when we're being asked to quit. 133 waitFor RelativeTime(1.0);128 waitForDuration(std::chrono::seconds(1)); 134 129 if (m_blockFreeingThreadShouldQuit) 135 130 break; … … 142 137 // Sleep until there is actually work to do rather than waking up every second to check. 143 138 { 144 MutexLocker locker(m_emptyRegionConditionLock);139 std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex); 145 140 SpinLockHolder regionLocker(&m_regionLock); 146 141 while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) { 147 142 m_regionLock.Unlock(); 148 m_emptyRegionCondition.wait( m_emptyRegionConditionLock);143 m_emptyRegionCondition.wait(lock); 149 144 m_regionLock.Lock(); 150 145 } -
trunk/Source/JavaScriptCore/heap/BlockAllocator.h
r157653 r161161 30 30 #include "HeapBlock.h" 31 31 #include "Region.h" 32 #include <mutex> 32 33 #include <wtf/DoublyLinkedList.h> 33 34 #include <wtf/Forward.h> … … 61 62 62 63 private: 63 void waitForRelativeTimeWhileHoldingLock(double relative); 64 void waitForRelativeTime(double relative); 64 void waitForDuration(std::chrono::milliseconds); 65 65 66 66 friend ThreadIdentifier createBlockFreeingThread(BlockAllocator*); … … 106 106 bool m_blockFreeingThreadShouldQuit; 107 107 SpinLock m_regionLock; 108 Mutex m_emptyRegionConditionLock;109 ThreadConditionm_emptyRegionCondition;108 std::mutex m_emptyRegionConditionMutex; 109 std::condition_variable m_emptyRegionCondition; 110 110 ThreadIdentifier m_blockFreeingThread; 111 111 }; … … 200 200 201 201 if (shouldWakeBlockFreeingThread) { 202 MutexLocker mutexLocker(m_emptyRegionConditionLock);203 m_emptyRegionCondition. signal();202 std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex); 203 m_emptyRegionCondition.notify_one(); 204 204 } 205 205
Note: See TracChangeset
for help on using the changeset viewer.