Changeset 161173 in webkit
- Timestamp:
- Dec 30, 2013 10:54:20 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r161163 r161173 1 2013-12-30 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r161157, r161158, r161160, r161161, 4 r161163, and r161165. 5 http://trac.webkit.org/changeset/161157 6 http://trac.webkit.org/changeset/161158 7 http://trac.webkit.org/changeset/161160 8 http://trac.webkit.org/changeset/161161 9 http://trac.webkit.org/changeset/161163 10 http://trac.webkit.org/changeset/161165 11 https://bugs.webkit.org/show_bug.cgi?id=126332 12 13 Broke WebKit2 on Mountain Lion (Requested by ap on #webkit). 14 15 * heap/BlockAllocator.cpp: 16 (JSC::BlockAllocator::~BlockAllocator): 17 (JSC::BlockAllocator::waitForRelativeTimeWhileHoldingLock): 18 (JSC::BlockAllocator::waitForRelativeTime): 19 (JSC::BlockAllocator::blockFreeingThreadMain): 20 * heap/BlockAllocator.h: 21 (JSC::BlockAllocator::deallocate): 22 1 23 2013-12-30 Anders Carlsson <andersca@apple.com> 2 24 -
trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp
r161161 r161173 62 62 releaseFreeRegions(); 63 63 { 64 std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);64 MutexLocker locker(m_emptyRegionConditionLock); 65 65 m_blockFreeingThreadShouldQuit = true; 66 m_emptyRegionCondition. notify_all();66 m_emptyRegionCondition.broadcast(); 67 67 } 68 68 if (m_blockFreeingThread) … … 102 102 } 103 103 104 void BlockAllocator::waitFor Duration(std::chrono::milliseconds duration)104 void BlockAllocator::waitForRelativeTimeWhileHoldingLock(double relative) 105 105 { 106 std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex); 106 if (m_blockFreeingThreadShouldQuit) 107 return; 107 108 109 m_emptyRegionCondition.timedWait(m_emptyRegionConditionLock, currentTime() + relative); 110 } 111 112 void BlockAllocator::waitForRelativeTime(double relative) 113 { 108 114 // If this returns early, that's fine, so long as it doesn't do it too 109 115 // frequently. It would only be a bug if this function failed to return 110 116 // when it was asked to do so. 111 if (m_blockFreeingThreadShouldQuit) 112 return; 113 114 m_emptyRegionCondition.wait_for(lock, duration); 117 118 MutexLocker locker(m_emptyRegionConditionLock); 119 waitForRelativeTimeWhileHoldingLock(relative); 115 120 } 116 121 … … 126 131 // Generally wait for one second before scavenging free blocks. This 127 132 // may return early, particularly when we're being asked to quit. 128 waitFor Duration(std::chrono::seconds(1));133 waitForRelativeTime(1.0); 129 134 if (m_blockFreeingThreadShouldQuit) 130 135 break; … … 137 142 // Sleep until there is actually work to do rather than waking up every second to check. 138 143 { 139 std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);144 MutexLocker locker(m_emptyRegionConditionLock); 140 145 SpinLockHolder regionLocker(&m_regionLock); 141 146 while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) { 142 147 m_regionLock.Unlock(); 143 m_emptyRegionCondition.wait( lock);148 m_emptyRegionCondition.wait(m_emptyRegionConditionLock); 144 149 m_regionLock.Lock(); 145 150 } -
trunk/Source/JavaScriptCore/heap/BlockAllocator.h
r161163 r161173 30 30 #include "HeapBlock.h" 31 31 #include "Region.h" 32 #include <condition_variable>33 #include <mutex>34 32 #include <wtf/DoublyLinkedList.h> 35 33 #include <wtf/Forward.h> … … 63 61 64 62 private: 65 void waitForDuration(std::chrono::milliseconds); 63 void waitForRelativeTimeWhileHoldingLock(double relative); 64 void waitForRelativeTime(double relative); 66 65 67 66 friend ThreadIdentifier createBlockFreeingThread(BlockAllocator*); … … 107 106 bool m_blockFreeingThreadShouldQuit; 108 107 SpinLock m_regionLock; 109 std::mutex m_emptyRegionConditionMutex;110 std::condition_variablem_emptyRegionCondition;108 Mutex m_emptyRegionConditionLock; 109 ThreadCondition m_emptyRegionCondition; 111 110 ThreadIdentifier m_blockFreeingThread; 112 111 }; … … 201 200 202 201 if (shouldWakeBlockFreeingThread) { 203 std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);204 m_emptyRegionCondition. notify_one();202 MutexLocker mutexLocker(m_emptyRegionConditionLock); 203 m_emptyRegionCondition.signal(); 205 204 } 206 205 -
trunk/Source/WTF/ChangeLog
r161164 r161173 1 2013-12-30 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r161157, r161158, r161160, r161161, 4 r161163, and r161165. 5 http://trac.webkit.org/changeset/161157 6 http://trac.webkit.org/changeset/161158 7 http://trac.webkit.org/changeset/161160 8 http://trac.webkit.org/changeset/161161 9 http://trac.webkit.org/changeset/161163 10 http://trac.webkit.org/changeset/161165 11 https://bugs.webkit.org/show_bug.cgi?id=126332 12 13 Broke WebKit2 on Mountain Lion (Requested by ap on #webkit). 14 15 * GNUmakefile.list.am: 16 * WTF.vcxproj/WTF.vcxproj: 17 * WTF.vcxproj/WTF.vcxproj.filters: 18 * WTF.xcodeproj/project.pbxproj: 19 * wtf/CMakeLists.txt: 20 * wtf/Forward.h: 21 * wtf/PlatformWin.cmake: 22 * wtf/threads/BinarySemaphore.cpp: Added. 23 (WTF::BinarySemaphore::BinarySemaphore): 24 (WTF::BinarySemaphore::~BinarySemaphore): 25 (WTF::BinarySemaphore::signal): 26 (WTF::BinarySemaphore::wait): 27 * wtf/threads/BinarySemaphore.h: Added. 28 (WTF::BinarySemaphore::event): 29 * wtf/threads/win/BinarySemaphoreWin.cpp: Added. 30 (WTF::BinarySemaphore::BinarySemaphore): 31 (WTF::BinarySemaphore::~BinarySemaphore): 32 (WTF::BinarySemaphore::signal): 33 (WTF::BinarySemaphore::wait): 34 1 35 2013-12-30 Anders Carlsson <andersca@apple.com> 2 36 -
trunk/Source/WTF/GNUmakefile.list.am
r161160 r161173 245 245 Source/WTF/wtf/text/WTFString.cpp \ 246 246 Source/WTF/wtf/text/WTFString.h \ 247 Source/WTF/wtf/threads/BinarySemaphore.cpp \ 248 Source/WTF/wtf/threads/BinarySemaphore.h \ 247 249 Source/WTF/wtf/unicode/CharacterNames.h \ 248 250 Source/WTF/wtf/unicode/Collator.h \ -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r161160 r161173 142 142 <ClCompile Include="..\wtf\ThreadingWin.cpp" /> 143 143 <ClCompile Include="..\wtf\threadspecificWin.cpp" /> 144 <ClCompile Include="..\wtf\threads\BinarySemaphore.cpp" /> 145 <ClCompile Include="..\wtf\threads\win\BinarySemaphoreWin.cpp" /> 144 146 <ClCompile Include="..\wtf\unicode\icu\CollatorICU.cpp" /> 145 147 <ClCompile Include="..\wtf\unicode\UTF8.cpp" /> … … 296 298 <ClInclude Include="..\wtf\threadsafeRefCounted.h" /> 297 299 <ClInclude Include="..\wtf\threadspecific.h" /> 300 <ClInclude Include="..\wtf\threads\BinarySemaphore.h" /> 298 301 <ClInclude Include="..\wtf\unicode\CharacterNames.h" /> 299 302 <ClInclude Include="..\wtf\unicode\Collator.h" /> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r161160 r161173 88 88 <Filter>win</Filter> 89 89 </ClCompile> 90 <ClCompile Include="..\wtf\threads\win\BinarySemaphoreWin.cpp"> 91 <Filter>threads\win</Filter> 92 </ClCompile> 93 <ClCompile Include="..\wtf\threads\BinarySemaphore.cpp"> 94 <Filter>threads</Filter> 95 </ClCompile> 90 96 <ClCompile Include="..\wtf\threadspecificWin.cpp"> 91 97 <Filter>wtf</Filter> … … 315 321 <ClInclude Include="..\wtf\text\WTFString.h"> 316 322 <Filter>text</Filter> 323 </ClInclude> 324 <ClInclude Include="..\wtf\threads\BinarySemaphore.h"> 325 <Filter>threads</Filter> 317 326 </ClInclude> 318 327 <ClInclude Include="..\wtf\threadsafeRefCounted.h"> -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r161160 r161173 246 246 A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47336151A825B004123FF /* ThreadingPthreads.cpp */; }; 247 247 A8A47450151A825B004123FF /* ThreadRestrictionVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */; }; 248 A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4733A151A825B004123FF /* BinarySemaphore.cpp */; }; 249 A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733B151A825B004123FF /* BinarySemaphore.h */; }; 248 250 A8A47454151A825B004123FF /* ThreadSafeRefCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */; }; 249 251 A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733F151A825B004123FF /* ThreadSpecific.h */; }; … … 520 522 A8A47336151A825B004123FF /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPthreads.cpp; sourceTree = "<group>"; }; 521 523 A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadRestrictionVerifier.h; sourceTree = "<group>"; }; 524 A8A4733A151A825B004123FF /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; }; 525 A8A4733B151A825B004123FF /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; }; 522 526 A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSafeRefCounted.h; sourceTree = "<group>"; }; 523 527 A8A4733F151A825B004123FF /* ThreadSpecific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSpecific.h; sourceTree = "<group>"; }; … … 641 645 A8A472C4151A825A004123FF /* mac */, 642 646 A8A4731B151A825B004123FF /* text */, 647 A8A47339151A825B004123FF /* threads */, 643 648 A8A47348151A825B004123FF /* unicode */, 644 649 A8A4725A151A825A004123FF /* ASCIICType.h */, … … 905 910 sourceTree = "<group>"; 906 911 }; 912 A8A47339151A825B004123FF /* threads */ = { 913 isa = PBXGroup; 914 children = ( 915 A8A4733A151A825B004123FF /* BinarySemaphore.cpp */, 916 A8A4733B151A825B004123FF /* BinarySemaphore.h */, 917 ); 918 path = threads; 919 sourceTree = "<group>"; 920 }; 907 921 A8A47348151A825B004123FF /* unicode */ = { 908 922 isa = PBXGroup; … … 952 966 A8A473AB151A825B004123FF /* bignum.h in Headers */, 953 967 7CDD7FFA186D2A54007433CD /* IteratorPair.h in Headers */, 968 A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */, 954 969 A8A4738A151A825B004123FF /* Bitmap.h in Headers */, 955 970 A8A4738C151A825B004123FF /* BitVector.h in Headers */, … … 1194 1209 A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */, 1195 1210 A8A473AA151A825B004123FF /* bignum.cc in Sources */, 1211 A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */, 1196 1212 A8A4738B151A825B004123FF /* BitVector.cpp in Sources */, 1197 1213 A8A473AC151A825B004123FF /* cached-powers.cc in Sources */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r161160 r161173 137 137 text/WTFString.h 138 138 139 threads/BinarySemaphore.h 140 139 141 unicode/CharacterNames.h 140 142 unicode/Collator.h … … 202 204 text/WTFString.cpp 203 205 206 threads/BinarySemaphore.cpp 207 204 208 unicode/UTF8.cpp 205 209 ) … … 209 213 "${WTF_DIR}/wtf" 210 214 "${WTF_DIR}/wtf/dtoa" 215 "${WTF_DIR}/wtf/threads" 211 216 "${WTF_DIR}/wtf/unicode" 212 217 "${THIRDPARTY_DIR}" -
trunk/Source/WTF/wtf/Forward.h
r161160 r161173 39 39 class AtomicString; 40 40 class AtomicStringImpl; 41 class BinarySemaphore; 41 42 class CString; 42 43 class Decoder; … … 52 53 using WTF::AtomicString; 53 54 using WTF::AtomicStringImpl; 55 using WTF::BinarySemaphore; 54 56 using WTF::CString; 55 57 using WTF::Decoder; -
trunk/Source/WTF/wtf/PlatformWin.cmake
r161160 r161173 1 1 list(APPEND WTF_SOURCES 2 threads/win/BinarySemaphoreWin.cpp 3 2 4 win/MainThreadWin.cpp 3 5 win/RunLoopWin.cpp -
trunk/Source/WebKit2/ChangeLog
r161165 r161173 1 2013-12-30 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r161157, r161158, r161160, r161161, 4 r161163, and r161165. 5 http://trac.webkit.org/changeset/161157 6 http://trac.webkit.org/changeset/161158 7 http://trac.webkit.org/changeset/161160 8 http://trac.webkit.org/changeset/161161 9 http://trac.webkit.org/changeset/161163 10 http://trac.webkit.org/changeset/161165 11 https://bugs.webkit.org/show_bug.cgi?id=126332 12 13 Broke WebKit2 on Mountain Lion (Requested by ap on #webkit). 14 15 * Platform/IPC/Connection.cpp: 16 (IPC::Connection::SyncMessageState::wait): 17 (IPC::Connection::sendSyncMessageFromSecondaryThread): 18 (IPC::Connection::waitForSyncReply): 19 1 20 2013-12-30 Anders Carlsson <andersca@apple.com> 2 21 -
trunk/Source/WebKit2/Platform/IPC/Connection.cpp
r161165 r161173 32 32 #include <wtf/RunLoop.h> 33 33 #include <wtf/text/WTFString.h> 34 #include <wtf/threads/BinarySemaphore.h> 34 35 35 36 namespace IPC { 36 37 class BinarySemaphore {38 public:39 BinarySemaphore()40 : m_isSet(false)41 {42 }43 44 ~BinarySemaphore()45 {46 }47 48 void signal()49 {50 std::lock_guard<std::mutex> lock(m_mutex);51 52 m_isSet = true;53 m_conditionVariable.notify_all();54 }55 56 bool wait(std::chrono::steady_clock::time_point absoluteTime)57 {58 std::unique_lock<std::mutex> lock(m_mutex);59 60 while (!m_isSet) {61 std::cv_status status = m_conditionVariable.wait_until(lock, absoluteTime);62 if (status == std::cv_status::timeout)63 return false;64 }65 66 // Reset the semaphore.67 m_isSet = false;68 69 return true;70 }71 72 private:73 bool m_isSet;74 75 std::mutex m_mutex;76 std::condition_variable m_conditionVariable;77 };78 37 79 38 class Connection::SyncMessageState : public ThreadSafeRefCounted<Connection::SyncMessageState> { … … 87 46 } 88 47 89 bool wait( std::chrono::steady_clock::time_pointabsoluteTime)48 bool wait(double absoluteTime) 90 49 { 91 50 return m_waitForSyncReplySemaphore.wait(absoluteTime); … … 418 377 } 419 378 420 static std::chrono::steady_clock::time_point absoluteTimeoutTime(std::chrono::milliseconds timeout)421 {422 // We use std::chrono::milliseconds::max() to mean no timeout.423 if (timeout == std::chrono::milliseconds::max())424 return std::chrono::steady_clock::time_point::max();425 426 return std::chrono::steady_clock::now() + timeout;427 }428 429 379 std::unique_ptr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout) 430 380 { … … 551 501 sendMessage(std::move(encoder), 0); 552 502 553 auto timeoutTime = absoluteTimeoutTime(timeout); 554 pendingReply.semaphore.wait(timeoutTime); 503 pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0)); 555 504 556 505 // Finally, pop the pending sync reply information. … … 566 515 std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags) 567 516 { 568 auto timeoutTime = absoluteTimeoutTime(timeout);517 double absoluteTime = currentTime() + (timeout.count() / 1000.0); 569 518 570 519 bool timedOut = false; … … 602 551 // account for a timeout value passed in. Timeout is always NoTimeout in these cases, but that could change. 603 552 RunLoop::current()->runForDuration(1e10); 604 timedOut = std::chrono::steady_clock::now() >= timeoutTime;553 timedOut = currentTime() >= absoluteTime; 605 554 #endif 606 555 } else 607 timedOut = !m_syncMessageState->wait( timeoutTime);556 timedOut = !m_syncMessageState->wait(absoluteTime); 608 557 609 558 }
Note: See TracChangeset
for help on using the changeset viewer.