Ignore:
Timestamp:
May 23, 2022, 4:21:02 AM (3 years ago)
Author:
[email protected]
Message:

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

Patch by Geza Lore <Geza Lore> 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/JavaScriptCore/jsc.cpp:

(Worker::isMain const):
(Worker::Worker):
(runJSC):

  • JSTests/stress/lars-sab-workers.js:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r294611 r294632  
    230230class Worker : public BasicRawSentinelNode<Worker> {
    231231public:
    232     Worker(Workers&);
     232    Worker(Workers&, bool isMain);
    233233    ~Worker();
    234234   
    235235    void enqueue(const AbstractLocker&, RefPtr<Message>);
    236236    RefPtr<Message> dequeue();
    237    
     237    bool isMain() const { return m_isMain; }
     238
    238239    static Worker& current();
    239240
     
    243244    Workers& m_workers;
    244245    Deque<RefPtr<Message>> m_messages;
     246    const bool m_isMain;
    245247};
    246248
     
    11301132    ShellSourceProvider(const String& source, const SourceOrigin& sourceOrigin, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType sourceType)
    11311133        : StringSourceProvider(source, sourceOrigin, WTFMove(sourceURL), startPosition, sourceType)
    1132     {
    1133     }
    1134 
    1135     static bool cacheEnabled()
    1136     {
    1137         static bool enabled = !!Options::diskCachePath();
    1138         return enabled;
    1139     }
     1134        // Workers started via $.agent.start are not shut down in a synchronous manner, and it
     1135        // is possible the main thread terminates the process while a worker is writing its
     1136        // bytecode cache, which results in intermittent test failures. As $.agent.start is only
     1137        // a rarely used testing facility, we simply do not cache bytecode on these threads.
     1138        , m_cacheEnabled(Worker::current().isMain() && !!Options::diskCachePath())
     1139
     1140    {
     1141    }
     1142
     1143    bool cacheEnabled() const { return m_cacheEnabled; }
    11401144
    11411145    mutable RefPtr<CachedBytecode> m_cachedBytecode;
     1146    const bool m_cacheEnabled;
    11421147};
    11431148
     
    19261931}
    19271932
    1928 Worker::Worker(Workers& workers)
     1933Worker::Worker(Workers& workers, bool isMain)
    19291934    : m_workers(workers)
     1935    , m_isMain(isMain)
    19301936{
    19311937    Locker locker { m_workers.m_lock };
     
    36523658int runJSC(const CommandLine& options, bool isWorker, const Func& func)
    36533659{
    3654     Worker worker(Workers::singleton());
     3660    Worker worker(Workers::singleton(), !isWorker);
    36553661   
    36563662    VM& vm = VM::create(HeapType::Large).leakRef();
Note: See TracChangeset for help on using the changeset viewer.