Changeset 206172 in webkit


Ignore:
Timestamp:
Sep 20, 2016 2:04:06 PM (8 years ago)
Author:
fpizlo@apple.com
Message:

Rename MarkedSpace::version/MarkedBlock::version to MarkedSpace::markingVersion/MarkedBlock::markingVersion
https://bugs.webkit.org/show_bug.cgi?id=162310

Reviewed by Geoffrey Garen.

In bug 162309, which is part of my concurrent GC work, I'll need to introduce a second
version-based flip. This one will be for newlyAllocated bits. This will allow me to
cheaply preserve per-object live state during marking. MarkedBlock::aboutToMarkSlow() will
do this instead of clearMarks():

  • Walk the mark bits, simultaneously counting the number of set bits and clearing them.
  • If the count is zero, then we're done.
  • If the count is equal to the max number of cells in the block, then set the allocated bit for the block.
  • If the count is something else, create a newlyAllocated vector.


The hope is that the last mode is going to be rare, since most blocks are not fragmented
at end of GC. Usually, we will fill them in with objects by allocating! But if we do
create newlyAllocated bits then we need to have some way of blowing them away later.

This is where a second version comes in. We can have a version for newlyAllocated bits,
which we increment at the end of marking, at around the same time that we clear all
allocated bits.

This means that the MarkedBlock will have two different version-based flips, so terms like
"flip" and "version" aren't enough.

This patch gets rid of the term "flip" entirely. It's a term of art in GCs that refers to
the state change at the beginning or end of GC. It refers to the logical state change, not
the physical one. It doesn't actually make sense to speak of a block being flipped
independently of other blocks. It's true that our implementation of the flip makes some
state updates happen lazily, but the block updating itself in some way (like clearing mark
bits) isn't the flip - the flip already happened when the version was incremented.

We no longer refer to a version without qualifying what kind of version it is. The type is
HeapVersion. All of the version members were renamed to markingVersion, to reflect the
fact that this version is just used for doing things to marking state. Instead of asking
if the block needsFlip(), we ask if areMarksStale().

This will let us introduce a second version for newlyAllocated, and will let us speak of
the two versions unambiguously.

  • heap/CellContainer.h:
  • heap/CellContainerInlines.h:

(JSC::CellContainer::isMarked):
(JSC::CellContainer::isMarkedOrNewlyAllocated):
(JSC::CellContainer::aboutToMark):
(JSC::CellContainer::areMarksStale):
(JSC::CellContainer::needsFlip): Deleted.

  • heap/ConservativeRoots.cpp:

(JSC::ConservativeRoots::genericAddPointer):
(JSC::ConservativeRoots::genericAddSpan):

  • heap/HeapInlines.h:

(JSC::Heap::isMarked):
(JSC::Heap::isMarkedConcurrently):
(JSC::Heap::testAndSetMarked):

  • heap/HeapUtil.h:

(JSC::HeapUtil::findGCObjectPointersForMarking):

  • heap/MarkedAllocator.cpp:

(JSC::MarkedAllocator::isPagedOut):

  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::MarkedBlock):
(JSC::MarkedBlock::Handle::specializedSweep):
(JSC::MarkedBlock::Handle::sweepHelperSelectSweepMode):
(JSC::MarkedBlock::Handle::sweepHelperSelectMarksMode):
(JSC::MarkedBlock::aboutToMarkSlow):
(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::assertMarksNotStale):
(JSC::MarkedBlock::areMarksStale):
(JSC::MarkedBlock::Handle::areMarksStale):
(JSC::MarkedBlock::isMarked):
(JSC::MarkedBlock::Handle::isMarkedOrNewlyAllocated):
(JSC::MarkedBlock::isMarkedOrNewlyAllocated):
(JSC::MarkedBlock::markCount):
(JSC::MarkedBlock::Handle::isLive):
(JSC::MarkedBlock::Handle::isLiveCell):
(JSC::MarkedBlock::Handle::sweepHelperSelectFlipMode): Deleted.
(JSC::MarkedBlock::assertFlipped): Deleted.
(JSC::MarkedBlock::needsFlip): Deleted.
(JSC::MarkedBlock::Handle::needsFlip): Deleted.

  • heap/MarkedBlock.h:

(JSC::MarkedBlock::areMarksStale):
(JSC::MarkedBlock::aboutToMark):
(JSC::MarkedBlock::assertMarksNotStale):
(JSC::MarkedBlock::Handle::assertMarksNotStale):
(JSC::MarkedBlock::isMarked):
(JSC::MarkedBlock::isMarkedConcurrently):
(JSC::MarkedBlock::testAndSetMarked):
(JSC::MarkedBlock::Handle::isMarkedOrNewlyAllocated):
(JSC::MarkedBlock::isMarkedOrNewlyAllocated):
(JSC::MarkedBlock::needsFlip): Deleted.
(JSC::MarkedBlock::assertFlipped): Deleted.
(JSC::MarkedBlock::Handle::assertFlipped): Deleted.

  • heap/MarkedBlockInlines.h:

(JSC::MarkedBlock::Handle::isLive):
(JSC::MarkedBlock::Handle::isLiveCell):
(JSC::MarkedBlock::resetMarkingVersion):
(JSC::MarkedBlock::resetVersion): Deleted.

  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::beginMarking):

  • heap/MarkedSpace.h:

(JSC::MarkedSpace::markingVersion):
(JSC::MarkedSpace::version): Deleted.

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::didStartMarking):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
(JSC::SlotVisitor::setMarkedAndAppendToMarkStack):
(JSC::SlotVisitor::markAuxiliary):

  • heap/SlotVisitor.h:

(JSC::SlotVisitor::markingVersion):
(JSC::SlotVisitor::version): Deleted.

  • heap/WeakBlock.cpp:

(JSC::WeakBlock::specializedVisit):
(JSC::WeakBlock::reap):

Location:
trunk/Source/JavaScriptCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r206164 r206172  
     12016-09-20  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Rename MarkedSpace::version/MarkedBlock::version to MarkedSpace::markingVersion/MarkedBlock::markingVersion
     4        https://bugs.webkit.org/show_bug.cgi?id=162310
     5
     6        Reviewed by Geoffrey Garen.
     7       
     8        In bug 162309, which is part of my concurrent GC work, I'll need to introduce a second
     9        version-based flip. This one will be for newlyAllocated bits. This will allow me to
     10        cheaply preserve per-object live state during marking. MarkedBlock::aboutToMarkSlow() will
     11        do this instead of clearMarks():
     12       
     13            - Walk the mark bits, simultaneously counting the number of set bits and clearing
     14              them.
     15            - If the count is zero, then we're done.
     16            - If the count is equal to the max number of cells in the block, then set the
     17              allocated bit for the block.
     18            - If the count is something else, create a newlyAllocated vector.
     19       
     20        The hope is that the last mode is going to be rare, since most blocks are not fragmented
     21        at end of GC. Usually, we will fill them in with objects by allocating! But if we do
     22        create newlyAllocated bits then we need to have some way of blowing them away later.
     23       
     24        This is where a second version comes in. We can have a version for newlyAllocated bits,
     25        which we increment at the end of marking, at around the same time that we clear all
     26        allocated bits.
     27       
     28        This means that the MarkedBlock will have two different version-based flips, so terms like
     29        "flip" and "version" aren't enough.
     30       
     31        This patch gets rid of the term "flip" entirely. It's a term of art in GCs that refers to
     32        the state change at the beginning or end of GC. It refers to the logical state change, not
     33        the physical one. It doesn't actually make sense to speak of a block being flipped
     34        independently of other blocks. It's true that our implementation of the flip makes some
     35        state updates happen lazily, but the block updating itself in some way (like clearing mark
     36        bits) isn't the flip - the flip already happened when the version was incremented.
     37       
     38        We no longer refer to a version without qualifying what kind of version it is. The type is
     39        HeapVersion. All of the version members were renamed to markingVersion, to reflect the
     40        fact that this version is just used for doing things to marking state. Instead of asking
     41        if the block needsFlip(), we ask if areMarksStale().
     42       
     43        This will let us introduce a second version for newlyAllocated, and will let us speak of
     44        the two versions unambiguously.
     45
     46        * heap/CellContainer.h:
     47        * heap/CellContainerInlines.h:
     48        (JSC::CellContainer::isMarked):
     49        (JSC::CellContainer::isMarkedOrNewlyAllocated):
     50        (JSC::CellContainer::aboutToMark):
     51        (JSC::CellContainer::areMarksStale):
     52        (JSC::CellContainer::needsFlip): Deleted.
     53        * heap/ConservativeRoots.cpp:
     54        (JSC::ConservativeRoots::genericAddPointer):
     55        (JSC::ConservativeRoots::genericAddSpan):
     56        * heap/HeapInlines.h:
     57        (JSC::Heap::isMarked):
     58        (JSC::Heap::isMarkedConcurrently):
     59        (JSC::Heap::testAndSetMarked):
     60        * heap/HeapUtil.h:
     61        (JSC::HeapUtil::findGCObjectPointersForMarking):
     62        * heap/MarkedAllocator.cpp:
     63        (JSC::MarkedAllocator::isPagedOut):
     64        * heap/MarkedBlock.cpp:
     65        (JSC::MarkedBlock::MarkedBlock):
     66        (JSC::MarkedBlock::Handle::specializedSweep):
     67        (JSC::MarkedBlock::Handle::sweepHelperSelectSweepMode):
     68        (JSC::MarkedBlock::Handle::sweepHelperSelectMarksMode):
     69        (JSC::MarkedBlock::aboutToMarkSlow):
     70        (JSC::MarkedBlock::clearMarks):
     71        (JSC::MarkedBlock::assertMarksNotStale):
     72        (JSC::MarkedBlock::areMarksStale):
     73        (JSC::MarkedBlock::Handle::areMarksStale):
     74        (JSC::MarkedBlock::isMarked):
     75        (JSC::MarkedBlock::Handle::isMarkedOrNewlyAllocated):
     76        (JSC::MarkedBlock::isMarkedOrNewlyAllocated):
     77        (JSC::MarkedBlock::markCount):
     78        (JSC::MarkedBlock::Handle::isLive):
     79        (JSC::MarkedBlock::Handle::isLiveCell):
     80        (JSC::MarkedBlock::Handle::sweepHelperSelectFlipMode): Deleted.
     81        (JSC::MarkedBlock::assertFlipped): Deleted.
     82        (JSC::MarkedBlock::needsFlip): Deleted.
     83        (JSC::MarkedBlock::Handle::needsFlip): Deleted.
     84        * heap/MarkedBlock.h:
     85        (JSC::MarkedBlock::areMarksStale):
     86        (JSC::MarkedBlock::aboutToMark):
     87        (JSC::MarkedBlock::assertMarksNotStale):
     88        (JSC::MarkedBlock::Handle::assertMarksNotStale):
     89        (JSC::MarkedBlock::isMarked):
     90        (JSC::MarkedBlock::isMarkedConcurrently):
     91        (JSC::MarkedBlock::testAndSetMarked):
     92        (JSC::MarkedBlock::Handle::isMarkedOrNewlyAllocated):
     93        (JSC::MarkedBlock::isMarkedOrNewlyAllocated):
     94        (JSC::MarkedBlock::needsFlip): Deleted.
     95        (JSC::MarkedBlock::assertFlipped): Deleted.
     96        (JSC::MarkedBlock::Handle::assertFlipped): Deleted.
     97        * heap/MarkedBlockInlines.h:
     98        (JSC::MarkedBlock::Handle::isLive):
     99        (JSC::MarkedBlock::Handle::isLiveCell):
     100        (JSC::MarkedBlock::resetMarkingVersion):
     101        (JSC::MarkedBlock::resetVersion): Deleted.
     102        * heap/MarkedSpace.cpp:
     103        (JSC::MarkedSpace::beginMarking):
     104        * heap/MarkedSpace.h:
     105        (JSC::MarkedSpace::markingVersion):
     106        (JSC::MarkedSpace::version): Deleted.
     107        * heap/SlotVisitor.cpp:
     108        (JSC::SlotVisitor::SlotVisitor):
     109        (JSC::SlotVisitor::didStartMarking):
     110        (JSC::SlotVisitor::appendJSCellOrAuxiliary):
     111        (JSC::SlotVisitor::setMarkedAndAppendToMarkStack):
     112        (JSC::SlotVisitor::markAuxiliary):
     113        * heap/SlotVisitor.h:
     114        (JSC::SlotVisitor::markingVersion):
     115        (JSC::SlotVisitor::version): Deleted.
     116        * heap/WeakBlock.cpp:
     117        (JSC::WeakBlock::specializedVisit):
     118        (JSC::WeakBlock::reap):
     119
    11202016-09-20  Ryan Haddad  <ryanhaddad@apple.com>
    2121
  • trunk/Source/JavaScriptCore/heap/CellContainer.h

    r206154 r206172  
    7979    }
    8080   
    81     void aboutToMark(HeapVersion);
    82     bool needsFlip() const;
     81    void aboutToMark(HeapVersion markingVersion);
     82    bool areMarksStale() const;
    8383   
    8484    bool isMarked(HeapCell*) const;
    85     bool isMarked(HeapVersion, HeapCell*) const;
     85    bool isMarked(HeapVersion markingVersion, HeapCell*) const;
    8686    bool isMarkedOrNewlyAllocated(HeapCell*) const;
    87     bool isMarkedOrNewlyAllocated(HeapVersion, HeapCell*) const;
     87    bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, HeapCell*) const;
    8888   
    8989    void noteMarked();
  • trunk/Source/JavaScriptCore/heap/CellContainerInlines.h

    r206154 r206172  
    5353}
    5454
    55 inline bool CellContainer::isMarked(HeapVersion version, HeapCell* cell) const
     55inline bool CellContainer::isMarked(HeapVersion markingVersion, HeapCell* cell) const
    5656{
    5757    if (isLargeAllocation())
    5858        return largeAllocation().isMarked();
    59     return markedBlock().isMarked(version, cell);
     59    return markedBlock().isMarked(markingVersion, cell);
    6060}
    6161
     
    6767}
    6868
    69 inline bool CellContainer::isMarkedOrNewlyAllocated(HeapVersion version, HeapCell* cell) const
     69inline bool CellContainer::isMarkedOrNewlyAllocated(HeapVersion markingVersion, HeapCell* cell) const
    7070{
    7171    if (isLargeAllocation())
    7272        return largeAllocation().isMarkedOrNewlyAllocated();
    73     return markedBlock().isMarkedOrNewlyAllocated(version, cell);
     73    return markedBlock().isMarkedOrNewlyAllocated(markingVersion, cell);
    7474}
    7575
     
    9494}
    9595
    96 inline void CellContainer::aboutToMark(HeapVersion heapVersion)
     96inline void CellContainer::aboutToMark(HeapVersion markingVersion)
    9797{
    9898    if (!isLargeAllocation())
    99         markedBlock().aboutToMark(heapVersion);
     99        markedBlock().aboutToMark(markingVersion);
    100100}
    101101
    102 inline bool CellContainer::needsFlip() const
     102inline bool CellContainer::areMarksStale() const
    103103{
    104104    if (isLargeAllocation())
    105105        return false;
    106     return markedBlock().needsFlip();
     106    return markedBlock().areMarksStale();
    107107}
    108108
  • trunk/Source/JavaScriptCore/heap/ConservativeRoots.cpp

    r206154 r206172  
    6767
    6868template<typename MarkHook>
    69 inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion version, TinyBloomFilter filter, MarkHook& markHook)
     69inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion markingVersion, TinyBloomFilter filter, MarkHook& markHook)
    7070{
    7171    markHook.mark(p);
    7272
    7373    HeapUtil::findGCObjectPointersForMarking(
    74         m_heap, version, filter, p,
     74        m_heap, markingVersion, filter, p,
    7575        [&] (void* p) {
    7676            if (m_size == m_capacity)
     
    9595
    9696    TinyBloomFilter filter = m_heap.objectSpace().blocks().filter(); // Make a local copy of filter to show the compiler it won't alias, and can be register-allocated.
    97     HeapVersion version = m_heap.objectSpace().version();
     97    HeapVersion markingVersion = m_heap.objectSpace().markingVersion();
    9898    for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it)
    99         genericAddPointer(*it, version, filter, markHook);
     99        genericAddPointer(*it, markingVersion, filter, markHook);
    100100}
    101101
  • trunk/Source/JavaScriptCore/heap/HeapInlines.h

    r206154 r206172  
    8383    MarkedBlock& block = cell->markedBlock();
    8484    return block.isMarked(
    85         block.vm()->heap.objectSpace().version(), cell);
     85        block.vm()->heap.objectSpace().markingVersion(), cell);
    8686}
    8787
     
    9393    MarkedBlock& block = cell->markedBlock();
    9494    return block.isMarkedConcurrently(
    95         block.vm()->heap.objectSpace().version(), cell);
    96 }
    97 
    98 ALWAYS_INLINE bool Heap::testAndSetMarked(HeapVersion version, const void* rawCell)
     95        block.vm()->heap.objectSpace().markingVersion(), cell);
     96}
     97
     98ALWAYS_INLINE bool Heap::testAndSetMarked(HeapVersion markingVersion, const void* rawCell)
    9999{
    100100    HeapCell* cell = bitwise_cast<HeapCell*>(rawCell);
     
    102102        return cell->largeAllocation().testAndSetMarked();
    103103    MarkedBlock& block = cell->markedBlock();
    104     block.aboutToMark(version);
     104    block.aboutToMark(markingVersion);
    105105    return block.testAndSetMarked(cell);
    106106}
  • trunk/Source/JavaScriptCore/heap/HeapUtil.h

    r206154 r206172  
    4747    template<typename Func>
    4848    static void findGCObjectPointersForMarking(
    49         Heap& heap, HeapVersion heapVersion, TinyBloomFilter filter, void* passedPointer,
     49        Heap& heap, HeapVersion markingVersion, TinyBloomFilter filter, void* passedPointer,
    5050        const Func& func)
    5151    {
     
    8686                && previousCandidate->handle().cellKind() == HeapCell::Auxiliary) {
    8787                previousPointer = static_cast<char*>(previousCandidate->handle().cellAlign(previousPointer));
    88                 if (previousCandidate->handle().isLiveCell(heapVersion, previousPointer))
     88                if (previousCandidate->handle().isLiveCell(markingVersion, previousPointer))
    8989                    func(previousPointer);
    9090            }
     
    100100       
    101101        auto tryPointer = [&] (void* pointer) {
    102             if (candidate->handle().isLiveCell(heapVersion, pointer))
     102            if (candidate->handle().isLiveCell(markingVersion, pointer))
    103103                func(pointer);
    104104        };
  • trunk/Source/JavaScriptCore/heap/MarkedAllocator.cpp

    r206154 r206172  
    5656        if (block) {
    5757            // Forces us to touch the memory of the block, but has no semantic effect.
    58             if (block->needsFlip())
    59                 block->block().resetVersion();
     58            if (block->areMarksStale())
     59                block->block().resetMarkingVersion();
    6060        }
    6161        ++itersSinceLastTimeCheck;
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.cpp

    r206154 r206172  
    7878
    7979MarkedBlock::MarkedBlock(VM& vm, Handle& handle)
    80     : m_version(MarkedSpace::nullVersion)
     80    : m_markingVersion(MarkedSpace::nullVersion)
    8181    , m_handle(handle)
    8282    , m_vm(&vm)
     
    8484}
    8585
    86 template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode, MarkedBlock::Handle::FlipMode flipMode>
     86template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode, MarkedBlock::Handle::MarksMode marksMode>
    8787FreeList MarkedBlock::Handle::specializedSweep()
    8888{
     
    9999        && emptyMode == IsEmpty
    100100        && newlyAllocatedMode == DoesNotHaveNewlyAllocated) {
    101         ASSERT(flipMode == NeedsFlip);
     101        ASSERT(marksMode == MarksStale);
    102102       
    103103        char* startOfLastCell = static_cast<char*>(cellAlign(block.atoms() + m_endAtom - 1));
     
    125125    for (size_t i = firstAtom(); i < m_endAtom; i += m_atomsPerCell) {
    126126        if (emptyMode == NotEmpty
    127             && ((flipMode == DoesNotNeedFlip && block.m_marks.get(i))
     127            && ((marksMode == MarksNotStale && block.m_marks.get(i))
    128128                || (newlyAllocatedMode == HasNewlyAllocated && m_newlyAllocated->get(i)))) {
    129129            isEmpty = false;
     
    217217{
    218218    if (sweepMode == SweepToFreeList)
    219         return sweepHelperSelectFlipMode<emptyMode, SweepToFreeList, destructionMode, scribbleMode, newlyAllocatedMode>();
    220     return sweepHelperSelectFlipMode<emptyMode, SweepOnly, destructionMode, scribbleMode, newlyAllocatedMode>();
     219        return sweepHelperSelectMarksMode<emptyMode, SweepToFreeList, destructionMode, scribbleMode, newlyAllocatedMode>();
     220    return sweepHelperSelectMarksMode<emptyMode, SweepOnly, destructionMode, scribbleMode, newlyAllocatedMode>();
    221221}
    222222
    223223template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode>
    224 FreeList MarkedBlock::Handle::sweepHelperSelectFlipMode()
    225 {
    226     if (needsFlip())
    227         return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, NeedsFlip>();
    228     return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, DoesNotNeedFlip>();
     224FreeList MarkedBlock::Handle::sweepHelperSelectMarksMode()
     225{
     226    if (areMarksStale())
     227        return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, MarksStale>();
     228    return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, MarksNotStale>();
    229229}
    230230
     
    343343}
    344344
    345 void MarkedBlock::aboutToMarkSlow(HeapVersion heapVersion)
     345void MarkedBlock::aboutToMarkSlow(HeapVersion markingVersion)
    346346{
    347347    ASSERT(vm()->heap.objectSpace().isMarking());
    348348    LockHolder locker(m_lock);
    349     if (needsFlip(heapVersion)) {
    350         clearMarks(heapVersion);
     349    if (areMarksStale(markingVersion)) {
     350        clearMarks(markingVersion);
    351351        // This means we're the first ones to mark any object in this block.
    352352        handle().allocator()->atomicSetAndCheckIsMarkingNotEmpty(&handle(), true);
     
    356356void MarkedBlock::clearMarks()
    357357{
    358     clearMarks(vm()->heap.objectSpace().version());
    359 }
    360 
    361 void MarkedBlock::clearMarks(HeapVersion heapVersion)
     358    clearMarks(vm()->heap.objectSpace().markingVersion());
     359}
     360
     361void MarkedBlock::clearMarks(HeapVersion markingVersion)
    362362{
    363363    m_marks.clearAll();
    364364    clearHasAnyMarked();
    365365    WTF::storeStoreFence();
    366     m_version = heapVersion;
     366    m_markingVersion = markingVersion;
    367367}
    368368
    369369#if !ASSERT_DISABLED
    370 void MarkedBlock::assertFlipped()
    371 {
    372     ASSERT(m_version == vm()->heap.objectSpace().version());
     370void MarkedBlock::assertMarksNotStale()
     371{
     372    ASSERT(m_markingVersion == vm()->heap.objectSpace().markingVersion());
    373373}
    374374#endif // !ASSERT_DISABLED
    375375
    376 bool MarkedBlock::needsFlip()
    377 {
    378     return needsFlip(vm()->heap.objectSpace().version());
    379 }
    380 
    381 bool MarkedBlock::Handle::needsFlip()
    382 {
    383     return m_block->needsFlip();
     376bool MarkedBlock::areMarksStale()
     377{
     378    return areMarksStale(vm()->heap.objectSpace().markingVersion());
     379}
     380
     381bool MarkedBlock::Handle::areMarksStale()
     382{
     383    return m_block->areMarksStale();
    384384}
    385385
    386386bool MarkedBlock::isMarked(const void* p)
    387387{
    388     return isMarked(vm()->heap.objectSpace().version(), p);
     388    return isMarked(vm()->heap.objectSpace().markingVersion(), p);
    389389}
    390390
    391391bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(const HeapCell* cell)
    392392{
    393     return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().version(), cell);
     393    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().markingVersion(), cell);
    394394}
    395395
    396396bool MarkedBlock::isMarkedOrNewlyAllocated(const HeapCell* cell)
    397397{
    398     return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().version(), cell);
     398    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().markingVersion(), cell);
    399399}
    400400
     
    410410size_t MarkedBlock::markCount()
    411411{
    412     return needsFlip() ? 0 : m_marks.count();
     412    return areMarksStale() ? 0 : m_marks.count();
    413413}
    414414
     
    477477bool MarkedBlock::Handle::isLive(const HeapCell* cell)
    478478{
    479     return isLive(vm()->heap.objectSpace().version(), cell);
     479    return isLive(vm()->heap.objectSpace().markingVersion(), cell);
    480480}
    481481
    482482bool MarkedBlock::Handle::isLiveCell(const void* p)
    483483{
    484     return isLiveCell(vm()->heap.objectSpace().version(), p);
     484    return isLiveCell(vm()->heap.objectSpace().markingVersion(), p);
    485485}
    486486
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r206154 r206172  
    155155        size_t size();
    156156           
    157         inline bool isLive(HeapVersion, const HeapCell*);
    158         inline bool isLiveCell(HeapVersion, const void*);
     157        inline bool isLive(HeapVersion markingVersion, const HeapCell*);
     158        inline bool isLiveCell(HeapVersion markingVersion, const void*);
    159159
    160160        bool isLive(const HeapCell*);
     
    162162
    163163        bool isMarkedOrNewlyAllocated(const HeapCell*);
    164         bool isMarkedOrNewlyAllocated(HeapVersion, const HeapCell*);
     164        bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell*);
    165165           
    166166        bool isNewlyAllocated(const void*);
     
    174174        template <typename Functor> inline IterationStatus forEachDeadCell(const Functor&);
    175175           
    176         bool needsFlip();
    177        
    178         void assertFlipped();
     176        bool areMarksStale();
     177       
     178        void assertMarksNotStale();
    179179           
    180180        bool isFreeListed() const { return m_isFreeListed; }
     
    209209       
    210210        template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode>
    211         FreeList sweepHelperSelectFlipMode();
    212        
    213         enum FlipMode { NeedsFlip, DoesNotNeedFlip };
    214        
    215         template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode, FlipMode>
     211        FreeList sweepHelperSelectMarksMode();
     212       
     213        enum MarksMode { MarksStale, MarksNotStale };
     214       
     215        template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode, MarksMode>
    216216        FreeList specializedSweep();
    217217           
     
    253253
    254254    bool isMarked(const void*);
    255     bool isMarked(HeapVersion, const void*);
    256     bool isMarkedConcurrently(HeapVersion, const void*);
     255    bool isMarked(HeapVersion markingVersion, const void*);
     256    bool isMarkedConcurrently(HeapVersion markingVersion, const void*);
    257257    bool testAndSetMarked(const void*);
    258258       
    259259    bool isMarkedOrNewlyAllocated(const HeapCell*);
    260     bool isMarkedOrNewlyAllocated(HeapVersion, const HeapCell*);
     260    bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell*);
    261261   
    262262    bool isAtom(const void*);
     
    271271    WeakSet& weakSet();
    272272   
    273     bool needsFlip(HeapVersion);
    274     bool needsFlip();
    275    
    276     void aboutToMark(HeapVersion);
    277        
    278     void assertFlipped();
     273    bool areMarksStale(HeapVersion markingVersion);
     274    bool areMarksStale();
     275   
     276    void aboutToMark(HeapVersion markingVersion);
     277       
     278    void assertMarksNotStale();
    279279       
    280280    bool needsDestruction() const { return m_needsDestruction; }
    281281   
    282     inline void resetVersion();
     282    inline void resetMarkingVersion();
    283283   
    284284private:
     
    290290    Atom* atoms();
    291291       
    292     void aboutToMarkSlow(HeapVersion);
     292    void aboutToMarkSlow(HeapVersion markingVersion);
    293293    void clearMarks();
    294     void clearMarks(HeapVersion);
     294    void clearMarks(HeapVersion markingVersion);
    295295    void clearHasAnyMarked();
    296296   
     
    329329    int16_t m_markCountBias;
    330330
    331     HeapVersion m_version;
     331    HeapVersion m_markingVersion;
    332332   
    333333    Handle& m_handle;
     
    470470}
    471471
    472 inline bool MarkedBlock::needsFlip(HeapVersion heapVersion)
    473 {
    474     return heapVersion != m_version;
    475 }
    476 
    477 inline void MarkedBlock::aboutToMark(HeapVersion heapVersion)
    478 {
    479     if (UNLIKELY(needsFlip(heapVersion)))
    480         aboutToMarkSlow(heapVersion);
     472inline bool MarkedBlock::areMarksStale(HeapVersion markingVersion)
     473{
     474    return markingVersion != m_markingVersion;
     475}
     476
     477inline void MarkedBlock::aboutToMark(HeapVersion markingVersion)
     478{
     479    if (UNLIKELY(areMarksStale(markingVersion)))
     480        aboutToMarkSlow(markingVersion);
    481481    WTF::loadLoadFence();
    482482}
    483483
    484484#if ASSERT_DISABLED
    485 inline void MarkedBlock::assertFlipped()
     485inline void MarkedBlock::assertMarksNotStale()
    486486{
    487487}
    488488#endif // ASSERT_DISABLED
    489489
    490 inline void MarkedBlock::Handle::assertFlipped()
    491 {
    492     block().assertFlipped();
    493 }
    494 
    495 inline bool MarkedBlock::isMarked(HeapVersion heapVersion, const void* p)
    496 {
    497     return needsFlip(heapVersion) ? false : m_marks.get(atomNumber(p));
    498 }
    499 
    500 inline bool MarkedBlock::isMarkedConcurrently(HeapVersion heapVersion, const void* p)
    501 {
    502     if (needsFlip(heapVersion))
     490inline void MarkedBlock::Handle::assertMarksNotStale()
     491{
     492    block().assertMarksNotStale();
     493}
     494
     495inline bool MarkedBlock::isMarked(HeapVersion markingVersion, const void* p)
     496{
     497    return areMarksStale(markingVersion) ? false : m_marks.get(atomNumber(p));
     498}
     499
     500inline bool MarkedBlock::isMarkedConcurrently(HeapVersion markingVersion, const void* p)
     501{
     502    if (areMarksStale(markingVersion))
    503503        return false;
    504504    WTF::loadLoadFence();
     
    508508inline bool MarkedBlock::testAndSetMarked(const void* p)
    509509{
    510     assertFlipped();
     510    assertMarksNotStale();
    511511    return m_marks.concurrentTestAndSet(atomNumber(p));
    512512}
     
    536536}
    537537
    538 inline bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(HeapVersion version, const HeapCell* cell)
    539 {
    540     return m_block->isMarked(version, cell) || (m_newlyAllocated && isNewlyAllocated(cell));
    541 }
    542 
    543 inline bool MarkedBlock::isMarkedOrNewlyAllocated(HeapVersion version, const HeapCell* cell)
    544 {
    545     return isMarked(version, cell) || (m_handle.m_newlyAllocated && m_handle.isNewlyAllocated(cell));
     538inline bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell* cell)
     539{
     540    return m_block->isMarked(markingVersion, cell) || (m_newlyAllocated && isNewlyAllocated(cell));
     541}
     542
     543inline bool MarkedBlock::isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell* cell)
     544{
     545    return isMarked(markingVersion, cell) || (m_handle.m_newlyAllocated && m_handle.isNewlyAllocated(cell));
    546546}
    547547
  • trunk/Source/JavaScriptCore/heap/MarkedBlockInlines.h

    r206154 r206172  
    3131namespace JSC {
    3232
    33 inline bool MarkedBlock::Handle::isLive(HeapVersion version, const HeapCell* cell)
     33inline bool MarkedBlock::Handle::isLive(HeapVersion markingVersion, const HeapCell* cell)
    3434{
    3535    ASSERT(!isFreeListed());
     
    4545        return true;
    4646   
    47     if (block.needsFlip(version))
     47    if (block.areMarksStale(markingVersion))
    4848        return false;
    4949
     
    5151}
    5252
    53 inline bool MarkedBlock::Handle::isLiveCell(HeapVersion version, const void* p)
     53inline bool MarkedBlock::Handle::isLiveCell(HeapVersion markingVersion, const void* p)
    5454{
    5555    if (!m_block->isAtom(p))
    5656        return false;
    57     return isLive(version, static_cast<const HeapCell*>(p));
     57    return isLive(markingVersion, static_cast<const HeapCell*>(p));
    5858}
    5959
     
    8888}
    8989
    90 inline void MarkedBlock::resetVersion()
     90inline void MarkedBlock::resetMarkingVersion()
    9191{
    92     m_version = MarkedSpace::nullVersion;
     92    m_markingVersion = MarkedSpace::nullVersion;
    9393}
    9494
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp

    r206154 r206172  
    459459            });
    460460
    461         m_version = nextVersion(m_version);
     461        m_markingVersion = nextVersion(m_markingVersion);
    462462       
    463         if (UNLIKELY(m_version == initialVersion)) {
     463        if (UNLIKELY(m_markingVersion == initialVersion)) {
    464464            // Oh no! Version wrap-around! We handle this by setting all block versions to null.
    465465            forEachBlock(
    466466                [&] (MarkedBlock::Handle* handle) {
    467                     handle->block().resetVersion();
     467                    handle->block().resetMarkingVersion();
    468468                });
    469469        }
     
    476476        forEachBlock(
    477477            [&] (MarkedBlock::Handle* block) {
    478                 if (block->needsFlip())
     478                if (block->areMarksStale())
    479479                    return;
    480480                ASSERT(!block->isFreeListed());
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.h

    r206154 r206172  
    167167    bool isPagedOut(double deadline);
    168168   
    169     HeapVersion version() const { return m_version; }
     169    HeapVersion markingVersion() const { return m_markingVersion; }
    170170
    171171    const Vector<LargeAllocation*>& largeAllocations() const { return m_largeAllocations; }
     
    213213
    214214    Heap* m_heap;
    215     HeapVersion m_version { initialVersion };
     215    HeapVersion m_markingVersion { initialVersion };
    216216    size_t m_capacity;
    217217    bool m_isIterating;
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp

    r206154 r206172  
    7979    , m_visitCount(0)
    8080    , m_isInParallelMode(false)
    81     , m_version(MarkedSpace::initialVersion)
     81    , m_markingVersion(MarkedSpace::initialVersion)
    8282    , m_heap(heap)
    8383#if !ASSERT_DISABLED
     
    103103        m_heapSnapshotBuilder = heapProfiler->activeSnapshotBuilder();
    104104   
    105     m_version = heap()->objectSpace().version();
     105    m_markingVersion = heap()->objectSpace().markingVersion();
    106106}
    107107
     
    135135    ASSERT(!m_isCheckingForDefaultMarkViolation);
    136136   
    137     if (Heap::testAndSetMarked(m_version, heapCell))
     137    if (Heap::testAndSetMarked(m_markingVersion, heapCell))
    138138        return;
    139139   
     
    201201ALWAYS_INLINE void SlotVisitor::setMarkedAndAppendToMarkStack(ContainerType& container, JSCell* cell)
    202202{
    203     container.aboutToMark(m_version);
     203    container.aboutToMark(m_markingVersion);
    204204   
    205205    if (container.testAndSetMarked(cell))
     
    249249    ASSERT(cell->heap() == heap());
    250250   
    251     if (Heap::testAndSetMarked(m_version, cell))
     251    if (Heap::testAndSetMarked(m_markingVersion, cell))
    252252        return;
    253253   
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.h

    r205850 r206172  
    125125    bool isBuildingHeapSnapshot() const { return !!m_heapSnapshotBuilder; }
    126126   
    127     HeapVersion version() const { return m_version; }
     127    HeapVersion markingVersion() const { return m_markingVersion; }
    128128
    129129private:
     
    162162    bool m_isInParallelMode;
    163163   
    164     HeapVersion m_version;
     164    HeapVersion m_markingVersion;
    165165   
    166166    Heap& m_heap;
  • trunk/Source/JavaScriptCore/heap/WeakBlock.cpp

    r206154 r206172  
    102102    SlotVisitor& visitor = heapRootVisitor.visitor();
    103103   
    104     HeapVersion version = visitor.version();
     104    HeapVersion markingVersion = visitor.markingVersion();
    105105
    106106    for (size_t i = 0; i < weakImplCount(); ++i) {
     
    114114
    115115        const JSValue& jsValue = weakImpl->jsValue();
    116         if (container.isMarkedConcurrently(version, jsValue.asCell()))
     116        if (container.isMarkedConcurrently(markingVersion, jsValue.asCell()))
    117117            continue;
    118118       
     
    148148    ASSERT(m_container);
    149149   
    150     HeapVersion version = m_container.heap()->objectSpace().version();
     150    HeapVersion markingVersion = m_container.heap()->objectSpace().markingVersion();
    151151
    152152    for (size_t i = 0; i < weakImplCount(); ++i) {
     
    155155            continue;
    156156
    157         if (m_container.isMarked(version, weakImpl->jsValue().asCell())) {
     157        if (m_container.isMarked(markingVersion, weakImpl->jsValue().asCell())) {
    158158            ASSERT(weakImpl->state() == WeakImpl::Live);
    159159            continue;
Note: See TracChangeset for help on using the changeset viewer.