Changeset 244497 in webkit
- Timestamp:
- Apr 21, 2019 11:44:25 PM (5 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r244481 r244497 1 2019-04-21 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [bmalloc] Use StaticPerProcess' mutex as bmalloc::Heap does with PerProcess 4 https://bugs.webkit.org/show_bug.cgi?id=197135 5 6 Reviewed by Darin Adler. 7 8 This patch leverages StaticPerProcess::mutex() for per process instance's lock in various classes, 9 as Heap does with PerProcess::mutex(). 10 11 * bmalloc/AllIsoHeaps.cpp: 12 (bmalloc::AllIsoHeaps::add): 13 (bmalloc::AllIsoHeaps::head): 14 * bmalloc/AllIsoHeaps.h: 15 * bmalloc/CryptoRandom.cpp: 16 (bmalloc::ARC4RandomNumberGenerator::randomValues): 17 * bmalloc/DebugHeap.cpp: 18 (bmalloc::DebugHeap::memalignLarge): 19 (bmalloc::DebugHeap::freeLarge): 20 * bmalloc/DebugHeap.h: 21 * bmalloc/Scavenger.cpp: 22 (bmalloc::Scavenger::run): 23 (bmalloc::Scavenger::runSoon): 24 (bmalloc::Scavenger::scheduleIfUnderMemoryPressure): 25 (bmalloc::Scavenger::schedule): 26 (bmalloc::Scavenger::timeSinceLastFullScavenge): 27 (bmalloc::Scavenger::scavenge): 28 (bmalloc::Scavenger::threadRunLoop): 29 * bmalloc/Scavenger.h: 30 1 31 2019-04-19 Yusuke Suzuki <ysuzuki@apple.com> 2 32 -
trunk/Source/bmalloc/bmalloc/AllIsoHeaps.cpp
r242938 r244497 36 36 void AllIsoHeaps::add(IsoHeapImplBase* heap) 37 37 { 38 std::lock_guard<Mutex> locker(m _lock);38 std::lock_guard<Mutex> locker(mutex()); 39 39 heap->m_next = m_head; 40 40 m_head = heap; … … 43 43 IsoHeapImplBase* AllIsoHeaps::head() 44 44 { 45 std::lock_guard<Mutex> locker(m _lock);45 std::lock_guard<Mutex> locker(mutex()); 46 46 return m_head; 47 47 } -
trunk/Source/bmalloc/bmalloc/AllIsoHeaps.h
r242938 r244497 43 43 44 44 private: 45 Mutex m_lock;46 45 IsoHeapImplBase* m_head { nullptr }; 47 46 }; -
trunk/Source/bmalloc/bmalloc/CryptoRandom.cpp
r242938 r244497 75 75 ARC4Stream m_stream; 76 76 int m_count; 77 Mutex m_mutex;78 77 }; 79 78 DECLARE_STATIC_PER_PROCESS_STORAGE(ARC4RandomNumberGenerator); … … 166 165 void ARC4RandomNumberGenerator::randomValues(void* buffer, size_t length) 167 166 { 168 std::lock_guard<Mutex> lock(m _mutex);167 std::lock_guard<Mutex> lock(mutex()); 169 168 170 169 unsigned char* result = reinterpret_cast<unsigned char*>(buffer); -
trunk/Source/bmalloc/bmalloc/DebugHeap.cpp
r242938 r244497 150 150 return nullptr; 151 151 { 152 std::lock_guard< std::mutex> locker(m_lock);152 std::lock_guard<Mutex> locker(mutex()); 153 153 m_sizeMap[result] = size; 154 154 } … … 163 163 size_t size; 164 164 { 165 std::lock_guard< std::mutex> locker(m_lock);165 std::lock_guard<Mutex> locker(mutex()); 166 166 size = m_sizeMap[base]; 167 167 size_t numErased = m_sizeMap.erase(base); -
trunk/Source/bmalloc/bmalloc/DebugHeap.h
r242938 r244497 62 62 // This is the debug heap. We can use whatever data structures we like. It doesn't matter. 63 63 size_t m_pageSize { 0 }; 64 std::mutex m_lock;65 64 std::unordered_map<void*, size_t> m_sizeMap; 66 65 }; -
trunk/Source/bmalloc/bmalloc/Scavenger.cpp
r243165 r244497 88 88 void Scavenger::run() 89 89 { 90 std::lock_guard<Mutex> lock(m _mutex);90 std::lock_guard<Mutex> lock(mutex()); 91 91 runHoldingLock(); 92 92 } … … 100 100 void Scavenger::runSoon() 101 101 { 102 std::lock_guard<Mutex> lock(m _mutex);102 std::lock_guard<Mutex> lock(mutex()); 103 103 runSoonHoldingLock(); 104 104 } … … 120 120 void Scavenger::scheduleIfUnderMemoryPressure(size_t bytes) 121 121 { 122 std::lock_guard<Mutex> lock(m _mutex);122 std::lock_guard<Mutex> lock(mutex()); 123 123 scheduleIfUnderMemoryPressureHoldingLock(bytes); 124 124 } … … 144 144 void Scavenger::schedule(size_t bytes) 145 145 { 146 std::lock_guard<Mutex> lock(m _mutex);146 std::lock_guard<Mutex> lock(mutex()); 147 147 scheduleIfUnderMemoryPressureHoldingLock(bytes); 148 148 … … 175 175 std::chrono::milliseconds Scavenger::timeSinceLastFullScavenge() 176 176 { 177 std::unique_lock<Mutex> lock(m _mutex);177 std::unique_lock<Mutex> lock(mutex()); 178 178 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_lastFullScavengeTime); 179 179 } … … 247 247 248 248 { 249 std::unique_lock<Mutex> lock(m _mutex);249 std::unique_lock<Mutex> lock(mutex()); 250 250 m_lastFullScavengeTime = std::chrono::steady_clock::now(); 251 251 } … … 313 313 while (true) { 314 314 if (m_state == State::Sleep) { 315 std::unique_lock<Mutex> lock(m _mutex);315 std::unique_lock<Mutex> lock(mutex()); 316 316 m_condition.wait(lock, [&]() { return m_state != State::Sleep; }); 317 317 } 318 318 319 319 if (m_state == State::RunSoon) { 320 std::unique_lock<Mutex> lock(m _mutex);320 std::unique_lock<Mutex> lock(mutex()); 321 321 m_condition.wait_for(lock, m_waitTime, [&]() { return m_state != State::RunSoon; }); 322 322 } -
trunk/Source/bmalloc/bmalloc/Scavenger.h
r243144 r244497 97 97 bool m_isInMiniMode { false }; 98 98 99 Mutex m_mutex;100 99 Mutex m_scavengingMutex; 101 100 std::condition_variable_any m_condition;
Note: See TracChangeset
for help on using the changeset viewer.