Title: [252288] tags/Safari-609.1.10.1/Source
Revision
252288
Author
alanc...@apple.com
Date
2019-11-08 16:52:04 -0800 (Fri, 08 Nov 2019)

Log Message

Cherry-pick r252124. rdar://problem/56524251

    WTF::RunLoop should not depend on isMainThread() idiom.
    https://bugs.webkit.org/show_bug.cgi?id=203873
    <rdar://problem/56524251>

    Reviewed by Saam Barati, Ryosuke Niwa, and Devin Rousso.

    Source/_javascript_Core:

    * inspector/JSGlobalObjectScriptDebugServer.cpp:
    (Inspector::JSGlobalObjectScriptDebugServer::runLoopMode):
    * inspector/JSGlobalObjectScriptDebugServer.h:
    * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
    (Inspector::RemoteTargetInitializeGlobalQueue):
    (Inspector::RemoteConnectionToTarget::setupRunLoop):
    (Inspector::RemoteConnectionToTarget::teardownRunLoop):

    Source/WTF:

    The isMainThread() idiom is only meaningful for WebCore.  It is less meaningful
    for JSC since a VM instance can be entered from multiple threads, as long as only
    one thread enters it at any time.  Hence, the concept of a main thread doesn't
    make sense at the JSC level.

    Since r251036, we started using a WTF::String to represent the RunLoop mode.
    This caused problems for JSC clients when USE(CF) since it necessitated the use of
    StringWrapperCFAllocator to track the life cycle of the CFStringRef generated from
    the WTF::String.

    To fix this problem, we should restore the original behavior of using CFStringRefs
    as the RunLoop mode token.

    * wtf/RunLoop.h:
    (WTF::RunLoop::cycle): Deleted.
    * wtf/cf/RunLoopCF.cpp:
    (WTF::RunLoop::cycle):
    * wtf/generic/RunLoopGeneric.cpp:
    (WTF::RunLoop::cycle):
    * wtf/glib/RunLoopGLib.cpp:
    (WTF::RunLoop::cycle):
    * wtf/win/RunLoopWin.cpp:
    (WTF::RunLoop::cycle):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: tags/Safari-609.1.10.1/Source/_javascript_Core/ChangeLog (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/_javascript_Core/ChangeLog	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/_javascript_Core/ChangeLog	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,71 @@
 2019-11-07  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r252124. rdar://problem/56524251
+
+    WTF::RunLoop should not depend on isMainThread() idiom.
+    https://bugs.webkit.org/show_bug.cgi?id=203873
+    <rdar://problem/56524251>
+    
+    Reviewed by Saam Barati, Ryosuke Niwa, and Devin Rousso.
+    
+    Source/_javascript_Core:
+    
+    * inspector/JSGlobalObjectScriptDebugServer.cpp:
+    (Inspector::JSGlobalObjectScriptDebugServer::runLoopMode):
+    * inspector/JSGlobalObjectScriptDebugServer.h:
+    * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
+    (Inspector::RemoteTargetInitializeGlobalQueue):
+    (Inspector::RemoteConnectionToTarget::setupRunLoop):
+    (Inspector::RemoteConnectionToTarget::teardownRunLoop):
+    
+    Source/WTF:
+    
+    The isMainThread() idiom is only meaningful for WebCore.  It is less meaningful
+    for JSC since a VM instance can be entered from multiple threads, as long as only
+    one thread enters it at any time.  Hence, the concept of a main thread doesn't
+    make sense at the JSC level.
+    
+    Since r251036, we started using a WTF::String to represent the RunLoop mode.
+    This caused problems for JSC clients when USE(CF) since it necessitated the use of
+    StringWrapperCFAllocator to track the life cycle of the CFStringRef generated from
+    the WTF::String.
+    
+    To fix this problem, we should restore the original behavior of using CFStringRefs
+    as the RunLoop mode token.
+    
+    * wtf/RunLoop.h:
+    (WTF::RunLoop::cycle): Deleted.
+    * wtf/cf/RunLoopCF.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/generic/RunLoopGeneric.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/glib/RunLoopGLib.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/win/RunLoopWin.cpp:
+    (WTF::RunLoop::cycle):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-11-05  Mark Lam  <mark....@apple.com>
+
+            WTF::RunLoop should not depend on isMainThread() idiom.
+            https://bugs.webkit.org/show_bug.cgi?id=203873
+            <rdar://problem/56524251>
+
+            Reviewed by Saam Barati, Ryosuke Niwa, and Devin Rousso.
+
+            * inspector/JSGlobalObjectScriptDebugServer.cpp:
+            (Inspector::JSGlobalObjectScriptDebugServer::runLoopMode):
+            * inspector/JSGlobalObjectScriptDebugServer.h:
+            * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
+            (Inspector::RemoteTargetInitializeGlobalQueue):
+            (Inspector::RemoteConnectionToTarget::setupRunLoop):
+            (Inspector::RemoteConnectionToTarget::teardownRunLoop):
+
+2019-11-07  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r252006. rdar://problem/56840002
 
     Surpress ASAN in SamplingProfiler's FrameWalker::resetAtMachineFrame().

Modified: tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -64,7 +64,7 @@
     }
 }
 
-String JSGlobalObjectScriptDebugServer::runLoopMode()
+RunLoopMode JSGlobalObjectScriptDebugServer::runLoopMode()
 {
 #if USE(CF) && !PLATFORM(WATCHOS)
     // Run the RunLoop in a custom run loop mode to prevent default observers
@@ -76,9 +76,9 @@
     // FIXME: <rdar://problem/25972777>. On watchOS, in order for auto-attach to work,
     // we need to run in the default run loop mode otherwise we do not receive the XPC messages
     // necessary to setup the relay connection and negotiate an auto-attach debugger.
-    return "com.apple._javascript_Core.remote-inspector-runloop-mode"_s;
+    return CFSTR("com.apple._javascript_Core.remote-inspector-runloop-mode");
 #else
-    return { };
+    return DefaultRunLoopMode;
 #endif
 }
 

Modified: tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.h (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.h	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.h	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "ScriptDebugServer.h"
+#include <wtf/RunLoop.h>
 
 namespace Inspector {
 
@@ -38,7 +39,7 @@
 
     JSC::JSGlobalObject& globalObject() const { return m_globalObject; }
 
-    static String runLoopMode();
+    static RunLoopMode runLoopMode();
 
 private:
     void attachDebugger() override;

Modified: tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/_javascript_Core/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -89,8 +89,8 @@
         // Add to the default run loop mode for default handling, and the JSContext remote inspector run loop mode when paused.
         CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, kCFRunLoopDefaultMode);
         auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
-        if (!mode.isNull())
-            CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, mode.createCFString().get());
+        if (mode != DefaultRunLoopMode)
+            CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, mode);
     });
 }
 
@@ -262,8 +262,8 @@
 
     CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
     auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
-    if (!mode.isNull())
-        CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), mode.createCFString().get());
+    if (mode != DefaultRunLoopMode)
+        CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), mode);
 }
 
 void RemoteConnectionToTarget::teardownRunLoop()
@@ -273,8 +273,8 @@
 
     CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
     auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
-    if (!mode.isNull())
-        CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), mode.createCFString().get());
+    if (mode != DefaultRunLoopMode)
+        CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), mode);
 
     m_runLoop = nullptr;
     m_runLoopSource = nullptr;

Modified: tags/Safari-609.1.10.1/Source/WTF/ChangeLog (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/ChangeLog	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/ChangeLog	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,3 +1,85 @@
+2019-11-07  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r252124. rdar://problem/56524251
+
+    WTF::RunLoop should not depend on isMainThread() idiom.
+    https://bugs.webkit.org/show_bug.cgi?id=203873
+    <rdar://problem/56524251>
+    
+    Reviewed by Saam Barati, Ryosuke Niwa, and Devin Rousso.
+    
+    Source/_javascript_Core:
+    
+    * inspector/JSGlobalObjectScriptDebugServer.cpp:
+    (Inspector::JSGlobalObjectScriptDebugServer::runLoopMode):
+    * inspector/JSGlobalObjectScriptDebugServer.h:
+    * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
+    (Inspector::RemoteTargetInitializeGlobalQueue):
+    (Inspector::RemoteConnectionToTarget::setupRunLoop):
+    (Inspector::RemoteConnectionToTarget::teardownRunLoop):
+    
+    Source/WTF:
+    
+    The isMainThread() idiom is only meaningful for WebCore.  It is less meaningful
+    for JSC since a VM instance can be entered from multiple threads, as long as only
+    one thread enters it at any time.  Hence, the concept of a main thread doesn't
+    make sense at the JSC level.
+    
+    Since r251036, we started using a WTF::String to represent the RunLoop mode.
+    This caused problems for JSC clients when USE(CF) since it necessitated the use of
+    StringWrapperCFAllocator to track the life cycle of the CFStringRef generated from
+    the WTF::String.
+    
+    To fix this problem, we should restore the original behavior of using CFStringRefs
+    as the RunLoop mode token.
+    
+    * wtf/RunLoop.h:
+    (WTF::RunLoop::cycle): Deleted.
+    * wtf/cf/RunLoopCF.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/generic/RunLoopGeneric.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/glib/RunLoopGLib.cpp:
+    (WTF::RunLoop::cycle):
+    * wtf/win/RunLoopWin.cpp:
+    (WTF::RunLoop::cycle):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252124 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-11-05  Mark Lam  <mark....@apple.com>
+
+            WTF::RunLoop should not depend on isMainThread() idiom.
+            https://bugs.webkit.org/show_bug.cgi?id=203873
+            <rdar://problem/56524251>
+
+            Reviewed by Saam Barati, Ryosuke Niwa, and Devin Rousso.
+
+            The isMainThread() idiom is only meaningful for WebCore.  It is less meaningful
+            for JSC since a VM instance can be entered from multiple threads, as long as only
+            one thread enters it at any time.  Hence, the concept of a main thread doesn't
+            make sense at the JSC level.
+
+            Since r251036, we started using a WTF::String to represent the RunLoop mode.
+            This caused problems for JSC clients when USE(CF) since it necessitated the use of
+            StringWrapperCFAllocator to track the life cycle of the CFStringRef generated from
+            the WTF::String.
+
+            To fix this problem, we should restore the original behavior of using CFStringRefs
+            as the RunLoop mode token.
+
+            * wtf/RunLoop.h:
+            (WTF::RunLoop::cycle): Deleted.
+            * wtf/cf/RunLoopCF.cpp:
+            (WTF::RunLoop::cycle):
+            * wtf/generic/RunLoopGeneric.cpp:
+            (WTF::RunLoop::cycle):
+            * wtf/glib/RunLoopGLib.cpp:
+            (WTF::RunLoop::cycle):
+            * wtf/win/RunLoopWin.cpp:
+            (WTF::RunLoop::cycle):
+
 2019-10-31  Tim Horton  <timothy_hor...@apple.com>
 
         Turn on IOSurface support in the iOS Simulator

Modified: tags/Safari-609.1.10.1/Source/WTF/wtf/RunLoop.h (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/wtf/RunLoop.h	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/wtf/RunLoop.h	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
  *
@@ -37,6 +37,10 @@
 #include <wtf/ThreadingPrimitives.h>
 #include <wtf/text/WTFString.h>
 
+#if USE(CF)
+#include <CoreFoundation/CFRunLoop.h>
+#endif
+
 #if USE(GLIB_EVENT_LOOP)
 #include <wtf/glib/GRefPtr.h>
 #endif
@@ -43,6 +47,14 @@
 
 namespace WTF {
 
+#if USE(CF)
+using RunLoopMode = CFStringRef;
+#define DefaultRunLoopMode kCFRunLoopDefaultMode
+#else
+using RunLoopMode = unsigned;
+#define DefaultRunLoopMode 0
+#endif
+
 class RunLoop : public FunctionDispatcher {
     WTF_MAKE_NONCOPYABLE(RunLoop);
 public:
@@ -62,7 +74,7 @@
     WTF_EXPORT_PRIVATE void wakeUp();
 
     enum class CycleResult { Continue, Stop };
-    WTF_EXPORT_PRIVATE CycleResult static cycle(const String& = { });
+    WTF_EXPORT_PRIVATE CycleResult static cycle(RunLoopMode = DefaultRunLoopMode);
 
 #if USE(COCOA_EVENT_LOOP)
     WTF_EXPORT_PRIVATE void runForDuration(Seconds duration);
@@ -218,3 +230,4 @@
 } // namespace WTF
 
 using WTF::RunLoop;
+using WTF::RunLoopMode;

Modified: tags/Safari-609.1.10.1/Source/WTF/wtf/cf/RunLoopCF.cpp (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/wtf/cf/RunLoopCF.cpp	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/wtf/cf/RunLoopCF.cpp	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -62,10 +62,10 @@
     CFRunLoopWakeUp(m_runLoop.get());
 }
 
-RunLoop::CycleResult RunLoop::cycle(const String& mode)
+RunLoop::CycleResult RunLoop::cycle(RunLoopMode mode)
 {
     CFTimeInterval timeInterval = 0.05;
-    CFRunLoopRunInMode(mode.isNull() ? kCFRunLoopDefaultMode : mode.createCFString().get(), timeInterval, true);
+    CFRunLoopRunInMode(mode, timeInterval, true);
     return CycleResult::Continue;
 }
 

Modified: tags/Safari-609.1.10.1/Source/WTF/wtf/generic/RunLoopGeneric.cpp (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2019-11-09 00:52:04 UTC (rev 252288)
@@ -218,7 +218,7 @@
     wakeUp(locker);
 }
 
-RunLoop::CycleResult RunLoop::cycle(const String&)
+RunLoop::CycleResult RunLoop::cycle(RunLoopMode)
 {
     iterate();
 }

Modified: tags/Safari-609.1.10.1/Source/WTF/wtf/glib/RunLoopGLib.cpp (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/wtf/glib/RunLoopGLib.cpp	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/wtf/glib/RunLoopGLib.cpp	2019-11-09 00:52:04 UTC (rev 252288)
@@ -123,7 +123,7 @@
     g_source_set_ready_time(m_source.get(), 0);
 }
 
-RunLoop::CycleResult RunLoop::cycle(const String&)
+RunLoop::CycleResult RunLoop::cycle(RunLoopMode)
 {
     g_main_context_iteration(NULL, FALSE);
     return CycleResult::Continue;

Modified: tags/Safari-609.1.10.1/Source/WTF/wtf/win/RunLoopWin.cpp (252287 => 252288)


--- tags/Safari-609.1.10.1/Source/WTF/wtf/win/RunLoopWin.cpp	2019-11-09 00:52:00 UTC (rev 252287)
+++ tags/Safari-609.1.10.1/Source/WTF/wtf/win/RunLoopWin.cpp	2019-11-09 00:52:04 UTC (rev 252288)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -120,7 +120,7 @@
     ::PostMessage(m_runLoopMessageWindow, PerformWorkMessage, reinterpret_cast<WPARAM>(this), 0);
 }
 
-RunLoop::CycleResult RunLoop::cycle(const String&)
+RunLoop::CycleResult RunLoop::cycle(RunLoopMode)
 {
     MSG message;
     if (!::GetMessage(&message, 0, 0, 0))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to