Title: [161173] trunk/Source
Revision
161173
Author
[email protected]
Date
2013-12-30 22:54:20 -0800 (Mon, 30 Dec 2013)

Log Message

Unreviewed, rolling out r161157, r161158, r161160, r161161,
r161163, and r161165.
http://trac.webkit.org/changeset/161157
http://trac.webkit.org/changeset/161158
http://trac.webkit.org/changeset/161160
http://trac.webkit.org/changeset/161161
http://trac.webkit.org/changeset/161163
http://trac.webkit.org/changeset/161165
https://bugs.webkit.org/show_bug.cgi?id=126332

Broke WebKit2 on Mountain Lion (Requested by ap on #webkit).

Source/_javascript_Core:

* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::~BlockAllocator):
(JSC::BlockAllocator::waitForRelativeTimeWhileHoldingLock):
(JSC::BlockAllocator::waitForRelativeTime):
(JSC::BlockAllocator::blockFreeingThreadMain):
* heap/BlockAllocator.h:
(JSC::BlockAllocator::deallocate):

Source/WebKit2:

* Platform/IPC/Connection.cpp:
(IPC::Connection::SyncMessageState::wait):
(IPC::Connection::sendSyncMessageFromSecondaryThread):
(IPC::Connection::waitForSyncReply):

Source/WTF:

* GNUmakefile.list.am:
* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/PlatformWin.cmake:
* wtf/threads/BinarySemaphore.cpp: Added.
(WTF::BinarySemaphore::BinarySemaphore):
(WTF::BinarySemaphore::~BinarySemaphore):
(WTF::BinarySemaphore::signal):
(WTF::BinarySemaphore::wait):
* wtf/threads/BinarySemaphore.h: Added.
(WTF::BinarySemaphore::event):
* wtf/threads/win/BinarySemaphoreWin.cpp: Added.
(WTF::BinarySemaphore::BinarySemaphore):
(WTF::BinarySemaphore::~BinarySemaphore):
(WTF::BinarySemaphore::signal):
(WTF::BinarySemaphore::wait):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (161172 => 161173)


--- trunk/Source/_javascript_Core/ChangeLog	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-12-31 06:54:20 UTC (rev 161173)
@@ -1,3 +1,25 @@
+2013-12-30  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r161157, r161158, r161160, r161161,
+        r161163, and r161165.
+        http://trac.webkit.org/changeset/161157
+        http://trac.webkit.org/changeset/161158
+        http://trac.webkit.org/changeset/161160
+        http://trac.webkit.org/changeset/161161
+        http://trac.webkit.org/changeset/161163
+        http://trac.webkit.org/changeset/161165
+        https://bugs.webkit.org/show_bug.cgi?id=126332
+
+        Broke WebKit2 on Mountain Lion (Requested by ap on #webkit).
+
+        * heap/BlockAllocator.cpp:
+        (JSC::BlockAllocator::~BlockAllocator):
+        (JSC::BlockAllocator::waitForRelativeTimeWhileHoldingLock):
+        (JSC::BlockAllocator::waitForRelativeTime):
+        (JSC::BlockAllocator::blockFreeingThreadMain):
+        * heap/BlockAllocator.h:
+        (JSC::BlockAllocator::deallocate):
+
 2013-12-30  Anders Carlsson  <[email protected]>
 
         Fix build.

Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.cpp (161172 => 161173)


--- trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2013-12-31 06:54:20 UTC (rev 161173)
@@ -61,9 +61,9 @@
 {
     releaseFreeRegions();
     {
-        std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);
+        MutexLocker locker(m_emptyRegionConditionLock);
         m_blockFreeingThreadShouldQuit = true;
-        m_emptyRegionCondition.notify_all();
+        m_emptyRegionCondition.broadcast();
     }
     if (m_blockFreeingThread)
         waitForThreadCompletion(m_blockFreeingThread);
@@ -101,17 +101,22 @@
     }
 }
 
-void BlockAllocator::waitForDuration(std::chrono::milliseconds duration)
+void BlockAllocator::waitForRelativeTimeWhileHoldingLock(double relative)
 {
-    std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
+    if (m_blockFreeingThreadShouldQuit)
+        return;
 
+    m_emptyRegionCondition.timedWait(m_emptyRegionConditionLock, currentTime() + relative);
+}
+
+void BlockAllocator::waitForRelativeTime(double relative)
+{
     // If this returns early, that's fine, so long as it doesn't do it too
     // frequently. It would only be a bug if this function failed to return
     // when it was asked to do so.
-    if (m_blockFreeingThreadShouldQuit)
-        return;
-
-    m_emptyRegionCondition.wait_for(lock, duration);
+    
+    MutexLocker locker(m_emptyRegionConditionLock);
+    waitForRelativeTimeWhileHoldingLock(relative);
 }
 
 void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator)
@@ -125,7 +130,7 @@
     while (!m_blockFreeingThreadShouldQuit) {
         // Generally wait for one second before scavenging free blocks. This
         // may return early, particularly when we're being asked to quit.
-        waitForDuration(std::chrono::seconds(1));
+        waitForRelativeTime(1.0);
         if (m_blockFreeingThreadShouldQuit)
             break;
         
@@ -136,11 +141,11 @@
 
         // Sleep until there is actually work to do rather than waking up every second to check.
         {
-            std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
+            MutexLocker locker(m_emptyRegionConditionLock);
             SpinLockHolder regionLocker(&m_regionLock);
             while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) {
                 m_regionLock.Unlock();
-                m_emptyRegionCondition.wait(lock);
+                m_emptyRegionCondition.wait(m_emptyRegionConditionLock);
                 m_regionLock.Lock();
             }
             currentNumberOfEmptyRegions = m_numberOfEmptyRegions;

Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.h (161172 => 161173)


--- trunk/Source/_javascript_Core/heap/BlockAllocator.h	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.h	2013-12-31 06:54:20 UTC (rev 161173)
@@ -29,8 +29,6 @@
 #include "GCActivityCallback.h"
 #include "HeapBlock.h"
 #include "Region.h"
-#include <condition_variable>
-#include <mutex>
 #include <wtf/DoublyLinkedList.h>
 #include <wtf/Forward.h>
 #include <wtf/PageAllocationAligned.h>
@@ -62,7 +60,8 @@
     template <typename T> void deallocateCustomSize(T*);
 
 private:
-    void waitForDuration(std::chrono::milliseconds);
+    void waitForRelativeTimeWhileHoldingLock(double relative);
+    void waitForRelativeTime(double relative);
 
     friend ThreadIdentifier createBlockFreeingThread(BlockAllocator*);
     void blockFreeingThreadMain();
@@ -106,8 +105,8 @@
     bool m_isCurrentlyAllocating;
     bool m_blockFreeingThreadShouldQuit;
     SpinLock m_regionLock;
-    std::mutex m_emptyRegionConditionMutex;
-    std::condition_variable m_emptyRegionCondition;
+    Mutex m_emptyRegionConditionLock;
+    ThreadCondition m_emptyRegionCondition;
     ThreadIdentifier m_blockFreeingThread;
 };
 
@@ -200,8 +199,8 @@
     }
 
     if (shouldWakeBlockFreeingThread) {
-        std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);
-        m_emptyRegionCondition.notify_one();
+        MutexLocker mutexLocker(m_emptyRegionConditionLock);
+        m_emptyRegionCondition.signal();
     }
 
     if (!m_blockFreeingThread)

Modified: trunk/Source/WTF/ChangeLog (161172 => 161173)


--- trunk/Source/WTF/ChangeLog	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/ChangeLog	2013-12-31 06:54:20 UTC (rev 161173)
@@ -1,3 +1,37 @@
+2013-12-30  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r161157, r161158, r161160, r161161,
+        r161163, and r161165.
+        http://trac.webkit.org/changeset/161157
+        http://trac.webkit.org/changeset/161158
+        http://trac.webkit.org/changeset/161160
+        http://trac.webkit.org/changeset/161161
+        http://trac.webkit.org/changeset/161163
+        http://trac.webkit.org/changeset/161165
+        https://bugs.webkit.org/show_bug.cgi?id=126332
+
+        Broke WebKit2 on Mountain Lion (Requested by ap on #webkit).
+
+        * GNUmakefile.list.am:
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.vcxproj/WTF.vcxproj.filters:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/Forward.h:
+        * wtf/PlatformWin.cmake:
+        * wtf/threads/BinarySemaphore.cpp: Added.
+        (WTF::BinarySemaphore::BinarySemaphore):
+        (WTF::BinarySemaphore::~BinarySemaphore):
+        (WTF::BinarySemaphore::signal):
+        (WTF::BinarySemaphore::wait):
+        * wtf/threads/BinarySemaphore.h: Added.
+        (WTF::BinarySemaphore::event):
+        * wtf/threads/win/BinarySemaphoreWin.cpp: Added.
+        (WTF::BinarySemaphore::BinarySemaphore):
+        (WTF::BinarySemaphore::~BinarySemaphore):
+        (WTF::BinarySemaphore::signal):
+        (WTF::BinarySemaphore::wait):
+
 2013-12-30  Anders Carlsson  <[email protected]>
 
         Replace yield() and pauseBriefly() with std::this_thread::yield()

Modified: trunk/Source/WTF/GNUmakefile.list.am (161172 => 161173)


--- trunk/Source/WTF/GNUmakefile.list.am	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/GNUmakefile.list.am	2013-12-31 06:54:20 UTC (rev 161173)
@@ -244,6 +244,8 @@
     Source/WTF/wtf/text/TextPosition.h \
     Source/WTF/wtf/text/WTFString.cpp \
     Source/WTF/wtf/text/WTFString.h \
+    Source/WTF/wtf/threads/BinarySemaphore.cpp \
+    Source/WTF/wtf/threads/BinarySemaphore.h \
     Source/WTF/wtf/unicode/CharacterNames.h \
     Source/WTF/wtf/unicode/Collator.h \
     Source/WTF/wtf/unicode/CollatorDefault.cpp \

Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (161172 => 161173)


--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2013-12-31 06:54:20 UTC (rev 161173)
@@ -141,6 +141,8 @@
     <ClCompile Include="..\wtf\Threading.cpp" />
     <ClCompile Include="..\wtf\ThreadingWin.cpp" />
     <ClCompile Include="..\wtf\threadspecificWin.cpp" />
+    <ClCompile Include="..\wtf\threads\BinarySemaphore.cpp" />
+    <ClCompile Include="..\wtf\threads\win\BinarySemaphoreWin.cpp" />
     <ClCompile Include="..\wtf\unicode\icu\CollatorICU.cpp" />
     <ClCompile Include="..\wtf\unicode\UTF8.cpp" />
     <ClCompile Include="..\wtf\win\MainThreadWin.cpp" />
@@ -295,6 +297,7 @@
     <ClInclude Include="..\wtf\ThreadRestrictionVerifier.h" />
     <ClInclude Include="..\wtf\threadsafeRefCounted.h" />
     <ClInclude Include="..\wtf\threadspecific.h" />
+    <ClInclude Include="..\wtf\threads\BinarySemaphore.h" />
     <ClInclude Include="..\wtf\unicode\CharacterNames.h" />
     <ClInclude Include="..\wtf\unicode\Collator.h" />
     <ClInclude Include="..\wtf\unicode\icu\UnicodeIcu.h" />

Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (161172 => 161173)


--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters	2013-12-31 06:54:20 UTC (rev 161173)
@@ -87,6 +87,12 @@
     <ClCompile Include="..\wtf\win\MainThreadWin.cpp">
       <Filter>win</Filter>
     </ClCompile>
+    <ClCompile Include="..\wtf\threads\win\BinarySemaphoreWin.cpp">
+      <Filter>threads\win</Filter>
+    </ClCompile>
+    <ClCompile Include="..\wtf\threads\BinarySemaphore.cpp">
+      <Filter>threads</Filter>
+    </ClCompile>
     <ClCompile Include="..\wtf\threadspecificWin.cpp">
       <Filter>wtf</Filter>
     </ClCompile>
@@ -315,6 +321,9 @@
     <ClInclude Include="..\wtf\text\WTFString.h">
       <Filter>text</Filter>
     </ClInclude>
+    <ClInclude Include="..\wtf\threads\BinarySemaphore.h">
+      <Filter>threads</Filter>
+    </ClInclude>
     <ClInclude Include="..\wtf\threadsafeRefCounted.h">
       <Filter>wtf</Filter>
     </ClInclude>

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (161172 => 161173)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2013-12-31 06:54:20 UTC (rev 161173)
@@ -245,6 +245,8 @@
 		A8A4744D151A825B004123FF /* ThreadingPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47335151A825B004123FF /* ThreadingPrimitives.h */; };
 		A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47336151A825B004123FF /* ThreadingPthreads.cpp */; };
 		A8A47450151A825B004123FF /* ThreadRestrictionVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */; };
+		A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A4733A151A825B004123FF /* BinarySemaphore.cpp */; };
+		A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733B151A825B004123FF /* BinarySemaphore.h */; };
 		A8A47454151A825B004123FF /* ThreadSafeRefCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */; };
 		A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733F151A825B004123FF /* ThreadSpecific.h */; };
 		A8A4745E151A825B004123FF /* CharacterNames.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47349151A825B004123FF /* CharacterNames.h */; };
@@ -519,6 +521,8 @@
 		A8A47335151A825B004123FF /* ThreadingPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadingPrimitives.h; sourceTree = "<group>"; };
 		A8A47336151A825B004123FF /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPthreads.cpp; sourceTree = "<group>"; };
 		A8A47338151A825B004123FF /* ThreadRestrictionVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadRestrictionVerifier.h; sourceTree = "<group>"; };
+		A8A4733A151A825B004123FF /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; };
+		A8A4733B151A825B004123FF /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; };
 		A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSafeRefCounted.h; sourceTree = "<group>"; };
 		A8A4733F151A825B004123FF /* ThreadSpecific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSpecific.h; sourceTree = "<group>"; };
 		A8A47349151A825B004123FF /* CharacterNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterNames.h; sourceTree = "<group>"; };
@@ -640,6 +644,7 @@
 				1FA47C87152502DA00568D1B /* ios */,
 				A8A472C4151A825A004123FF /* mac */,
 				A8A4731B151A825B004123FF /* text */,
+				A8A47339151A825B004123FF /* threads */,
 				A8A47348151A825B004123FF /* unicode */,
 				A8A4725A151A825A004123FF /* ASCIICType.h */,
 				A8A4725B151A825A004123FF /* Assertions.cpp */,
@@ -904,6 +909,15 @@
 			path = text;
 			sourceTree = "<group>";
 		};
+		A8A47339151A825B004123FF /* threads */ = {
+			isa = PBXGroup;
+			children = (
+				A8A4733A151A825B004123FF /* BinarySemaphore.cpp */,
+				A8A4733B151A825B004123FF /* BinarySemaphore.h */,
+			);
+			path = threads;
+			sourceTree = "<group>";
+		};
 		A8A47348151A825B004123FF /* unicode */ = {
 			isa = PBXGroup;
 			children = (
@@ -951,6 +965,7 @@
 				A8A473A9151A825B004123FF /* bignum-dtoa.h in Headers */,
 				A8A473AB151A825B004123FF /* bignum.h in Headers */,
 				7CDD7FFA186D2A54007433CD /* IteratorPair.h in Headers */,
+				A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */,
 				A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
 				A8A4738C151A825B004123FF /* BitVector.h in Headers */,
 				A8A4738E151A825B004123FF /* BlockStack.h in Headers */,
@@ -1193,6 +1208,7 @@
 				8134013815B092FD001FF0B8 /* Base64.cpp in Sources */,
 				A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */,
 				A8A473AA151A825B004123FF /* bignum.cc in Sources */,
+				A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */,
 				A8A4738B151A825B004123FF /* BitVector.cpp in Sources */,
 				A8A473AC151A825B004123FF /* cached-powers.cc in Sources */,
 				A8A47460151A825B004123FF /* CollatorDefault.cpp in Sources */,

Modified: trunk/Source/WTF/wtf/CMakeLists.txt (161172 => 161173)


--- trunk/Source/WTF/wtf/CMakeLists.txt	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/wtf/CMakeLists.txt	2013-12-31 06:54:20 UTC (rev 161173)
@@ -136,6 +136,8 @@
     text/StringImpl.h
     text/WTFString.h
 
+    threads/BinarySemaphore.h
+
     unicode/CharacterNames.h
     unicode/Collator.h
     unicode/UTF8.h
@@ -201,6 +203,8 @@
     text/StringStatics.cpp
     text/WTFString.cpp
 
+    threads/BinarySemaphore.cpp
+
     unicode/UTF8.cpp
 )
 
@@ -208,6 +212,7 @@
     "${WTF_DIR}"
     "${WTF_DIR}/wtf"
     "${WTF_DIR}/wtf/dtoa"
+    "${WTF_DIR}/wtf/threads"
     "${WTF_DIR}/wtf/unicode"
     "${THIRDPARTY_DIR}"
     "${CMAKE_BINARY_DIR}"

Modified: trunk/Source/WTF/wtf/Forward.h (161172 => 161173)


--- trunk/Source/WTF/wtf/Forward.h	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/wtf/Forward.h	2013-12-31 06:54:20 UTC (rev 161173)
@@ -38,6 +38,7 @@
 
 class AtomicString;
 class AtomicStringImpl;
+class BinarySemaphore;
 class CString;
 class Decoder;
 class Encoder;
@@ -51,6 +52,7 @@
 
 using WTF::AtomicString;
 using WTF::AtomicStringImpl;
+using WTF::BinarySemaphore;
 using WTF::CString;
 using WTF::Decoder;
 using WTF::Encoder;

Modified: trunk/Source/WTF/wtf/PlatformWin.cmake (161172 => 161173)


--- trunk/Source/WTF/wtf/PlatformWin.cmake	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WTF/wtf/PlatformWin.cmake	2013-12-31 06:54:20 UTC (rev 161173)
@@ -1,4 +1,6 @@
 list(APPEND WTF_SOURCES
+    threads/win/BinarySemaphoreWin.cpp
+
     win/MainThreadWin.cpp
     win/RunLoopWin.cpp
 )

Added: trunk/Source/WTF/wtf/threads/BinarySemaphore.cpp (0 => 161173)


--- trunk/Source/WTF/wtf/threads/BinarySemaphore.cpp	                        (rev 0)
+++ trunk/Source/WTF/wtf/threads/BinarySemaphore.cpp	2013-12-31 06:54:20 UTC (rev 161173)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BinarySemaphore.h"
+
+#if !PLATFORM(WIN)
+
+namespace WTF {
+
+BinarySemaphore::BinarySemaphore()
+    : m_isSet(false)
+{
+}
+    
+BinarySemaphore::~BinarySemaphore()
+{
+}
+
+void BinarySemaphore::signal()
+{
+    MutexLocker locker(m_mutex);
+
+    m_isSet = true;
+    m_condition.signal();
+}
+
+bool BinarySemaphore::wait(double absoluteTime)
+{
+    MutexLocker locker(m_mutex);
+
+    bool timedOut = false;
+    while (!m_isSet) {
+        timedOut = !m_condition.timedWait(m_mutex, absoluteTime);
+        if (timedOut)
+            return false;
+    }
+
+    // Reset the semaphore.
+    m_isSet = false;
+    return true;
+}
+
+} // namespace WTF
+
+#endif // !PLATFORM(WIN)

Added: trunk/Source/WTF/wtf/threads/BinarySemaphore.h (0 => 161173)


--- trunk/Source/WTF/wtf/threads/BinarySemaphore.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/threads/BinarySemaphore.h	2013-12-31 06:54:20 UTC (rev 161173)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BinarySemaphore_h
+#define BinarySemaphore_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/ThreadingPrimitives.h>
+
+namespace WTF {
+
+class BinarySemaphore {
+    WTF_MAKE_NONCOPYABLE(BinarySemaphore);
+
+public:
+    WTF_EXPORT_PRIVATE BinarySemaphore();
+    WTF_EXPORT_PRIVATE ~BinarySemaphore();
+
+    WTF_EXPORT_PRIVATE void signal();
+    WTF_EXPORT_PRIVATE bool wait(double absoluteTime);
+
+#if OS(WINDOWS)
+    HANDLE event() const { return m_event; }
+#endif
+
+private:
+#if OS(WINDOWS)
+    HANDLE m_event;
+#else
+    bool m_isSet;
+
+    Mutex m_mutex;
+    ThreadCondition m_condition;
+#endif
+};
+
+} // namespace WTF
+
+using WTF::BinarySemaphore;
+
+#endif // BinarySemaphore_h

Added: trunk/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp (0 => 161173)


--- trunk/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp	                        (rev 0)
+++ trunk/Source/WTF/wtf/threads/win/BinarySemaphoreWin.cpp	2013-12-31 06:54:20 UTC (rev 161173)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BinarySemaphore.h"
+
+namespace WTF {
+
+BinarySemaphore::BinarySemaphore()
+    : m_event(::CreateEventW(0, FALSE, FALSE, 0))
+{
+}
+
+BinarySemaphore::~BinarySemaphore()
+{
+    ::CloseHandle(m_event);
+}
+
+void BinarySemaphore::signal()
+{
+    ::SetEvent(m_event);
+}
+
+bool BinarySemaphore::wait(double absoluteTime)
+{
+    DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime);
+    if (!interval) {
+        // Consider the wait to have timed out, even if the event has already been signaled, to
+        // match the WTF::ThreadCondition implementation.
+        return false;
+    }
+
+    DWORD result = ::WaitForSingleObject(m_event, interval);
+    switch (result) {
+    case WAIT_OBJECT_0:
+        // The event was signaled.
+        return true;
+
+    case WAIT_TIMEOUT:
+        // The wait timed out.
+        return false;
+
+    case WAIT_FAILED:
+        ASSERT_WITH_MESSAGE(false, "::WaitForSingleObject failed with error %lu", ::GetLastError());
+        return false;
+
+    default:
+        ASSERT_WITH_MESSAGE(false, "::WaitForSingleObject returned unexpected result %lu", result);
+        return false;
+    }
+}
+
+} // namespace WTF

Modified: trunk/Source/WebKit2/ChangeLog (161172 => 161173)


--- trunk/Source/WebKit2/ChangeLog	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-31 06:54:20 UTC (rev 161173)
@@ -1,3 +1,22 @@
+2013-12-30  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r161157, r161158, r161160, r161161,
+        r161163, and r161165.
+        http://trac.webkit.org/changeset/161157
+        http://trac.webkit.org/changeset/161158
+        http://trac.webkit.org/changeset/161160
+        http://trac.webkit.org/changeset/161161
+        http://trac.webkit.org/changeset/161163
+        http://trac.webkit.org/changeset/161165
+        https://bugs.webkit.org/show_bug.cgi?id=126332
+
+        Broke WebKit2 on Mountain Lion (Requested by ap on #webkit).
+
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::SyncMessageState::wait):
+        (IPC::Connection::sendSyncMessageFromSecondaryThread):
+        (IPC::Connection::waitForSyncReply):
+
 2013-12-30  Anders Carlsson  <[email protected]>
 
         Try to fix the test failures seen on the bots.

Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (161172 => 161173)


--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp	2013-12-31 06:49:49 UTC (rev 161172)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp	2013-12-31 06:54:20 UTC (rev 161173)
@@ -31,51 +31,10 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
 #include <wtf/text/WTFString.h>
+#include <wtf/threads/BinarySemaphore.h>
 
 namespace IPC {
 
-class BinarySemaphore {
-public:
-    BinarySemaphore()
-        : m_isSet(false)
-    {
-    }
-    
-    ~BinarySemaphore()
-    {
-    }
-
-    void signal()
-    {
-        std::lock_guard<std::mutex> lock(m_mutex);
-    
-        m_isSet = true;
-        m_conditionVariable.notify_all();
-    }
-    
-    bool wait(std::chrono::steady_clock::time_point absoluteTime)
-    {
-        std::unique_lock<std::mutex> lock(m_mutex);
-    
-        while (!m_isSet) {
-            std::cv_status status = m_conditionVariable.wait_until(lock, absoluteTime);
-            if (status == std::cv_status::timeout)
-                return false;
-        }
-        
-        // Reset the semaphore.
-        m_isSet = false;
-
-        return true;
-    }
-
-private:
-    bool m_isSet;
-    
-    std::mutex m_mutex;
-    std::condition_variable m_conditionVariable;
-};
-
 class Connection::SyncMessageState : public ThreadSafeRefCounted<Connection::SyncMessageState> {
 public:
     static PassRefPtr<SyncMessageState> getOrCreate(RunLoop*);
@@ -86,7 +45,7 @@
         m_waitForSyncReplySemaphore.signal();
     }
 
-    bool wait(std::chrono::steady_clock::time_point absoluteTime)
+    bool wait(double absoluteTime)
     {
         return m_waitForSyncReplySemaphore.wait(absoluteTime);
     }
@@ -417,15 +376,6 @@
     return sendMessage(std::move(encoder));
 }
 
-static std::chrono::steady_clock::time_point absoluteTimeoutTime(std::chrono::milliseconds timeout)
-{
-    // We use std::chrono::milliseconds::max() to mean no timeout.
-    if (timeout == std::chrono::milliseconds::max())
-        return std::chrono::steady_clock::time_point::max();
-    
-    return std::chrono::steady_clock::now() + timeout;
-}
-    
 std::unique_ptr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout)
 {
     // First, check if this message is already in the incoming messages queue.
@@ -550,8 +500,7 @@
 
     sendMessage(std::move(encoder), 0);
 
-    auto timeoutTime = absoluteTimeoutTime(timeout);
-    pendingReply.semaphore.wait(timeoutTime);
+    pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0));
 
     // Finally, pop the pending sync reply information.
     {
@@ -565,7 +514,7 @@
 
 std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags)
 {
-    auto timeoutTime = absoluteTimeoutTime(timeout);
+    double absoluteTime = currentTime() + (timeout.count() / 1000.0);
 
     bool timedOut = false;
     while (!timedOut) {
@@ -601,10 +550,10 @@
             // FIXME: Although we run forever, any events incoming will cause us to drop out and exit out. This however doesn't
             // account for a timeout value passed in. Timeout is always NoTimeout in these cases, but that could change.
             RunLoop::current()->runForDuration(1e10);
-            timedOut = std::chrono::steady_clock::now() >= timeoutTime;
+            timedOut = currentTime() >= absoluteTime;
 #endif
         } else
-            timedOut = !m_syncMessageState->wait(timeoutTime);
+            timedOut = !m_syncMessageState->wait(absoluteTime);
         
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to