⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181549 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 5:20:59 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r181486 - Prohibit GC while sweeping
https://bugs.webkit.org/show_bug.cgi?id=142638

Reviewed by Andreas Kling.

I noticed in https://bugs.webkit.org/show_bug.cgi?id=142636 that a GC
could trigger a sweep which could trigger another GC. Yo Dawg.

I tried to figure out whether this could cause problems or not and it
made me cross-eyed.

(Some clients like to report extra memory cost during deallocation as a
way to indicate that the GC now owns something exclusively. It's
arguably a bug to communicate with the GC in this way, but we shouldn't
do crazy when this happens.)

This patch makes explicit the fact that we don't allow GC while sweeping.

Usually, sweeping implicitly defers GC by virtue of happening during
allocation. But not always.

  • heap/Heap.cpp:

(JSC::Heap::collectAllGarbage): Defer GC while sweeping due to an
explicit GC request.

(JSC::Heap::didFinishCollection): Make sure that zombifying sweep
defers GC by not returning to the non-GC state until we're all done.

  • heap/IncrementalSweeper.cpp:

(JSC::IncrementalSweeper::sweepNextBlock): Defer GC while sweeping due
to a timer.

Location:
releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/ChangeLog

    r181547 r181549  
     12015-03-12  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Prohibit GC while sweeping
     4        https://bugs.webkit.org/show_bug.cgi?id=142638
     5
     6        Reviewed by Andreas Kling.
     7
     8        I noticed in https://bugs.webkit.org/show_bug.cgi?id=142636 that a GC
     9        could trigger a sweep which could trigger another GC. Yo Dawg.
     10
     11        I tried to figure out whether this could cause problems or not and it
     12        made me cross-eyed.
     13
     14        (Some clients like to report extra memory cost during deallocation as a
     15        way to indicate that the GC now owns something exclusively. It's
     16        arguably a bug to communicate with the GC in this way, but we shouldn't
     17        do crazy when this happens.)
     18
     19        This patch makes explicit the fact that we don't allow GC while sweeping.
     20
     21        Usually, sweeping implicitly defers GC by virtue of happening during
     22        allocation. But not always.
     23
     24        * heap/Heap.cpp:
     25        (JSC::Heap::collectAllGarbage): Defer GC while sweeping due to an
     26        explicit GC request.
     27
     28        (JSC::Heap::didFinishCollection): Make sure that zombifying sweep
     29        defers GC by not returning to the non-GC state until we're all done.
     30
     31        * heap/IncrementalSweeper.cpp:
     32        (JSC::IncrementalSweeper::sweepNextBlock): Defer GC while sweeping due
     33        to a timer.
     34
    1352015-03-13  Mark Lam  <mark.lam@apple.com>
    236
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/heap/Heap.cpp

    r181533 r181549  
    975975
    976976    SamplingRegion samplingRegion("Garbage Collection: Sweeping");
     977
     978    DeferGCForAWhile deferGC(*this);
    977979    m_objectSpace.sweep();
    978980    m_objectSpace.shrink();
     
    12771279    if (Options::recordGCPauseTimes())
    12781280        HeapStatistics::recordGCPauseTime(gcStartTime, gcEndTime);
     1281
     1282    if (Options::useZombieMode())
     1283        zombifyDeadObjects();
     1284
     1285    if (Options::objectsAreImmortal())
     1286        markDeadObjects();
     1287
     1288    if (Options::showObjectStatistics())
     1289        HeapStatistics::showObjectStatistics(this);
     1290
     1291    if (Options::logGC() == GCLogging::Verbose)
     1292        GCLogging::dumpObjectGraph(this);
     1293
    12791294    RELEASE_ASSERT(m_operationInProgress == EdenCollection || m_operationInProgress == FullCollection);
    1280 
    12811295    m_operationInProgress = NoOperation;
    12821296    JAVASCRIPTCORE_GC_END();
    1283 
    1284     if (Options::useZombieMode())
    1285         zombifyDeadObjects();
    1286 
    1287     if (Options::objectsAreImmortal())
    1288         markDeadObjects();
    1289 
    1290     if (Options::showObjectStatistics())
    1291         HeapStatistics::showObjectStatistics(this);
    1292 
    1293     if (Options::logGC() == GCLogging::Verbose)
    1294         GCLogging::dumpObjectGraph(this);
    12951297}
    12961298
  • releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/heap/IncrementalSweeper.cpp

    r179728 r181549  
    9191            continue;
    9292
     93        DeferGCForAWhile deferGC(m_vm->heap);
    9394        block->sweep();
    9495        m_vm->heap.objectSpace().freeOrShrinkBlock(block);
Note: See TracChangeset for help on using the changeset viewer.