Changeset 228152 in webkit


Ignore:
Timestamp:
Feb 5, 2018 10:50:24 PM (6 years ago)
Author:
Chris Dumez
Message:

Avoid unnecessarily constructing RunLoops for GC AutomaticThreads in Connection::sendMessage() after r228001
https://bugs.webkit.org/show_bug.cgi?id=182494
<rdar://problem/37147632>

Reviewed by Ryosuke Niwa.

Somebody fixed a GC crash in r228001 by allowing RunLoop::current() to be called from a
GC thread. However, this is still unnecessarily inefficient. Calling RunLoop::current()
will construct RunLoops for background GC threads (WTF::AutomaticThreads). This patches
updates the IPC code to call isMainThread() instead of RunLoop::isMain() in
Connection::sendMessage(). This should mean the same thing since this code runs in
WebKit2 and should be more efficient as it ends up simply calling pthread_main_np(),
without constructing a RunLoop.

  • Platform/IPC/Connection.cpp:

(IPC::Connection::sendMessage):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228151 r228152  
     12018-02-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Avoid unnecessarily constructing RunLoops for GC AutomaticThreads in Connection::sendMessage() after r228001
     4        https://bugs.webkit.org/show_bug.cgi?id=182494
     5        <rdar://problem/37147632>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Somebody fixed a GC crash in r228001 by allowing RunLoop::current() to be called from a
     10        GC thread. However, this is still unnecessarily inefficient. Calling RunLoop::current()
     11        will construct RunLoops for background GC threads (WTF::AutomaticThreads). This patches
     12        updates the IPC code to call isMainThread() instead of RunLoop::isMain() in
     13        Connection::sendMessage(). This should mean the same thing since this code runs in
     14        WebKit2 and should be more efficient as it ends up simply calling pthread_main_np(),
     15        without constructing a RunLoop.
     16
     17        * Platform/IPC/Connection.cpp:
     18        (IPC::Connection::sendMessage):
     19
    1202018-02-05  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Source/WebKit/Platform/IPC/Connection.cpp

    r227566 r228152  
    380380        return false;
    381381
    382     if (RunLoop::isMain() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == "IPC")) {
     382    if (isMainThread() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == "IPC")) {
    383383        uint64_t syncRequestID;
    384384        auto wrappedMessage = createSyncMessageEncoder("IPC", "WrappedAsyncMessageForTesting", encoder->destinationID(), syncRequestID);
Note: See TracChangeset for help on using the changeset viewer.