Changeset 275553 in webkit


Ignore:
Timestamp:
Apr 6, 2021 2:27:06 PM (3 years ago)
Author:
Fujii Hironori
Message:

Add IPC::Semaphore stub for Unix ports
https://bugs.webkit.org/show_bug.cgi?id=224223

Reviewed by Don Olmstead.

PlayStation, GTK and WPE ports don't use it yet. Just add stubs
instead of scattering #if everywhere using Semaphore.

  • GPUProcess/graphics/RemoteRenderingBackend.cpp:

(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
(WebKit::RemoteRenderingBackend::populateGetImageDataSharedMemory):

  • Platform/IPC/StreamClientConnection.cpp:

(IPC::StreamClientConnection::setWakeUpSemaphore):
(IPC::StreamClientConnection::wakeUpServer):

  • Platform/IPC/StreamClientConnection.h:

(IPC::StreamClientConnection::tryAcquire):
(IPC::StreamClientConnection::tryAcquireAll):

  • Platform/IPC/StreamConnectionWorkQueue.cpp:

(IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue):
(IPC::StreamConnectionWorkQueue::removeStreamConnection):
(IPC::StreamConnectionWorkQueue::stop):
(IPC::StreamConnectionWorkQueue::wakeUp):
(IPC::StreamConnectionWorkQueue::wakeUpProcessingThread):

  • Platform/IPC/StreamConnectionWorkQueue.h:
  • Platform/IPC/StreamServerConnection.cpp:

(IPC::StreamServerConnectionBase::release):
(IPC::StreamServerConnectionBase::releaseAll):

  • Platform/IPC/unix/IPCSemaphoreUnix.cpp: Added.

(IPC::Semaphore::Semaphore):
(IPC::Semaphore::signal):
(IPC::Semaphore::wait):
(IPC::Semaphore::waitFor):
(IPC::Semaphore::encode const):
(IPC::Semaphore::decode):
(IPC::Semaphore::destroy):

  • PlatformPlayStation.cmake:
  • Sources.txt:
  • SourcesGTK.txt:
  • SourcesWPE.txt:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:

(WebKit::RemoteRenderingBackendProxy::waitForGetImageDataToComplete):
(WebKit::RemoteRenderingBackendProxy::didAppendData):

  • WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:

(WebKit::RemoteAudioDestinationProxy::startRenderingThread):
(WebKit::RemoteAudioDestinationProxy::stopRenderingThread):

Location:
trunk/Source/WebKit
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r275549 r275553  
     12021-04-06  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Add IPC::Semaphore stub for Unix ports
     4        https://bugs.webkit.org/show_bug.cgi?id=224223
     5
     6        Reviewed by Don Olmstead.
     7
     8        PlayStation, GTK and WPE ports don't use it yet. Just add stubs
     9        instead of scattering #if everywhere using Semaphore.
     10
     11        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
     12        (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
     13        (WebKit::RemoteRenderingBackend::populateGetImageDataSharedMemory):
     14        * Platform/IPC/StreamClientConnection.cpp:
     15        (IPC::StreamClientConnection::setWakeUpSemaphore):
     16        (IPC::StreamClientConnection::wakeUpServer):
     17        * Platform/IPC/StreamClientConnection.h:
     18        (IPC::StreamClientConnection::tryAcquire):
     19        (IPC::StreamClientConnection::tryAcquireAll):
     20        * Platform/IPC/StreamConnectionWorkQueue.cpp:
     21        (IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue):
     22        (IPC::StreamConnectionWorkQueue::removeStreamConnection):
     23        (IPC::StreamConnectionWorkQueue::stop):
     24        (IPC::StreamConnectionWorkQueue::wakeUp):
     25        (IPC::StreamConnectionWorkQueue::wakeUpProcessingThread):
     26        * Platform/IPC/StreamConnectionWorkQueue.h:
     27        * Platform/IPC/StreamServerConnection.cpp:
     28        (IPC::StreamServerConnectionBase::release):
     29        (IPC::StreamServerConnectionBase::releaseAll):
     30        * Platform/IPC/unix/IPCSemaphoreUnix.cpp: Added.
     31        (IPC::Semaphore::Semaphore):
     32        (IPC::Semaphore::signal):
     33        (IPC::Semaphore::wait):
     34        (IPC::Semaphore::waitFor):
     35        (IPC::Semaphore::encode const):
     36        (IPC::Semaphore::decode):
     37        (IPC::Semaphore::destroy):
     38        * PlatformPlayStation.cmake:
     39        * Sources.txt:
     40        * SourcesGTK.txt:
     41        * SourcesWPE.txt:
     42        * WebKit.xcodeproj/project.pbxproj:
     43        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
     44        (WebKit::RemoteRenderingBackendProxy::waitForGetImageDataToComplete):
     45        (WebKit::RemoteRenderingBackendProxy::didAppendData):
     46        * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
     47        (WebKit::RemoteAudioDestinationProxy::startRenderingThread):
     48        (WebKit::RemoteAudioDestinationProxy::stopRenderingThread):
     49
    1502021-04-06  Ryosuke Niwa  <rniwa@webkit.org>
    251
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

    r275403 r275553  
    248248
    249249            handle.startWaiting();
    250 #if PLATFORM(COCOA)
    251250            m_resumeDisplayListSemaphore.waitFor(30_us);
    252 #else
    253             sleep(30_us);
    254 #endif
    255251
    256252            auto resumeReadingInfo = handle.stopWaiting();
     
    377373        memset(m_getImageDataSharedMemory->data(), 0, m_getImageDataSharedMemory->size());
    378374
    379 #if OS(DARWIN)
    380375    m_getImageDataSemaphore.signal();
    381 #endif
    382376}
    383377
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp

    r275463 r275553  
    4141void StreamClientConnection::setWakeUpSemaphore(IPC::Semaphore&& semaphore)
    4242{
    43 #if PLATFORM(COCOA) || PLATFORM(WIN)
    4443    m_wakeUpSemaphore = WTFMove(semaphore);
    45 #endif
    4644    wakeUpServer();
    4745}
     
    4947void StreamClientConnection::wakeUpServer()
    5048{
    51 #if PLATFORM(COCOA) || PLATFORM(WIN)
    5249    if (m_wakeUpSemaphore)
    5350        m_wakeUpSemaphore->signal();
    54 #endif
    5551}
    5652
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h

    r275463 r275553  
    103103    size_t m_clientOffset { 0 };
    104104    StreamConnectionBuffer m_buffer;
    105 #if PLATFORM(COCOA) || PLATFORM(WIN)
    106105    Optional<Semaphore> m_wakeUpSemaphore;
    107 #endif
    108106};
    109107
     
    241239        if (timeout.didTimeOut())
    242240            break;
    243 #if PLATFORM(COCOA) || PLATFORM(WIN)
    244241        ClientLimit oldClientLimit = sharedClientLimit().compareExchangeStrong(clientLimit, ClientLimit::clientIsWaitingTag, std::memory_order_acq_rel, std::memory_order_acq_rel);
    245242        if (clientLimit == oldClientLimit) {
     
    248245        } else
    249246            clientLimit = oldClientLimit;
    250 #else
    251         Thread::yield();
    252         clientLimit = sharedClientLimit().load(std::memory_order_acquire);
    253 #endif
    254247        // The alignedSpan uses the minimumMessageSize to calculate the next beginning position in the buffer,
    255248        // and not the size. The size might be more or less what is needed, depending on where the reader is.
     
    274267
    275268    for (;;) {
    276 #if PLATFORM(COCOA) || PLATFORM(WIN)
    277269        ClientLimit clientLimit = sharedClientLimit().exchange(ClientLimit::clientIsWaitingTag, std::memory_order_acq_rel);
    278270        ClientOffset clientOffset = sharedClientOffset().load(std::memory_order_acquire);
    279 #else
    280         ClientLimit clientLimit = sharedClientLimit().load(std::memory_order_acquire);
    281         ClientOffset clientOffset = sharedClientOffset().load(std::memory_order_acquire);
    282 #endif
    283271        if (!clientLimit && (clientOffset == ClientOffset::serverIsSleepingTag || !clientOffset))
    284272            break;
    285273
    286 #if PLATFORM(COCOA) || PLATFORM(WIN)
    287274        m_buffer.clientWaitSemaphore().waitFor(timeout);
    288 #else
    289         Thread::yield();
    290 #endif
    291275        if (timeout.didTimeOut())
    292276            return WTF::nullopt;
    293277    }
    294 #if PLATFORM(COCOA) || PLATFORM(WIN)
    295278    // In case the transaction was cancelled, undo the transaction marker.
    296279    sharedClientLimit().store(static_cast<ClientLimit>(0), std::memory_order_release);
    297 #endif
    298280    m_clientOffset = 0;
    299281    return alignedSpan(m_clientOffset, 0);
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.cpp

    r275463 r275553  
    3030
    3131StreamConnectionWorkQueue::StreamConnectionWorkQueue(const char* name)
    32 #if PLATFORM(COCOA) || PLATFORM(WIN)
    3332    : m_name(name)
    34 #endif
    3533{
    3634}
     
    6462        ASSERT(!m_shouldQuit); // Re-entering during shutdown not supported.
    6563    }
    66 #if PLATFORM(COCOA) || PLATFORM(WIN)
    6764    m_wakeUpSemaphore.signal();
    68 #endif
    6965}
    7066
     
    7268{
    7369    m_shouldQuit = true;
    74 #if PLATFORM(COCOA) || PLATFORM(WIN)
    7570    if (!m_processingThread)
    7671        return;
     
    7873    m_processingThread->waitForCompletion();
    7974    m_processingThread = nullptr;
    80 #endif
    8175}
    8276
    8377void StreamConnectionWorkQueue::wakeUp()
    8478{
    85 #if PLATFORM(COCOA) || PLATFORM(WIN)
    8679    m_wakeUpSemaphore.signal();
    87 #endif
    8880}
    8981
     
    9587void StreamConnectionWorkQueue::wakeUpProcessingThread()
    9688{
    97 #if PLATFORM(COCOA) || PLATFORM(WIN)
    9889    if (m_processingThread) {
    9990        m_wakeUpSemaphore.signal();
     
    112103    };
    113104    m_processingThread = Thread::create(m_name, WTFMove(task), ThreadType::Graphics, Thread::QOS::UserInteractive);
    114 #endif
    115105}
    116106
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.h

    r275463 r275553  
    5454    void processStreams();
    5555
    56 #if PLATFORM(COCOA) || PLATFORM(WIN)
    5756    const char* const m_name;
    58 #endif
    5957
    6058    Semaphore m_wakeUpSemaphore;
  • trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp

    r275463 r275553  
    8989    ServerOffset serverOffset = static_cast<ServerOffset>(wrapOffset(alignOffset(m_serverOffset) + readSize));
    9090
    91 #if PLATFORM(COCOA) || PLATFORM(WIN)
    9291    ServerOffset oldServerOffset = sharedServerOffset().exchange(serverOffset, std::memory_order_acq_rel);
    9392    // If the client wrote over serverOffset, it means the client is waiting.
     
    9695    else
    9796        ASSERT(!(oldServerOffset & ServerOffset::clientIsWaitingTag));
    98 #else
    99     sharedServerOffset().store(serverOffset, std::memory_order_release);
    100     // IPC::Semaphore not implemented for the platform. Client will poll and yield.
    101 #endif
    10297
    10398    m_serverOffset = serverOffset;
     
    107102{
    108103    sharedServerLimit().store(static_cast<ServerLimit>(0), std::memory_order_release);
    109 #if PLATFORM(COCOA) || PLATFORM(WIN)
    110104    ServerOffset oldServerOffset = sharedServerOffset().exchange(static_cast<ServerOffset>(0), std::memory_order_acq_rel);
    111105    // If the client wrote over serverOffset, it means the client is waiting.
     
    114108    else
    115109        ASSERT(!(oldServerOffset & ServerOffset::clientIsWaitingTag));
    116 #else
    117     sharedServerOffset().store(static_cast<ServerOffset>(0), std::memory_order_release);
    118     // IPC::Semaphore not implemented for the platform. Client will poll and yield.
    119 #endif
    120110    m_serverOffset = 0;
    121111}
  • trunk/Source/WebKit/Platform/IPC/unix/IPCSemaphoreUnix.cpp

    r275552 r275553  
    2727#include "IPCSemaphore.h"
    2828
    29 #if !OS(DARWIN) && !OS(WINDOWS)
    30 
    3129namespace IPC {
    3230
    33 Semaphore::Semaphore() = default;
     31Semaphore::Semaphore()
     32{
     33    ASSERT_NOT_REACHED();
     34}
    3435
    35 Semaphore::Semaphore(Semaphore&&) = default;
     36Semaphore::Semaphore(Semaphore&&)
     37{
     38    ASSERT_NOT_REACHED();
     39}
    3640
    3741Semaphore::~Semaphore() = default;
     
    3943Semaphore& Semaphore::operator=(Semaphore&&) = default;
    4044
    41 void Semaphore::encode(Encoder&) const { }
     45void Semaphore::signal()
     46{
     47}
     48
     49void Semaphore::wait()
     50{
     51}
     52
     53bool Semaphore::waitFor(Timeout)
     54{
     55    return false;
     56}
     57
     58void Semaphore::encode(Encoder&) const
     59{
     60}
    4261
    4362Optional<Semaphore> Semaphore::decode(Decoder&)
     
    4665}
    4766
     67void Semaphore::destroy()
     68{
    4869}
    4970
    50 #endif
     71} // namespace IPC
  • trunk/Source/WebKit/PlatformPlayStation.cmake

    r271360 r275553  
    5353    Platform/IPC/unix/AttachmentUnix.cpp
    5454    Platform/IPC/unix/ConnectionUnix.cpp
     55    Platform/IPC/unix/IPCSemaphoreUnix.cpp
    5556
    5657    Platform/classifier/ResourceLoadStatisticsClassifier.cpp
  • trunk/Source/WebKit/Sources.txt

    r275537 r275553  
    147147Platform/IPC/Decoder.cpp @no-unify
    148148Platform/IPC/Encoder.cpp @no-unify
    149 Platform/IPC/IPCSemaphore.cpp @no-unify
    150149Platform/IPC/JSIPCBinding.cpp @no-unify
    151150Platform/IPC/MessageReceiveQueueMap.cpp @no-unify
  • trunk/Source/WebKit/SourcesGTK.txt

    r274815 r275553  
    5353Platform/IPC/unix/AttachmentUnix.cpp
    5454Platform/IPC/unix/ConnectionUnix.cpp
     55Platform/IPC/unix/IPCSemaphoreUnix.cpp
    5556
    5657Platform/classifier/ResourceLoadStatisticsClassifier.cpp
  • trunk/Source/WebKit/SourcesWPE.txt

    r273131 r275553  
    5353Platform/IPC/unix/AttachmentUnix.cpp
    5454Platform/IPC/unix/ConnectionUnix.cpp
     55Platform/IPC/unix/IPCSemaphoreUnix.cpp
    5556
    5657Platform/classifier/ResourceLoadStatisticsClassifier.cpp
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r275537 r275553  
    16011601                A1FB68241F6E518200C43F9F /* WKCrashReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1FB68221F6E518200C43F9F /* WKCrashReporter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16021602                A31F60A425CC7DB900AF14F4 /* IPCSemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = A31F60A225CC7DB800AF14F4 /* IPCSemaphore.h */; };
    1603                 A31F60A525CC7DB900AF14F4 /* IPCSemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A31F60A325CC7DB800AF14F4 /* IPCSemaphore.cpp */; };
    16041603                A513F5402154A5D700662841 /* WebPageInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = A513F53E2154A5CC00662841 /* WebPageInspectorController.h */; };
    16051604                A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = A518B5D01FE1D55B00F9FA28 /* WKInspectorWKWebView.h */; };
     
    50595058                A1FB68231F6E518200C43F9F /* WKCrashReporter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKCrashReporter.mm; sourceTree = "<group>"; };
    50605059                A31F60A225CC7DB800AF14F4 /* IPCSemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPCSemaphore.h; sourceTree = "<group>"; };
    5061                 A31F60A325CC7DB800AF14F4 /* IPCSemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IPCSemaphore.cpp; sourceTree = "<group>"; };
    50625060                A31F60A625CC7DCF00AF14F4 /* IPCSemaphoreDarwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IPCSemaphoreDarwin.cpp; sourceTree = "<group>"; };
    50635061                A38A12E123C93AC700FABFA9 /* TextChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextChecker.cpp; sourceTree = "<group>"; };
     
    70447042                                4151E5C31FBB90A900E47E2D /* FormDataReference.h */,
    70457043                                C0CE72AC1247E78D00BC0EC4 /* HandleMessage.h */,
    7046                                 A31F60A325CC7DB800AF14F4 /* IPCSemaphore.cpp */,
    70477044                                A31F60A225CC7DB800AF14F4 /* IPCSemaphore.h */,
    70487045                                9BF5EC6325410E9900984E77 /* JSIPCBinding.cpp */,
     
    1391613913                                2749F6442146561B008380BF /* InjectedBundleNodeHandle.cpp in Sources */,
    1391713914                                2749F6452146561E008380BF /* InjectedBundleRangeHandle.cpp in Sources */,
    13918                                 A31F60A525CC7DB900AF14F4 /* IPCSemaphore.cpp in Sources */,
    1391913915                                9BF5EC642541145600984E77 /* JSIPCBinding.cpp in Sources */,
    1392013916                                2D913441212CF9F000128AFD /* JSNPMethod.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp

    r275240 r275553  
    181181{
    182182    ASSERT(m_getImageDataSemaphore);
    183 #if OS(DARWIN)
    184183    return m_getImageDataSemaphore->waitFor(timeout);
    185 #else
    186     return true;
    187 #endif
    188184}
    189185
     
    327323        if (m_deferredWakeupMessageArguments) {
    328324            if (sharedHandle->tryToResume({ m_deferredWakeupMessageArguments->offset, m_deferredWakeupMessageArguments->destinationImageBufferIdentifier.toUInt64() })) {
    329 #if PLATFORM(COCOA)
    330325                m_resumeDisplayListSemaphore.signal();
    331 #endif
    332326                m_deferredWakeupMessageArguments = WTF::nullopt;
    333327                m_remainingItemsToAppendBeforeSendingWakeup = 0;
     
    344338    auto offsetToRead = sharedHandle->writableOffset() - numberOfBytes;
    345339    if (sharedHandle->tryToResume({ offsetToRead, destinationImageBuffer.toUInt64() })) {
    346 #if PLATFORM(COCOA)
    347340        m_resumeDisplayListSemaphore.signal();
    348 #endif
    349341        return;
    350342    }
  • trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp

    r274459 r275553  
    7575void RemoteAudioDestinationProxy::startRenderingThread()
    7676{
    77 #if PLATFORM(COCOA)
    7877    ASSERT(!m_renderThread);
    7978
     
    8887    };
    8988    m_renderThread = Thread::create("RemoteAudioDestinationProxy render thread", WTFMove(offThreadRendering), ThreadType::Audio, Thread::QOS::UserInteractive);
    90 #endif
    9189}
    9290
    9391void RemoteAudioDestinationProxy::stopRenderingThread()
    9492{
    95 #if PLATFORM(COCOA)
    9693    if (!m_renderThread)
    9794        return;
     
    10198    m_renderThread->waitForCompletion();
    10299    m_renderThread = nullptr;
    103 #endif
    104100}
    105101
Note: See TracChangeset for help on using the changeset viewer.