Rename MarkedSpace::version/MarkedBlock::version to MarkedSpace::markingVersion/Marke...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2016 21:04:06 +0000 (21:04 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Sep 2016 21:04:06 +0000 (21:04 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206172 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/CellContainer.h
Source/JavaScriptCore/heap/CellContainerInlines.h
Source/JavaScriptCore/heap/ConservativeRoots.cpp
Source/JavaScriptCore/heap/HeapInlines.h
Source/JavaScriptCore/heap/HeapUtil.h
Source/JavaScriptCore/heap/MarkedAllocator.cpp
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/heap/MarkedBlockInlines.h
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/heap/SlotVisitor.cpp
Source/JavaScriptCore/heap/SlotVisitor.h
Source/JavaScriptCore/heap/WeakBlock.cpp

index 8c07f12..e4279bf 100644 (file)
@@ -1,3 +1,122 @@
+2016-09-20  Filip Pizlo  <fpizlo@apple.com>
+
+        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):
+
 2016-09-20  Ryan Haddad  <ryanhaddad@apple.com>
 
         Rebaseline builtins generator tests after r206155.
index 0f75c96..920cec3 100644 (file)
@@ -78,13 +78,13 @@ public:
         return *bitwise_cast<LargeAllocation*>(m_encodedPointer - isLargeAllocationBit);
     }
     
-    void aboutToMark(HeapVersion);
-    bool needsFlip() const;
+    void aboutToMark(HeapVersion markingVersion);
+    bool areMarksStale() const;
     
     bool isMarked(HeapCell*) const;
-    bool isMarked(HeapVersion, HeapCell*) const;
+    bool isMarked(HeapVersion markingVersion, HeapCell*) const;
     bool isMarkedOrNewlyAllocated(HeapCell*) const;
-    bool isMarkedOrNewlyAllocated(HeapVersion, HeapCell*) const;
+    bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, HeapCell*) const;
     
     void noteMarked();
     
index 88ee30e..cf3fb17 100644 (file)
@@ -52,11 +52,11 @@ inline bool CellContainer::isMarked(HeapCell* cell) const
     return markedBlock().isMarked(cell);
 }
 
-inline bool CellContainer::isMarked(HeapVersion version, HeapCell* cell) const
+inline bool CellContainer::isMarked(HeapVersion markingVersion, HeapCell* cell) const
 {
     if (isLargeAllocation())
         return largeAllocation().isMarked();
-    return markedBlock().isMarked(version, cell);
+    return markedBlock().isMarked(markingVersion, cell);
 }
 
 inline bool CellContainer::isMarkedOrNewlyAllocated(HeapCell* cell) const
@@ -66,11 +66,11 @@ inline bool CellContainer::isMarkedOrNewlyAllocated(HeapCell* cell) const
     return markedBlock().isMarkedOrNewlyAllocated(cell);
 }
 
-inline bool CellContainer::isMarkedOrNewlyAllocated(HeapVersion version, HeapCell* cell) const
+inline bool CellContainer::isMarkedOrNewlyAllocated(HeapVersion markingVersion, HeapCell* cell) const
 {
     if (isLargeAllocation())
         return largeAllocation().isMarkedOrNewlyAllocated();
-    return markedBlock().isMarkedOrNewlyAllocated(version, cell);
+    return markedBlock().isMarkedOrNewlyAllocated(markingVersion, cell);
 }
 
 inline void CellContainer::noteMarked()
@@ -93,17 +93,17 @@ inline WeakSet& CellContainer::weakSet() const
     return markedBlock().weakSet();
 }
 
-inline void CellContainer::aboutToMark(HeapVersion heapVersion)
+inline void CellContainer::aboutToMark(HeapVersion markingVersion)
 {
     if (!isLargeAllocation())
-        markedBlock().aboutToMark(heapVersion);
+        markedBlock().aboutToMark(markingVersion);
 }
 
-inline bool CellContainer::needsFlip() const
+inline bool CellContainer::areMarksStale() const
 {
     if (isLargeAllocation())
         return false;
-    return markedBlock().needsFlip();
+    return markedBlock().areMarksStale();
 }
 
 } // namespace JSC
index 8bd2a98..59517dd 100644 (file)
@@ -66,12 +66,12 @@ void ConservativeRoots::grow()
 }
 
 template<typename MarkHook>
-inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion version, TinyBloomFilter filter, MarkHook& markHook)
+inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion markingVersion, TinyBloomFilter filter, MarkHook& markHook)
 {
     markHook.mark(p);
 
     HeapUtil::findGCObjectPointersForMarking(
-        m_heap, version, filter, p,
+        m_heap, markingVersion, filter, p,
         [&] (void* p) {
             if (m_size == m_capacity)
                 grow();
@@ -94,9 +94,9 @@ void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHoo
     RELEASE_ASSERT(isPointerAligned(end));
 
     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.
-    HeapVersion version = m_heap.objectSpace().version();
+    HeapVersion markingVersion = m_heap.objectSpace().markingVersion();
     for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it)
-        genericAddPointer(*it, version, filter, markHook);
+        genericAddPointer(*it, markingVersion, filter, markHook);
 }
 
 class DummyMarkHook {
index fdf5c96..0168f93 100644 (file)
@@ -82,7 +82,7 @@ ALWAYS_INLINE bool Heap::isMarked(const void* rawCell)
         return cell->largeAllocation().isMarked();
     MarkedBlock& block = cell->markedBlock();
     return block.isMarked(
-        block.vm()->heap.objectSpace().version(), cell);
+        block.vm()->heap.objectSpace().markingVersion(), cell);
 }
 
 ALWAYS_INLINE bool Heap::isMarkedConcurrently(const void* rawCell)
@@ -92,16 +92,16 @@ ALWAYS_INLINE bool Heap::isMarkedConcurrently(const void* rawCell)
         return cell->largeAllocation().isMarked();
     MarkedBlock& block = cell->markedBlock();
     return block.isMarkedConcurrently(
-        block.vm()->heap.objectSpace().version(), cell);
+        block.vm()->heap.objectSpace().markingVersion(), cell);
 }
 
-ALWAYS_INLINE bool Heap::testAndSetMarked(HeapVersion version, const void* rawCell)
+ALWAYS_INLINE bool Heap::testAndSetMarked(HeapVersion markingVersion, const void* rawCell)
 {
     HeapCell* cell = bitwise_cast<HeapCell*>(rawCell);
     if (cell->isLargeAllocation())
         return cell->largeAllocation().testAndSetMarked();
     MarkedBlock& block = cell->markedBlock();
-    block.aboutToMark(version);
+    block.aboutToMark(markingVersion);
     return block.testAndSetMarked(cell);
 }
 
index a09b55c..9280c9f 100644 (file)
@@ -46,7 +46,7 @@ public:
     // before liveness data is cleared to be accurate.
     template<typename Func>
     static void findGCObjectPointersForMarking(
-        Heap& heap, HeapVersion heapVersion, TinyBloomFilter filter, void* passedPointer,
+        Heap& heap, HeapVersion markingVersion, TinyBloomFilter filter, void* passedPointer,
         const Func& func)
     {
         const HashSet<MarkedBlock*>& set = heap.objectSpace().blocks().set();
@@ -85,7 +85,7 @@ public:
                 && set.contains(previousCandidate)
                 && previousCandidate->handle().cellKind() == HeapCell::Auxiliary) {
                 previousPointer = static_cast<char*>(previousCandidate->handle().cellAlign(previousPointer));
-                if (previousCandidate->handle().isLiveCell(heapVersion, previousPointer))
+                if (previousCandidate->handle().isLiveCell(markingVersion, previousPointer))
                     func(previousPointer);
             }
         }
@@ -99,7 +99,7 @@ public:
             return;
         
         auto tryPointer = [&] (void* pointer) {
-            if (candidate->handle().isLiveCell(heapVersion, pointer))
+            if (candidate->handle().isLiveCell(markingVersion, pointer))
                 func(pointer);
         };
     
index d961022..ae634e5 100644 (file)
@@ -55,8 +55,8 @@ bool MarkedAllocator::isPagedOut(double deadline)
         MarkedBlock::Handle* block = m_blocks[index];
         if (block) {
             // Forces us to touch the memory of the block, but has no semantic effect.
-            if (block->needsFlip())
-                block->block().resetVersion();
+            if (block->areMarksStale())
+                block->block().resetMarkingVersion();
         }
         ++itersSinceLastTimeCheck;
         if (itersSinceLastTimeCheck >= Heap::s_timeCheckResolution) {
index 83d035b..842f8ee 100644 (file)
@@ -77,13 +77,13 @@ MarkedBlock::Handle::~Handle()
 }
 
 MarkedBlock::MarkedBlock(VM& vm, Handle& handle)
-    : m_version(MarkedSpace::nullVersion)
+    : m_markingVersion(MarkedSpace::nullVersion)
     , m_handle(handle)
     , m_vm(&vm)
 {
 }
 
-template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode, MarkedBlock::Handle::FlipMode flipMode>
+template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode, MarkedBlock::Handle::MarksMode marksMode>
 FreeList MarkedBlock::Handle::specializedSweep()
 {
     RELEASE_ASSERT(!(destructionMode == DoesNotNeedDestruction && sweepMode == SweepOnly));
@@ -98,7 +98,7 @@ FreeList MarkedBlock::Handle::specializedSweep()
     if (Options::useBumpAllocator()
         && emptyMode == IsEmpty
         && newlyAllocatedMode == DoesNotHaveNewlyAllocated) {
-        ASSERT(flipMode == NeedsFlip);
+        ASSERT(marksMode == MarksStale);
         
         char* startOfLastCell = static_cast<char*>(cellAlign(block.atoms() + m_endAtom - 1));
         char* payloadEnd = startOfLastCell + cellSize();
@@ -124,7 +124,7 @@ FreeList MarkedBlock::Handle::specializedSweep()
     bool isEmpty = true;
     for (size_t i = firstAtom(); i < m_endAtom; i += m_atomsPerCell) {
         if (emptyMode == NotEmpty
-            && ((flipMode == DoesNotNeedFlip && block.m_marks.get(i))
+            && ((marksMode == MarksNotStale && block.m_marks.get(i))
                 || (newlyAllocatedMode == HasNewlyAllocated && m_newlyAllocated->get(i)))) {
             isEmpty = false;
             continue;
@@ -216,16 +216,16 @@ template<MarkedBlock::Handle::EmptyMode emptyMode, DestructionMode destructionMo
 FreeList MarkedBlock::Handle::sweepHelperSelectSweepMode(SweepMode sweepMode)
 {
     if (sweepMode == SweepToFreeList)
-        return sweepHelperSelectFlipMode<emptyMode, SweepToFreeList, destructionMode, scribbleMode, newlyAllocatedMode>();
-    return sweepHelperSelectFlipMode<emptyMode, SweepOnly, destructionMode, scribbleMode, newlyAllocatedMode>();
+        return sweepHelperSelectMarksMode<emptyMode, SweepToFreeList, destructionMode, scribbleMode, newlyAllocatedMode>();
+    return sweepHelperSelectMarksMode<emptyMode, SweepOnly, destructionMode, scribbleMode, newlyAllocatedMode>();
 }
 
 template<MarkedBlock::Handle::EmptyMode emptyMode, MarkedBlock::Handle::SweepMode sweepMode, DestructionMode destructionMode, MarkedBlock::Handle::ScribbleMode scribbleMode, MarkedBlock::Handle::NewlyAllocatedMode newlyAllocatedMode>
-FreeList MarkedBlock::Handle::sweepHelperSelectFlipMode()
+FreeList MarkedBlock::Handle::sweepHelperSelectMarksMode()
 {
-    if (needsFlip())
-        return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, NeedsFlip>();
-    return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, DoesNotNeedFlip>();
+    if (areMarksStale())
+        return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, MarksStale>();
+    return specializedSweep<emptyMode, sweepMode, destructionMode, scribbleMode, newlyAllocatedMode, MarksNotStale>();
 }
 
 void MarkedBlock::Handle::unsweepWithNoNewlyAllocated()
@@ -342,12 +342,12 @@ void MarkedBlock::Handle::forEachFreeCell(const FreeList& freeList, const Func&
     }
 }
 
-void MarkedBlock::aboutToMarkSlow(HeapVersion heapVersion)
+void MarkedBlock::aboutToMarkSlow(HeapVersion markingVersion)
 {
     ASSERT(vm()->heap.objectSpace().isMarking());
     LockHolder locker(m_lock);
-    if (needsFlip(heapVersion)) {
-        clearMarks(heapVersion);
+    if (areMarksStale(markingVersion)) {
+        clearMarks(markingVersion);
         // This means we're the first ones to mark any object in this block.
         handle().allocator()->atomicSetAndCheckIsMarkingNotEmpty(&handle(), true);
     }
@@ -355,47 +355,47 @@ void MarkedBlock::aboutToMarkSlow(HeapVersion heapVersion)
 
 void MarkedBlock::clearMarks()
 {
-    clearMarks(vm()->heap.objectSpace().version());
+    clearMarks(vm()->heap.objectSpace().markingVersion());
 }
 
-void MarkedBlock::clearMarks(HeapVersion heapVersion)
+void MarkedBlock::clearMarks(HeapVersion markingVersion)
 {
     m_marks.clearAll();
     clearHasAnyMarked();
     WTF::storeStoreFence();
-    m_version = heapVersion;
+    m_markingVersion = markingVersion;
 }
 
 #if !ASSERT_DISABLED
-void MarkedBlock::assertFlipped()
+void MarkedBlock::assertMarksNotStale()
 {
-    ASSERT(m_version == vm()->heap.objectSpace().version());
+    ASSERT(m_markingVersion == vm()->heap.objectSpace().markingVersion());
 }
 #endif // !ASSERT_DISABLED
 
-bool MarkedBlock::needsFlip()
+bool MarkedBlock::areMarksStale()
 {
-    return needsFlip(vm()->heap.objectSpace().version());
+    return areMarksStale(vm()->heap.objectSpace().markingVersion());
 }
 
-bool MarkedBlock::Handle::needsFlip()
+bool MarkedBlock::Handle::areMarksStale()
 {
-    return m_block->needsFlip();
+    return m_block->areMarksStale();
 }
 
 bool MarkedBlock::isMarked(const void* p)
 {
-    return isMarked(vm()->heap.objectSpace().version(), p);
+    return isMarked(vm()->heap.objectSpace().markingVersion(), p);
 }
 
 bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(const HeapCell* cell)
 {
-    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().version(), cell);
+    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().markingVersion(), cell);
 }
 
 bool MarkedBlock::isMarkedOrNewlyAllocated(const HeapCell* cell)
 {
-    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().version(), cell);
+    return isMarkedOrNewlyAllocated(vm()->heap.objectSpace().markingVersion(), cell);
 }
 
 void MarkedBlock::Handle::didConsumeFreeList()
@@ -409,7 +409,7 @@ void MarkedBlock::Handle::didConsumeFreeList()
 
 size_t MarkedBlock::markCount()
 {
-    return needsFlip() ? 0 : m_marks.count();
+    return areMarksStale() ? 0 : m_marks.count();
 }
 
 bool MarkedBlock::Handle::isEmpty()
@@ -476,12 +476,12 @@ void MarkedBlock::Handle::didRemoveFromAllocator()
 
 bool MarkedBlock::Handle::isLive(const HeapCell* cell)
 {
-    return isLive(vm()->heap.objectSpace().version(), cell);
+    return isLive(vm()->heap.objectSpace().markingVersion(), cell);
 }
 
 bool MarkedBlock::Handle::isLiveCell(const void* p)
 {
-    return isLiveCell(vm()->heap.objectSpace().version(), p);
+    return isLiveCell(vm()->heap.objectSpace().markingVersion(), p);
 }
 
 } // namespace JSC
index 88cd27e..dd9e844 100644 (file)
@@ -154,14 +154,14 @@ public:
         size_t markCount();
         size_t size();
             
-        inline bool isLive(HeapVersion, const HeapCell*);
-        inline bool isLiveCell(HeapVersion, const void*);
+        inline bool isLive(HeapVersion markingVersion, const HeapCell*);
+        inline bool isLiveCell(HeapVersion markingVersion, const void*);
 
         bool isLive(const HeapCell*);
         bool isLiveCell(const void*);
 
         bool isMarkedOrNewlyAllocated(const HeapCell*);
-        bool isMarkedOrNewlyAllocated(HeapVersion, const HeapCell*);
+        bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell*);
             
         bool isNewlyAllocated(const void*);
         void setNewlyAllocated(const void*);
@@ -173,9 +173,9 @@ public:
         template <typename Functor> inline IterationStatus forEachLiveCell(const Functor&);
         template <typename Functor> inline IterationStatus forEachDeadCell(const Functor&);
             
-        bool needsFlip();
+        bool areMarksStale();
         
-        void assertFlipped();
+        void assertMarksNotStale();
             
         bool isFreeListed() const { return m_isFreeListed; }
         
@@ -208,11 +208,11 @@ public:
         FreeList sweepHelperSelectSweepMode(SweepMode = SweepOnly);
         
         template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode>
-        FreeList sweepHelperSelectFlipMode();
+        FreeList sweepHelperSelectMarksMode();
         
-        enum FlipMode { NeedsFlip, DoesNotNeedFlip };
+        enum MarksMode { MarksStale, MarksNotStale };
         
-        template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode, FlipMode>
+        template<EmptyMode, SweepMode, DestructionMode, ScribbleMode, NewlyAllocatedMode, MarksMode>
         FreeList specializedSweep();
             
         template<typename Func>
@@ -252,12 +252,12 @@ public:
     size_t markCount();
 
     bool isMarked(const void*);
-    bool isMarked(HeapVersion, const void*);
-    bool isMarkedConcurrently(HeapVersion, const void*);
+    bool isMarked(HeapVersion markingVersion, const void*);
+    bool isMarkedConcurrently(HeapVersion markingVersion, const void*);
     bool testAndSetMarked(const void*);
         
     bool isMarkedOrNewlyAllocated(const HeapCell*);
-    bool isMarkedOrNewlyAllocated(HeapVersion, const HeapCell*);
+    bool isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell*);
     
     bool isAtom(const void*);
     void clearMarked(const void*);
@@ -270,16 +270,16 @@ public:
         
     WeakSet& weakSet();
     
-    bool needsFlip(HeapVersion);
-    bool needsFlip();
+    bool areMarksStale(HeapVersion markingVersion);
+    bool areMarksStale();
     
-    void aboutToMark(HeapVersion);
+    void aboutToMark(HeapVersion markingVersion);
         
-    void assertFlipped();
+    void assertMarksNotStale();
         
     bool needsDestruction() const { return m_needsDestruction; }
     
-    inline void resetVersion();
+    inline void resetMarkingVersion();
     
 private:
     static const size_t atomAlignmentMask = atomSize - 1;
@@ -289,9 +289,9 @@ private:
     MarkedBlock(VM&, Handle&);
     Atom* atoms();
         
-    void aboutToMarkSlow(HeapVersion);
+    void aboutToMarkSlow(HeapVersion markingVersion);
     void clearMarks();
-    void clearMarks(HeapVersion);
+    void clearMarks(HeapVersion markingVersion);
     void clearHasAnyMarked();
     
     void noteMarkedSlow();
@@ -328,7 +328,7 @@ private:
     //     m_biasedMarkCount != m_markCountBias
     int16_t m_markCountBias;
 
-    HeapVersion m_version;
+    HeapVersion m_markingVersion;
     
     Handle& m_handle;
     VM* m_vm;
@@ -469,37 +469,37 @@ inline size_t MarkedBlock::atomNumber(const void* p)
     return (reinterpret_cast<Bits>(p) - reinterpret_cast<Bits>(this)) / atomSize;
 }
 
-inline bool MarkedBlock::needsFlip(HeapVersion heapVersion)
+inline bool MarkedBlock::areMarksStale(HeapVersion markingVersion)
 {
-    return heapVersion != m_version;
+    return markingVersion != m_markingVersion;
 }
 
-inline void MarkedBlock::aboutToMark(HeapVersion heapVersion)
+inline void MarkedBlock::aboutToMark(HeapVersion markingVersion)
 {
-    if (UNLIKELY(needsFlip(heapVersion)))
-        aboutToMarkSlow(heapVersion);
+    if (UNLIKELY(areMarksStale(markingVersion)))
+        aboutToMarkSlow(markingVersion);
     WTF::loadLoadFence();
 }
 
 #if ASSERT_DISABLED
-inline void MarkedBlock::assertFlipped()
+inline void MarkedBlock::assertMarksNotStale()
 {
 }
 #endif // ASSERT_DISABLED
 
-inline void MarkedBlock::Handle::assertFlipped()
+inline void MarkedBlock::Handle::assertMarksNotStale()
 {
-    block().assertFlipped();
+    block().assertMarksNotStale();
 }
 
-inline bool MarkedBlock::isMarked(HeapVersion heapVersion, const void* p)
+inline bool MarkedBlock::isMarked(HeapVersion markingVersion, const void* p)
 {
-    return needsFlip(heapVersion) ? false : m_marks.get(atomNumber(p));
+    return areMarksStale(markingVersion) ? false : m_marks.get(atomNumber(p));
 }
 
-inline bool MarkedBlock::isMarkedConcurrently(HeapVersion heapVersion, const void* p)
+inline bool MarkedBlock::isMarkedConcurrently(HeapVersion markingVersion, const void* p)
 {
-    if (needsFlip(heapVersion))
+    if (areMarksStale(markingVersion))
         return false;
     WTF::loadLoadFence();
     return m_marks.get(atomNumber(p));
@@ -507,7 +507,7 @@ inline bool MarkedBlock::isMarkedConcurrently(HeapVersion heapVersion, const voi
 
 inline bool MarkedBlock::testAndSetMarked(const void* p)
 {
-    assertFlipped();
+    assertMarksNotStale();
     return m_marks.concurrentTestAndSet(atomNumber(p));
 }
 
@@ -535,14 +535,14 @@ inline bool MarkedBlock::Handle::clearNewlyAllocated()
     return false;
 }
 
-inline bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(HeapVersion version, const HeapCell* cell)
+inline bool MarkedBlock::Handle::isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell* cell)
 {
-    return m_block->isMarked(version, cell) || (m_newlyAllocated && isNewlyAllocated(cell));
+    return m_block->isMarked(markingVersion, cell) || (m_newlyAllocated && isNewlyAllocated(cell));
 }
 
-inline bool MarkedBlock::isMarkedOrNewlyAllocated(HeapVersion version, const HeapCell* cell)
+inline bool MarkedBlock::isMarkedOrNewlyAllocated(HeapVersion markingVersion, const HeapCell* cell)
 {
-    return isMarked(version, cell) || (m_handle.m_newlyAllocated && m_handle.isNewlyAllocated(cell));
+    return isMarked(markingVersion, cell) || (m_handle.m_newlyAllocated && m_handle.isNewlyAllocated(cell));
 }
 
 inline bool MarkedBlock::isAtom(const void* p)
index d09fafb..e7638aa 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace JSC {
 
-inline bool MarkedBlock::Handle::isLive(HeapVersion version, const HeapCell* cell)
+inline bool MarkedBlock::Handle::isLive(HeapVersion markingVersion, const HeapCell* cell)
 {
     ASSERT(!isFreeListed());
     
@@ -44,17 +44,17 @@ inline bool MarkedBlock::Handle::isLive(HeapVersion version, const HeapCell* cel
     if (allocator()->isAllocated(this))
         return true;
     
-    if (block.needsFlip(version))
+    if (block.areMarksStale(markingVersion))
         return false;
 
     return block.isMarked(cell);
 }
 
-inline bool MarkedBlock::Handle::isLiveCell(HeapVersion version, const void* p)
+inline bool MarkedBlock::Handle::isLiveCell(HeapVersion markingVersion, const void* p)
 {
     if (!m_block->isAtom(p))
         return false;
-    return isLive(version, static_cast<const HeapCell*>(p));
+    return isLive(markingVersion, static_cast<const HeapCell*>(p));
 }
 
 template <typename Functor>
@@ -87,9 +87,9 @@ inline IterationStatus MarkedBlock::Handle::forEachDeadCell(const Functor& funct
     return IterationStatus::Continue;
 }
 
-inline void MarkedBlock::resetVersion()
+inline void MarkedBlock::resetMarkingVersion()
 {
-    m_version = MarkedSpace::nullVersion;
+    m_markingVersion = MarkedSpace::nullVersion;
 }
 
 } // namespace JSC
index 1ccba3b..cce0654 100644 (file)
@@ -458,13 +458,13 @@ void MarkedSpace::beginMarking()
                 return IterationStatus::Continue;
             });
 
-        m_version = nextVersion(m_version);
+        m_markingVersion = nextVersion(m_markingVersion);
         
-        if (UNLIKELY(m_version == initialVersion)) {
+        if (UNLIKELY(m_markingVersion == initialVersion)) {
             // Oh no! Version wrap-around! We handle this by setting all block versions to null.
             forEachBlock(
                 [&] (MarkedBlock::Handle* handle) {
-                    handle->block().resetVersion();
+                    handle->block().resetMarkingVersion();
                 });
         }
         
@@ -475,7 +475,7 @@ void MarkedSpace::beginMarking()
     if (!ASSERT_DISABLED) {
         forEachBlock(
             [&] (MarkedBlock::Handle* block) {
-                if (block->needsFlip())
+                if (block->areMarksStale())
                     return;
                 ASSERT(!block->isFreeListed());
             });
index 684b4a9..34718e3 100644 (file)
@@ -166,7 +166,7 @@ public:
 
     bool isPagedOut(double deadline);
     
-    HeapVersion version() const { return m_version; }
+    HeapVersion markingVersion() const { return m_markingVersion; }
 
     const Vector<LargeAllocation*>& largeAllocations() const { return m_largeAllocations; }
     unsigned largeAllocationsNurseryOffset() const { return m_largeAllocationsNurseryOffset; }
@@ -212,7 +212,7 @@ private:
     Subspace m_auxiliarySpace;
 
     Heap* m_heap;
-    HeapVersion m_version { initialVersion };
+    HeapVersion m_markingVersion { initialVersion };
     size_t m_capacity;
     bool m_isIterating;
     bool m_isMarking { false };
index 3f8b233..8371721 100644 (file)
@@ -78,7 +78,7 @@ SlotVisitor::SlotVisitor(Heap& heap)
     , m_bytesCopied(0)
     , m_visitCount(0)
     , m_isInParallelMode(false)
-    , m_version(MarkedSpace::initialVersion)
+    , m_markingVersion(MarkedSpace::initialVersion)
     , m_heap(heap)
 #if !ASSERT_DISABLED
     , m_isCheckingForDefaultMarkViolation(false)
@@ -102,7 +102,7 @@ void SlotVisitor::didStartMarking()
     if (HeapProfiler* heapProfiler = vm().heapProfiler())
         m_heapSnapshotBuilder = heapProfiler->activeSnapshotBuilder();
     
-    m_version = heap()->objectSpace().version();
+    m_markingVersion = heap()->objectSpace().markingVersion();
 }
 
 void SlotVisitor::reset()
@@ -134,7 +134,7 @@ void SlotVisitor::appendJSCellOrAuxiliary(HeapCell* heapCell)
     
     ASSERT(!m_isCheckingForDefaultMarkViolation);
     
-    if (Heap::testAndSetMarked(m_version, heapCell))
+    if (Heap::testAndSetMarked(m_markingVersion, heapCell))
         return;
     
     switch (heapCell->cellKind()) {
@@ -200,7 +200,7 @@ void SlotVisitor::setMarkedAndAppendToMarkStack(JSCell* cell)
 template<typename ContainerType>
 ALWAYS_INLINE void SlotVisitor::setMarkedAndAppendToMarkStack(ContainerType& container, JSCell* cell)
 {
-    container.aboutToMark(m_version);
+    container.aboutToMark(m_markingVersion);
     
     if (container.testAndSetMarked(cell))
         return;
@@ -248,7 +248,7 @@ void SlotVisitor::markAuxiliary(const void* base)
     
     ASSERT(cell->heap() == heap());
     
-    if (Heap::testAndSetMarked(m_version, cell))
+    if (Heap::testAndSetMarked(m_markingVersion, cell))
         return;
     
     noteLiveAuxiliaryCell(cell);
index 9fc1362..b1e4b8b 100644 (file)
@@ -124,7 +124,7 @@ public:
 
     bool isBuildingHeapSnapshot() const { return !!m_heapSnapshotBuilder; }
     
-    HeapVersion version() const { return m_version; }
+    HeapVersion markingVersion() const { return m_markingVersion; }
 
 private:
     friend class ParallelModeEnabler;
@@ -161,7 +161,7 @@ private:
     size_t m_visitCount;
     bool m_isInParallelMode;
     
-    HeapVersion m_version;
+    HeapVersion m_markingVersion;
     
     Heap& m_heap;
 
index aed147f..dc57cc4 100644 (file)
@@ -101,7 +101,7 @@ void WeakBlock::specializedVisit(ContainerType& container, HeapRootVisitor& heap
 {
     SlotVisitor& visitor = heapRootVisitor.visitor();
     
-    HeapVersion version = visitor.version();
+    HeapVersion markingVersion = visitor.markingVersion();
 
     for (size_t i = 0; i < weakImplCount(); ++i) {
         WeakImpl* weakImpl = &weakImpls()[i];
@@ -113,7 +113,7 @@ void WeakBlock::specializedVisit(ContainerType& container, HeapRootVisitor& heap
             continue;
 
         const JSValue& jsValue = weakImpl->jsValue();
-        if (container.isMarkedConcurrently(version, jsValue.asCell()))
+        if (container.isMarkedConcurrently(markingVersion, jsValue.asCell()))
             continue;
         
         if (!weakHandleOwner->isReachableFromOpaqueRoots(Handle<Unknown>::wrapSlot(&const_cast<JSValue&>(jsValue)), weakImpl->context(), visitor))
@@ -147,14 +147,14 @@ void WeakBlock::reap()
     // If this WeakBlock doesn't belong to a CellContainer, we won't even be here.
     ASSERT(m_container);
     
-    HeapVersion version = m_container.heap()->objectSpace().version();
+    HeapVersion markingVersion = m_container.heap()->objectSpace().markingVersion();
 
     for (size_t i = 0; i < weakImplCount(); ++i) {
         WeakImpl* weakImpl = &weakImpls()[i];
         if (weakImpl->state() > WeakImpl::Dead)
             continue;
 
-        if (m_container.isMarked(version, weakImpl->jsValue().asCell())) {
+        if (m_container.isMarked(markingVersion, weakImpl->jsValue().asCell())) {
             ASSERT(weakImpl->state() == WeakImpl::Live);
             continue;
         }