Title: [270661] trunk
Revision
270661
Author
[email protected]
Date
2020-12-10 16:17:23 -0800 (Thu, 10 Dec 2020)

Log Message

Unreviewed, re-landing r270132.

Regression test failures have been resolved.

Re-landed changeset:

"Use a Version 1 CFRunLoopSource for faster task dispatch"
https://bugs.webkit.org/show_bug.cgi?id=202874
https://trac.webkit.org/changeset/270132

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (270660 => 270661)


--- trunk/Source/WTF/ChangeLog	2020-12-10 23:26:49 UTC (rev 270660)
+++ trunk/Source/WTF/ChangeLog	2020-12-11 00:17:23 UTC (rev 270661)
@@ -1,3 +1,15 @@
+2020-12-10  Geoffrey Garen  <[email protected]>
+
+        Unreviewed, re-landing r270132.
+
+        Regression test failures have been resolved.
+
+        Re-landed changeset:
+
+        "Use a Version 1 CFRunLoopSource for faster task dispatch"
+        https://bugs.webkit.org/show_bug.cgi?id=202874
+        https://trac.webkit.org/changeset/270132
+
 2020-12-10  Dean Jackson  <[email protected]>
 
         Add runtime flag for ANGLE on Metal

Modified: trunk/Source/WTF/wtf/RunLoop.h (270660 => 270661)


--- trunk/Source/WTF/wtf/RunLoop.h	2020-12-10 23:26:49 UTC (rev 270660)
+++ trunk/Source/WTF/wtf/RunLoop.h	2020-12-11 00:17:23 UTC (rev 270661)
@@ -227,9 +227,10 @@
 
     Lock m_loopLock;
 #elif USE(COCOA_EVENT_LOOP)
-    static void performWork(void*);
+    static void performWork(CFMachPortRef, void* msg, CFIndex size, void* info);
     RetainPtr<CFRunLoopRef> m_runLoop;
     RetainPtr<CFRunLoopSourceRef> m_runLoopSource;
+    RetainPtr<CFMachPortRef> m_port;
 #elif USE(GLIB_EVENT_LOOP)
     void notify(Event, const char*);
 

Modified: trunk/Source/WTF/wtf/cf/RunLoopCF.cpp (270660 => 270661)


--- trunk/Source/WTF/wtf/cf/RunLoopCF.cpp	2020-12-10 23:26:49 UTC (rev 270660)
+++ trunk/Source/WTF/wtf/cf/RunLoopCF.cpp	2020-12-11 00:17:23 UTC (rev 270661)
@@ -28,6 +28,7 @@
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <dispatch/dispatch.h>
+#include <mach/mach.h>
 #include <wtf/AutodrainedPool.h>
 #include <wtf/SchedulePair.h>
 
@@ -40,29 +41,39 @@
     return adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval.seconds(), repeatInterval.seconds(), 0, 0, timerFired, &context));
 }
 
-void RunLoop::performWork(void* context)
+void RunLoop::performWork(CFMachPortRef, void*, CFIndex, void* info)
 {
     AutodrainedPool pool;
-    static_cast<RunLoop*>(context)->performWork();
+    static_cast<RunLoop*>(info)->performWork();
 }
 
 RunLoop::RunLoop()
     : m_runLoop(CFRunLoopGetCurrent())
 {
-    CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, performWork };
-    m_runLoopSource = adoptCF(CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context));
+    CFMachPortContext context = { 0, this, nullptr, nullptr, nullptr };
+    m_port = adoptCF(CFMachPortCreate(kCFAllocatorDefault, performWork, &context, nullptr));
+    m_runLoopSource = adoptCF(CFMachPortCreateRunLoopSource(kCFAllocatorDefault, m_port.get(), 0));
     CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopCommonModes);
 }
 
 RunLoop::~RunLoop()
 {
+    CFMachPortInvalidate(m_port.get());
     CFRunLoopSourceInvalidate(m_runLoopSource.get());
 }
 
 void RunLoop::wakeUp()
 {
-    CFRunLoopSourceSignal(m_runLoopSource.get());
-    CFRunLoopWakeUp(m_runLoop.get());
+    mach_msg_header_t header;
+    header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
+    header.msgh_size = sizeof(mach_msg_header_t);
+    header.msgh_remote_port = CFMachPortGetPort(m_port.get());
+    header.msgh_local_port = MACH_PORT_NULL;
+    header.msgh_id = 0;
+    mach_msg_return_t result = mach_msg(&header, MACH_SEND_MSG | MACH_SEND_TIMEOUT, header.msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+    RELEASE_ASSERT(result == MACH_MSG_SUCCESS || result == MACH_SEND_TIMED_OUT);
+    if (result == MACH_SEND_TIMED_OUT)
+        mach_msg_destroy(&header);
 }
 
 RunLoop::CycleResult RunLoop::cycle(RunLoopMode mode)

Modified: trunk/Tools/ChangeLog (270660 => 270661)


--- trunk/Tools/ChangeLog	2020-12-10 23:26:49 UTC (rev 270660)
+++ trunk/Tools/ChangeLog	2020-12-11 00:17:23 UTC (rev 270661)
@@ -1,3 +1,15 @@
+2020-12-10  Geoffrey Garen  <[email protected]>
+
+        Unreviewed, re-landing r270132.
+
+        Regression test failures have been resolved.
+
+        Re-landed changeset:
+
+        "Use a Version 1 CFRunLoopSource for faster task dispatch"
+        https://bugs.webkit.org/show_bug.cgi?id=202874
+        https://trac.webkit.org/changeset/270132
+
 2020-12-10  Don Olmstead  <[email protected]>
 
         [CMake] Determine when to use $<TARGET_OBJECTS> for executables

Modified: trunk/Tools/TestWebKitAPI/cocoa/UtilitiesCocoa.mm (270660 => 270661)


--- trunk/Tools/TestWebKitAPI/cocoa/UtilitiesCocoa.mm	2020-12-10 23:26:49 UTC (rev 270660)
+++ trunk/Tools/TestWebKitAPI/cocoa/UtilitiesCocoa.mm	2020-12-11 00:17:23 UTC (rev 270661)
@@ -38,7 +38,7 @@
 void spinRunLoop(uint64_t count)
 {
     for (uint64_t i = 0; i < count; ++i)
-        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
+        while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource) { }
 }
 
 void sleep(double seconds)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to