Title: [261328] trunk/Source
Revision
261328
Author
mark....@apple.com
Date
2020-05-07 12:49:37 -0700 (Thu, 07 May 2020)

Log Message

Give the DFG and FTL WorkList threads more stack space on ASAN builds.
https://bugs.webkit.org/show_bug.cgi?id=211535
<rdar://problem/62947884>

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* dfg/DFGWorklist.cpp:
(JSC::DFG::Worklist::ThreadBody::ThreadBody):
- Mark the AutomaticThread as ThreadType::Compiler.

Source/WTF:

1. Add the ability to set the ThreadType for AutomaticThreads.
2. Give ThreadType::Compiler (which currently only used for the DFG anf FTL
   WorkList threads) a larger stack for OS(DARWIN) on ASAN builds.

   This is needed because ASAN is a memory hungry beast, and we want the ASAN
   builds to get to exercise the same amount of code a regular build will (instead
   of failing out early with a stack overflow error).

* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::AutomaticThread):
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h:
* wtf/Threading.cpp:
(WTF::stackSize):
* wtf/Threading.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (261327 => 261328)


--- trunk/Source/_javascript_Core/ChangeLog	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,3 +1,15 @@
+2020-05-07  Mark Lam  <mark....@apple.com>
+
+        Give the DFG and FTL WorkList threads more stack space on ASAN builds.
+        https://bugs.webkit.org/show_bug.cgi?id=211535
+        <rdar://problem/62947884>
+
+        Reviewed by Geoffrey Garen.
+
+        * dfg/DFGWorklist.cpp:
+        (JSC::DFG::Worklist::ThreadBody::ThreadBody):
+        - Mark the AutomaticThread as ThreadType::Compiler.
+
 2020-05-07  Daniel Kolesa  <dan...@octaforge.org>
 
         REGRESSION(r251875): Crash in JSC::StructureIDTable::get on ppc64le: gcSafeMemcpy broken on JSVALUE64 platforms other than x86_64 and aarch64

Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp (261327 => 261328)


--- trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2020-05-07 19:49:37 UTC (rev 261328)
@@ -40,7 +40,7 @@
 class Worklist::ThreadBody : public AutomaticThread {
 public:
     ThreadBody(const AbstractLocker& locker, Worklist& worklist, ThreadData& data, Box<Lock> lock, Ref<AutomaticThreadCondition>&& condition, int relativePriority)
-        : AutomaticThread(locker, lock, WTFMove(condition))
+        : AutomaticThread(locker, lock, WTFMove(condition), ThreadType::Compiler)
         , m_worklist(worklist)
         , m_data(data)
         , m_relativePriority(relativePriority)

Modified: trunk/Source/WTF/ChangeLog (261327 => 261328)


--- trunk/Source/WTF/ChangeLog	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/WTF/ChangeLog	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,5 +1,29 @@
 2020-05-07  Mark Lam  <mark....@apple.com>
 
+        Give the DFG and FTL WorkList threads more stack space on ASAN builds.
+        https://bugs.webkit.org/show_bug.cgi?id=211535
+        <rdar://problem/62947884>
+
+        Reviewed by Geoffrey Garen.
+
+        1. Add the ability to set the ThreadType for AutomaticThreads.
+        2. Give ThreadType::Compiler (which currently only used for the DFG anf FTL
+           WorkList threads) a larger stack for OS(DARWIN) on ASAN builds.
+
+           This is needed because ASAN is a memory hungry beast, and we want the ASAN
+           builds to get to exercise the same amount of code a regular build will (instead
+           of failing out early with a stack overflow error).
+
+        * wtf/AutomaticThread.cpp:
+        (WTF::AutomaticThread::AutomaticThread):
+        (WTF::AutomaticThread::start):
+        * wtf/AutomaticThread.h:
+        * wtf/Threading.cpp:
+        (WTF::stackSize):
+        * wtf/Threading.h:
+
+2020-05-07  Mark Lam  <mark....@apple.com>
+
         Add stack checks to the DFG and FTL bytecode parser.
         https://bugs.webkit.org/show_bug.cgi?id=211547
         <rdar://problem/62958880>

Modified: trunk/Source/WTF/wtf/AutomaticThread.cpp (261327 => 261328)


--- trunk/Source/WTF/wtf/AutomaticThread.cpp	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/WTF/wtf/AutomaticThread.cpp	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -105,9 +105,15 @@
 }
 
 AutomaticThread::AutomaticThread(const AbstractLocker& locker, Box<Lock> lock, Ref<AutomaticThreadCondition>&& condition, Seconds timeout)
+    : AutomaticThread(locker, lock, WTFMove(condition), ThreadType::Unknown, timeout)
+{
+}
+
+AutomaticThread::AutomaticThread(const AbstractLocker& locker, Box<Lock> lock, Ref<AutomaticThreadCondition>&& condition, ThreadType type, Seconds timeout)
     : m_lock(lock)
     , m_condition(WTFMove(condition))
     , m_timeout(timeout)
+    , m_threadType(type)
 {
     if (verbose)
         dataLog(RawPointer(this), ": Allocated AutomaticThread.\n");
@@ -227,7 +233,7 @@
                 }
                 RELEASE_ASSERT(result == WorkResult::Continue);
             }
-        })->detach();
+        }, m_threadType)->detach();
 }
 
 void AutomaticThread::threadDidStart()

Modified: trunk/Source/WTF/wtf/AutomaticThread.h (261327 => 261328)


--- trunk/Source/WTF/wtf/AutomaticThread.h	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/WTF/wtf/AutomaticThread.h	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
 #include <wtf/Condition.h>
 #include <wtf/Lock.h>
 #include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/Threading.h>
 #include <wtf/Vector.h>
 
 namespace WTF {
@@ -131,6 +132,8 @@
     // This logically creates the thread, but in reality the thread won't be created until someone
     // calls AutomaticThreadCondition::notifyOne() or notifyAll().
     AutomaticThread(const AbstractLocker&, Box<Lock>, Ref<AutomaticThreadCondition>&&, Seconds timeout = 10_s);
+
+    AutomaticThread(const AbstractLocker&, Box<Lock>, Ref<AutomaticThreadCondition>&&, ThreadType, Seconds timeout = 10_s);
     
     // To understand PollResult and WorkResult, imagine that poll() and work() are being called like
     // so:
@@ -183,6 +186,7 @@
     Box<Lock> m_lock;
     Ref<AutomaticThreadCondition> m_condition;
     Seconds m_timeout;
+    ThreadType m_threadType { ThreadType::Unknown };
     bool m_isRunning { true };
     bool m_isWaiting { false };
     bool m_hasUnderlyingThread { false };

Modified: trunk/Source/WTF/wtf/Threading.cpp (261327 => 261328)


--- trunk/Source/WTF/wtf/Threading.cpp	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/WTF/wtf/Threading.cpp	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2020 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,7 +52,10 @@
     // Enable STACK_STATS in StackStats.h to create a build that will track the information for tuning.
 #if PLATFORM(PLAYSTATION)
     if (threadType == ThreadType::_javascript_)
-        return 512 * 1024;
+        return 512 * KB;
+#elif OS(DARWIN) && ASAN_ENABLED
+    if (threadType == ThreadType::Compiler)
+        return 1 * MB; // ASan needs more stack space (especially on Debug builds).
 #else
     UNUSED_PARAM(threadType);
 #endif

Modified: trunk/Source/WTF/wtf/Threading.h (261327 => 261328)


--- trunk/Source/WTF/wtf/Threading.h	2020-05-07 19:36:01 UTC (rev 261327)
+++ trunk/Source/WTF/wtf/Threading.h	2020-05-07 19:49:37 UTC (rev 261328)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2020 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Justin Haygood <jhayg...@reaktix.com>
  * Copyright (C) 2017 Yusuke Suzuki <utatane....@gmail.com>
  *
@@ -85,6 +85,7 @@
 enum class ThreadType : uint8_t {
     Unknown = 0,
     _javascript_,
+    Compiler,
     GarbageCollection,
     Network,
     Graphics,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to