Title: [190324] trunk/Source
Revision
190324
Author
fpi...@apple.com
Date
2015-09-29 13:25:42 -0700 (Tue, 29 Sep 2015)

Log Message

ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
https://bugs.webkit.org/show_bug.cgi?id=149635

Reviewed by Saam Barati.

Source/_javascript_Core:

It bugged me that this change caused a whole-world recompile. So, I changed the code so
that ParallelHelperPool.h is only included by Heap.cpp and not by Heap.h.

* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::markRoots):
(JSC::Heap::copyBackingStores):
* heap/Heap.h:

Source/WTF:

* wtf/ParallelHelperPool.h:
(WTF::ParallelHelperClient::runFunctionInParallel): Stack-allocate the task instead of heap-allocating it.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (190323 => 190324)


--- trunk/Source/_javascript_Core/ChangeLog	2015-09-29 20:22:18 UTC (rev 190323)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-09-29 20:25:42 UTC (rev 190324)
@@ -1,5 +1,21 @@
 2015-09-29  Filip Pizlo  <fpi...@apple.com>
 
+        ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
+        https://bugs.webkit.org/show_bug.cgi?id=149635
+
+        Reviewed by Saam Barati.
+
+        It bugged me that this change caused a whole-world recompile. So, I changed the code so
+        that ParallelHelperPool.h is only included by Heap.cpp and not by Heap.h.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        (JSC::Heap::markRoots):
+        (JSC::Heap::copyBackingStores):
+        * heap/Heap.h:
+
+2015-09-29  Filip Pizlo  <fpi...@apple.com>
+
         GC copy phase spans too many files
         https://bugs.webkit.org/show_bug.cgi?id=149586
 

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (190323 => 190324)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2015-09-29 20:22:18 UTC (rev 190323)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2015-09-29 20:25:42 UTC (rev 190324)
@@ -53,6 +53,7 @@
 #include <algorithm>
 #include <wtf/RAMSize.h>
 #include <wtf/CurrentTime.h>
+#include <wtf/ParallelHelperPool.h>
 #include <wtf/ParallelVectorIterator.h>
 #include <wtf/ProcessID.h>
 
@@ -357,7 +358,7 @@
 #if USE(CF)
     , m_delayedReleaseRecursionCount(0)
 #endif
-    , m_helperClient(&heapHelperPool())
+    , m_helperClient(std::make_unique<ParallelHelperClient>(&heapHelperPool()))
 {
     m_storageSpace.init();
     if (Options::verifyHeap())
@@ -547,7 +548,7 @@
 
     m_parallelMarkersShouldExit = false;
 
-    m_helperClient.setFunction(
+    m_helperClient->setFunction(
         [this] () {
             SlotVisitor* slotVisitor;
             {
@@ -604,7 +605,7 @@
         m_parallelMarkersShouldExit = true;
         m_markingConditionVariable.notifyAll();
     }
-    m_helperClient.finish();
+    m_helperClient->finish();
     updateObjectCounts(gcStartTime);
     resetVisitors();
 }
@@ -637,7 +638,7 @@
         // that other threads run. That's because after runFunctionInParallel() returns, the task
         // we have created is not going to be running anymore. Hence, everything on the stack here
         // outlives the task.
-        m_helperClient.runFunctionInParallel(
+        m_helperClient->runFunctionInParallel(
             [&] () {
                 CopyVisitor copyVisitor(*this);
                 

Modified: trunk/Source/_javascript_Core/heap/Heap.h (190323 => 190324)


--- trunk/Source/_javascript_Core/heap/Heap.h	2015-09-29 20:22:18 UTC (rev 190323)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2015-09-29 20:25:42 UTC (rev 190324)
@@ -45,8 +45,12 @@
 #include "WriteBarrierSupport.h"
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
-#include <wtf/ParallelHelperPool.h>
 
+namespace WTF {
+class ParallelHelperClient;
+}
+using WTF::ParallelHelperClient;
+
 namespace JSC {
 
 class CopiedSpace;
@@ -441,7 +445,7 @@
     ListableHandler<WeakReferenceHarvester>::List m_weakReferenceHarvesters;
     ListableHandler<UnconditionalFinalizer>::List m_unconditionalFinalizers;
 
-    ParallelHelperClient m_helperClient;
+    std::unique_ptr<ParallelHelperClient> m_helperClient;
 };
 
 } // namespace JSC

Modified: trunk/Source/WTF/ChangeLog (190323 => 190324)


--- trunk/Source/WTF/ChangeLog	2015-09-29 20:22:18 UTC (rev 190323)
+++ trunk/Source/WTF/ChangeLog	2015-09-29 20:25:42 UTC (rev 190324)
@@ -1,5 +1,15 @@
 2015-09-29  Filip Pizlo  <fpi...@apple.com>
 
+        ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
+        https://bugs.webkit.org/show_bug.cgi?id=149635
+
+        Reviewed by Saam Barati.
+
+        * wtf/ParallelHelperPool.h:
+        (WTF::ParallelHelperClient::runFunctionInParallel): Stack-allocate the task instead of heap-allocating it.
+
+2015-09-29  Filip Pizlo  <fpi...@apple.com>
+
         GC copy phase spans too many files
         https://bugs.webkit.org/show_bug.cgi?id=149586
 

Modified: trunk/Source/WTF/wtf/ParallelHelperPool.h (190323 => 190324)


--- trunk/Source/WTF/wtf/ParallelHelperPool.h	2015-09-29 20:22:18 UTC (rev 190323)
+++ trunk/Source/WTF/wtf/ParallelHelperPool.h	2015-09-29 20:25:42 UTC (rev 190324)
@@ -148,14 +148,19 @@
     // client->finish();
     WTF_EXPORT_PRIVATE void runTaskInParallel(RefPtr<SharedTask>);
 
-    // Equivalent to:
+    // Semantically equivalent to:
     // client->setFunction(functor);
     // client->doSomeHelping();
     // client->finish();
+    //
+    // Except, unlike the above sequence, this won't allocate the task in the heap. This allocates
+    // the task on the stack because it knows that the task is not reachable after this method is
+    // done.
     template<typename Functor>
     void runFunctionInParallel(const Functor& functor)
     {
-        runTaskInParallel(createSharedTask(functor));
+        SharedTaskFunctor<Functor> sharedTask(functor);
+        runTaskInParallel(&sharedTask);
     }
 
     ParallelHelperPool& pool() { return *m_pool; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to