Title: [294632] trunk
Revision
294632
Author
[email protected]
Date
2022-05-23 04:21:02 -0700 (Mon, 23 May 2022)

Log Message

[JSC] Do not use bytecode cache on $.agent worker threads

Patch by Geza Lore <[email protected]> on 2022-05-23
https://bugs.webkit.org/show_bug.cgi?id=240642

Reviewed by Yusuke Suzuki.

Workers started via $.agent.start are not shut down in a synchronous
manner, and it is possible the main thread terminates the process while
a worker is writing its bytecode cache, which results in intermittent
test failures. As $.agent.start is only a rarely used testing facility,
we simply do not cache bytecode on these threads.

Also un-skip test on ARMv7 that used to fail because of this.

* Source/_javascript_Core/jsc.cpp:
(Worker::isMain const):
(Worker::Worker):
(runJSC):
 * JSTests/stress/lars-sab-workers.js:

Canonical link: https://commits.webkit.org/250858@main

Modified Paths

Diff

Modified: trunk/JSTests/stress/lars-sab-workers.js (294631 => 294632)


--- trunk/JSTests/stress/lars-sab-workers.js	2022-05-23 10:37:07 UTC (rev 294631)
+++ trunk/JSTests/stress/lars-sab-workers.js	2022-05-23 11:21:02 UTC (rev 294632)
@@ -1,4 +1,3 @@
-//@ skip if $architecture == "arm"
 //@ defaultRunNoisyTest
 var sab = new SharedArrayBuffer(100 * 4);
 

Modified: trunk/Source/_javascript_Core/jsc.cpp (294631 => 294632)


--- trunk/Source/_javascript_Core/jsc.cpp	2022-05-23 10:37:07 UTC (rev 294631)
+++ trunk/Source/_javascript_Core/jsc.cpp	2022-05-23 11:21:02 UTC (rev 294632)
@@ -229,12 +229,13 @@
 
 class Worker : public BasicRawSentinelNode<Worker> {
 public:
-    Worker(Workers&);
+    Worker(Workers&, bool isMain);
     ~Worker();
     
     void enqueue(const AbstractLocker&, RefPtr<Message>);
     RefPtr<Message> dequeue();
-    
+    bool isMain() const { return m_isMain; }
+
     static Worker& current();
 
 private:
@@ -242,6 +243,7 @@
 
     Workers& m_workers;
     Deque<RefPtr<Message>> m_messages;
+    const bool m_isMain;
 };
 
 class Workers {
@@ -1129,16 +1131,19 @@
 
     ShellSourceProvider(const String& source, const SourceOrigin& sourceOrigin, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType sourceType)
         : StringSourceProvider(source, sourceOrigin, WTFMove(sourceURL), startPosition, sourceType)
-    {
-    }
+        // Workers started via $.agent.start are not shut down in a synchronous manner, and it
+        // is possible the main thread terminates the process while a worker is writing its
+        // bytecode cache, which results in intermittent test failures. As $.agent.start is only
+        // a rarely used testing facility, we simply do not cache bytecode on these threads.
+        , m_cacheEnabled(Worker::current().isMain() && !!Options::diskCachePath())
 
-    static bool cacheEnabled()
     {
-        static bool enabled = !!Options::diskCachePath();
-        return enabled;
     }
 
+    bool cacheEnabled() const { return m_cacheEnabled; }
+
     mutable RefPtr<CachedBytecode> m_cachedBytecode;
+    const bool m_cacheEnabled;
 };
 
 static inline SourceCode jscSource(const String& source, const SourceOrigin& sourceOrigin, String sourceURL = String(), const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
@@ -1925,8 +1930,9 @@
 {
 }
 
-Worker::Worker(Workers& workers)
+Worker::Worker(Workers& workers, bool isMain)
     : m_workers(workers)
+    , m_isMain(isMain)
 {
     Locker locker { m_workers.m_lock };
     m_workers.m_workers.append(this);
@@ -3651,7 +3657,7 @@
 template<typename Func>
 int runJSC(const CommandLine& options, bool isWorker, const Func& func)
 {
-    Worker worker(Workers::singleton());
+    Worker worker(Workers::singleton(), !isWorker);
     
     VM& vm = VM::create(HeapType::Large).leakRef();
     if (!isWorker && options.m_canBlockIsFalse)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to