Changeset 161173 in webkit


Ignore:
Timestamp:
Dec 30, 2013 10:54:20 PM (10 years ago)
Author:
commit-queue@webkit.org
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/JavaScriptCore:

  • 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):

Location:
trunk/Source
Files:
5 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r161163 r161173  
     12013-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
    1232013-12-30  Anders Carlsson  <andersca@apple.com>
    224
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp

    r161161 r161173  
    6262    releaseFreeRegions();
    6363    {
    64         std::lock_guard<std::mutex> lock(m_emptyRegionConditionMutex);
     64        MutexLocker locker(m_emptyRegionConditionLock);
    6565        m_blockFreeingThreadShouldQuit = true;
    66         m_emptyRegionCondition.notify_all();
     66        m_emptyRegionCondition.broadcast();
    6767    }
    6868    if (m_blockFreeingThread)
     
    102102}
    103103
    104 void BlockAllocator::waitForDuration(std::chrono::milliseconds duration)
     104void BlockAllocator::waitForRelativeTimeWhileHoldingLock(double relative)
    105105{
    106     std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
     106    if (m_blockFreeingThreadShouldQuit)
     107        return;
    107108
     109    m_emptyRegionCondition.timedWait(m_emptyRegionConditionLock, currentTime() + relative);
     110}
     111
     112void BlockAllocator::waitForRelativeTime(double relative)
     113{
    108114    // If this returns early, that's fine, so long as it doesn't do it too
    109115    // frequently. It would only be a bug if this function failed to return
    110116    // 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);
    115120}
    116121
     
    126131        // Generally wait for one second before scavenging free blocks. This
    127132        // may return early, particularly when we're being asked to quit.
    128         waitForDuration(std::chrono::seconds(1));
     133        waitForRelativeTime(1.0);
    129134        if (m_blockFreeingThreadShouldQuit)
    130135            break;
     
    137142        // Sleep until there is actually work to do rather than waking up every second to check.
    138143        {
    139             std::unique_lock<std::mutex> lock(m_emptyRegionConditionMutex);
     144            MutexLocker locker(m_emptyRegionConditionLock);
    140145            SpinLockHolder regionLocker(&m_regionLock);
    141146            while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) {
    142147                m_regionLock.Unlock();
    143                 m_emptyRegionCondition.wait(lock);
     148                m_emptyRegionCondition.wait(m_emptyRegionConditionLock);
    144149                m_regionLock.Lock();
    145150            }
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.h

    r161163 r161173  
    3030#include "HeapBlock.h"
    3131#include "Region.h"
    32 #include <condition_variable>
    33 #include <mutex>
    3432#include <wtf/DoublyLinkedList.h>
    3533#include <wtf/Forward.h>
     
    6361
    6462private:
    65     void waitForDuration(std::chrono::milliseconds);
     63    void waitForRelativeTimeWhileHoldingLock(double relative);
     64    void waitForRelativeTime(double relative);
    6665
    6766    friend ThreadIdentifier createBlockFreeingThread(BlockAllocator*);
     
    107106    bool m_blockFreeingThreadShouldQuit;
    108107    SpinLock m_regionLock;
    109     std::mutex m_emptyRegionConditionMutex;
    110     std::condition_variable m_emptyRegionCondition;
     108    Mutex m_emptyRegionConditionLock;
     109    ThreadCondition m_emptyRegionCondition;
    111110    ThreadIdentifier m_blockFreeingThread;
    112111};
     
    201200
    202201    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();
    205204    }
    206205
  • trunk/Source/WTF/ChangeLog

    r161164 r161173  
     12013-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
    1352013-12-30  Anders Carlsson  <andersca@apple.com>
    236
  • trunk/Source/WTF/GNUmakefile.list.am

    r161160 r161173  
    245245    Source/WTF/wtf/text/WTFString.cpp \
    246246    Source/WTF/wtf/text/WTFString.h \
     247    Source/WTF/wtf/threads/BinarySemaphore.cpp \
     248    Source/WTF/wtf/threads/BinarySemaphore.h \
    247249    Source/WTF/wtf/unicode/CharacterNames.h \
    248250    Source/WTF/wtf/unicode/Collator.h \
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj

    r161160 r161173  
    142142    <ClCompile Include="..\wtf\ThreadingWin.cpp" />
    143143    <ClCompile Include="..\wtf\threadspecificWin.cpp" />
     144    <ClCompile Include="..\wtf\threads\BinarySemaphore.cpp" />
     145    <ClCompile Include="..\wtf\threads\win\BinarySemaphoreWin.cpp" />
    144146    <ClCompile Include="..\wtf\unicode\icu\CollatorICU.cpp" />
    145147    <ClCompile Include="..\wtf\unicode\UTF8.cpp" />
     
    296298    <ClInclude Include="..\wtf\threadsafeRefCounted.h" />
    297299    <ClInclude Include="..\wtf\threadspecific.h" />
     300    <ClInclude Include="..\wtf\threads\BinarySemaphore.h" />
    298301    <ClInclude Include="..\wtf\unicode\CharacterNames.h" />
    299302    <ClInclude Include="..\wtf\unicode\Collator.h" />
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters

    r161160 r161173  
    8888      <Filter>win</Filter>
    8989    </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>
    9096    <ClCompile Include="..\wtf\threadspecificWin.cpp">
    9197      <Filter>wtf</Filter>
     
    315321    <ClInclude Include="..\wtf\text\WTFString.h">
    316322      <Filter>text</Filter>
     323    </ClInclude>
     324    <ClInclude Include="..\wtf\threads\BinarySemaphore.h">
     325      <Filter>threads</Filter>
    317326    </ClInclude>
    318327    <ClInclude Include="..\wtf\threadsafeRefCounted.h">
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r161160 r161173  
    246246                A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47336151A825B004123FF /* ThreadingPthreads.cpp */; };
    247247                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 */; };
    248250                A8A47454151A825B004123FF /* ThreadSafeRefCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */; };
    249251                A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A4733F151A825B004123FF /* ThreadSpecific.h */; };
     
    520522                A8A47336151A825B004123FF /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPthreads.cpp; sourceTree = "<group>"; };
    521523                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>"; };
    522526                A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSafeRefCounted.h; sourceTree = "<group>"; };
    523527                A8A4733F151A825B004123FF /* ThreadSpecific.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSpecific.h; sourceTree = "<group>"; };
     
    641645                                A8A472C4151A825A004123FF /* mac */,
    642646                                A8A4731B151A825B004123FF /* text */,
     647                                A8A47339151A825B004123FF /* threads */,
    643648                                A8A47348151A825B004123FF /* unicode */,
    644649                                A8A4725A151A825A004123FF /* ASCIICType.h */,
     
    905910                        sourceTree = "<group>";
    906911                };
     912                A8A47339151A825B004123FF /* threads */ = {
     913                        isa = PBXGroup;
     914                        children = (
     915                                A8A4733A151A825B004123FF /* BinarySemaphore.cpp */,
     916                                A8A4733B151A825B004123FF /* BinarySemaphore.h */,
     917                        );
     918                        path = threads;
     919                        sourceTree = "<group>";
     920                };
    907921                A8A47348151A825B004123FF /* unicode */ = {
    908922                        isa = PBXGroup;
     
    952966                                A8A473AB151A825B004123FF /* bignum.h in Headers */,
    953967                                7CDD7FFA186D2A54007433CD /* IteratorPair.h in Headers */,
     968                                A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */,
    954969                                A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
    955970                                A8A4738C151A825B004123FF /* BitVector.h in Headers */,
     
    11941209                                A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */,
    11951210                                A8A473AA151A825B004123FF /* bignum.cc in Sources */,
     1211                                A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */,
    11961212                                A8A4738B151A825B004123FF /* BitVector.cpp in Sources */,
    11971213                                A8A473AC151A825B004123FF /* cached-powers.cc in Sources */,
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r161160 r161173  
    137137    text/WTFString.h
    138138
     139    threads/BinarySemaphore.h
     140
    139141    unicode/CharacterNames.h
    140142    unicode/Collator.h
     
    202204    text/WTFString.cpp
    203205
     206    threads/BinarySemaphore.cpp
     207
    204208    unicode/UTF8.cpp
    205209)
     
    209213    "${WTF_DIR}/wtf"
    210214    "${WTF_DIR}/wtf/dtoa"
     215    "${WTF_DIR}/wtf/threads"
    211216    "${WTF_DIR}/wtf/unicode"
    212217    "${THIRDPARTY_DIR}"
  • trunk/Source/WTF/wtf/Forward.h

    r161160 r161173  
    3939class AtomicString;
    4040class AtomicStringImpl;
     41class BinarySemaphore;
    4142class CString;
    4243class Decoder;
     
    5253using WTF::AtomicString;
    5354using WTF::AtomicStringImpl;
     55using WTF::BinarySemaphore;
    5456using WTF::CString;
    5557using WTF::Decoder;
  • trunk/Source/WTF/wtf/PlatformWin.cmake

    r161160 r161173  
    11list(APPEND WTF_SOURCES
     2    threads/win/BinarySemaphoreWin.cpp
     3
    24    win/MainThreadWin.cpp
    35    win/RunLoopWin.cpp
  • trunk/Source/WebKit2/ChangeLog

    r161165 r161173  
     12013-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
    1202013-12-30  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/Source/WebKit2/Platform/IPC/Connection.cpp

    r161165 r161173  
    3232#include <wtf/RunLoop.h>
    3333#include <wtf/text/WTFString.h>
     34#include <wtf/threads/BinarySemaphore.h>
    3435
    3536namespace 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 };
    7837
    7938class Connection::SyncMessageState : public ThreadSafeRefCounted<Connection::SyncMessageState> {
     
    8746    }
    8847
    89     bool wait(std::chrono::steady_clock::time_point absoluteTime)
     48    bool wait(double absoluteTime)
    9049    {
    9150        return m_waitForSyncReplySemaphore.wait(absoluteTime);
     
    418377}
    419378
    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    
    429379std::unique_ptr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout)
    430380{
     
    551501    sendMessage(std::move(encoder), 0);
    552502
    553     auto timeoutTime = absoluteTimeoutTime(timeout);
    554     pendingReply.semaphore.wait(timeoutTime);
     503    pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0));
    555504
    556505    // Finally, pop the pending sync reply information.
     
    566515std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags)
    567516{
    568     auto timeoutTime = absoluteTimeoutTime(timeout);
     517    double absoluteTime = currentTime() + (timeout.count() / 1000.0);
    569518
    570519    bool timedOut = false;
     
    602551            // account for a timeout value passed in. Timeout is always NoTimeout in these cases, but that could change.
    603552            RunLoop::current()->runForDuration(1e10);
    604             timedOut = std::chrono::steady_clock::now() >= timeoutTime;
     553            timedOut = currentTime() >= absoluteTime;
    605554#endif
    606555        } else
    607             timedOut = !m_syncMessageState->wait(timeoutTime);
     556            timedOut = !m_syncMessageState->wait(absoluteTime);
    608557       
    609558    }
Note: See TracChangeset for help on using the changeset viewer.