Changeset 190324 in webkit


Ignore:
Timestamp:
Sep 29, 2015 1:25:42 PM (9 years ago)
Author:
fpizlo@apple.com
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/JavaScriptCore:

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.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r190310 r190324  
     12015-09-29  Filip Pizlo  <fpizlo@apple.com>
     2
     3        ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
     4        https://bugs.webkit.org/show_bug.cgi?id=149635
     5
     6        Reviewed by Saam Barati.
     7
     8        It bugged me that this change caused a whole-world recompile. So, I changed the code so
     9        that ParallelHelperPool.h is only included by Heap.cpp and not by Heap.h.
     10
     11        * heap/Heap.cpp:
     12        (JSC::Heap::Heap):
     13        (JSC::Heap::markRoots):
     14        (JSC::Heap::copyBackingStores):
     15        * heap/Heap.h:
     16
    1172015-09-29  Filip Pizlo  <fpizlo@apple.com>
    218
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r190310 r190324  
    5454#include <wtf/RAMSize.h>
    5555#include <wtf/CurrentTime.h>
     56#include <wtf/ParallelHelperPool.h>
    5657#include <wtf/ParallelVectorIterator.h>
    5758#include <wtf/ProcessID.h>
     
    358359    , m_delayedReleaseRecursionCount(0)
    359360#endif
    360     , m_helperClient(&heapHelperPool())
     361    , m_helperClient(std::make_unique<ParallelHelperClient>(&heapHelperPool()))
    361362{
    362363    m_storageSpace.init();
     
    548549    m_parallelMarkersShouldExit = false;
    549550
    550     m_helperClient.setFunction(
     551    m_helperClient->setFunction(
    551552        [this] () {
    552553            SlotVisitor* slotVisitor;
     
    605606        m_markingConditionVariable.notifyAll();
    606607    }
    607     m_helperClient.finish();
     608    m_helperClient->finish();
    608609    updateObjectCounts(gcStartTime);
    609610    resetVisitors();
     
    638639        // we have created is not going to be running anymore. Hence, everything on the stack here
    639640        // outlives the task.
    640         m_helperClient.runFunctionInParallel(
     641        m_helperClient->runFunctionInParallel(
    641642            [&] () {
    642643                CopyVisitor copyVisitor(*this);
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r190310 r190324  
    4646#include <wtf/HashCountedSet.h>
    4747#include <wtf/HashSet.h>
    48 #include <wtf/ParallelHelperPool.h>
     48
     49namespace WTF {
     50class ParallelHelperClient;
     51}
     52using WTF::ParallelHelperClient;
    4953
    5054namespace JSC {
     
    442446    ListableHandler<UnconditionalFinalizer>::List m_unconditionalFinalizers;
    443447
    444     ParallelHelperClient m_helperClient;
     448    std::unique_ptr<ParallelHelperClient> m_helperClient;
    445449};
    446450
  • trunk/Source/WTF/ChangeLog

    r190310 r190324  
     12015-09-29  Filip Pizlo  <fpizlo@apple.com>
     2
     3        ParallelHelperPool::runFunctionInParallel() shouldn't allocate, and ParallelHelperPool.h shouldn't be included everywhere
     4        https://bugs.webkit.org/show_bug.cgi?id=149635
     5
     6        Reviewed by Saam Barati.
     7
     8        * wtf/ParallelHelperPool.h:
     9        (WTF::ParallelHelperClient::runFunctionInParallel): Stack-allocate the task instead of heap-allocating it.
     10
    1112015-09-29  Filip Pizlo  <fpizlo@apple.com>
    212
  • trunk/Source/WTF/wtf/ParallelHelperPool.h

    r190268 r190324  
    149149    WTF_EXPORT_PRIVATE void runTaskInParallel(RefPtr<SharedTask>);
    150150
    151     // Equivalent to:
     151    // Semantically equivalent to:
    152152    // client->setFunction(functor);
    153153    // client->doSomeHelping();
    154154    // client->finish();
     155    //
     156    // Except, unlike the above sequence, this won't allocate the task in the heap. This allocates
     157    // the task on the stack because it knows that the task is not reachable after this method is
     158    // done.
    155159    template<typename Functor>
    156160    void runFunctionInParallel(const Functor& functor)
    157161    {
    158         runTaskInParallel(createSharedTask(functor));
     162        SharedTaskFunctor<Functor> sharedTask(functor);
     163        runTaskInParallel(&sharedTask);
    159164    }
    160165
Note: See TracChangeset for help on using the changeset viewer.