Commit 33ca2bcb authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Use black color in MinorMC

MinorMC only used a single color (grey) while the full MC used 2 colors
(grey and black). Update MinorMC to use black as well. This aligns and
brings full MC and MinorMC closer, and allows to reuse more of the
existing sweeping infrastructure for the non-moving MinorMC.

Bug: v8:12612
Change-Id: Ifa740537c4587dc197196e41829ea74a312b79d0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3683320Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80894}
parent 3694eba7
...@@ -1917,8 +1917,6 @@ DEFINE_NEG_NEG_IMPLICATION(text_is_readable, partial_constant_pool) ...@@ -1917,8 +1917,6 @@ DEFINE_NEG_NEG_IMPLICATION(text_is_readable, partial_constant_pool)
DEFINE_BOOL(trace_minor_mc_parallel_marking, false, DEFINE_BOOL(trace_minor_mc_parallel_marking, false,
"trace parallel marking for the young generation") "trace parallel marking for the young generation")
DEFINE_BOOL(minor_mc, false, "perform young generation mark compact GCs") DEFINE_BOOL(minor_mc, false, "perform young generation mark compact GCs")
DEFINE_BOOL(minor_mc_sweeping, false,
"perform sweeping in young generation mark compact GCs")
// //
// Dev shell flags // Dev shell flags
......
...@@ -46,7 +46,8 @@ class ConcurrentMarkingState final ...@@ -46,7 +46,8 @@ class ConcurrentMarkingState final
MemoryChunkDataMap* memory_chunk_data) MemoryChunkDataMap* memory_chunk_data)
: MarkingStateBase(cage_base), memory_chunk_data_(memory_chunk_data) {} : MarkingStateBase(cage_base), memory_chunk_data_(memory_chunk_data) {}
ConcurrentBitmap<AccessMode::ATOMIC>* bitmap(const BasicMemoryChunk* chunk) { ConcurrentBitmap<AccessMode::ATOMIC>* bitmap(
const BasicMemoryChunk* chunk) const {
return chunk->marking_bitmap<AccessMode::ATOMIC>(); return chunk->marking_bitmap<AccessMode::ATOMIC>();
} }
......
...@@ -400,9 +400,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterYoungGenGC() { ...@@ -400,9 +400,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterYoungGenGC() {
DCHECK(obj.IsHeapObject()); DCHECK(obj.IsHeapObject());
// Only pointers to from space have to be updated. // Only pointers to from space have to be updated.
if (Heap::InFromPage(obj)) { if (Heap::InFromPage(obj)) {
DCHECK_IMPLIES(FLAG_minor_mc_sweeping, minor_marking_state->IsWhite(obj));
MapWord map_word = obj.map_word(cage_base, kRelaxedLoad); MapWord map_word = obj.map_word(cage_base, kRelaxedLoad);
DCHECK_IMPLIES(FLAG_minor_mc_sweeping, !map_word.IsForwardingAddress());
if (!map_word.IsForwardingAddress()) { if (!map_word.IsForwardingAddress()) {
// There may be objects on the marking deque that do not exist // There may be objects on the marking deque that do not exist
// anymore, e.g. left trimmed objects or objects from the root set // anymore, e.g. left trimmed objects or objects from the root set
......
...@@ -42,7 +42,7 @@ void MarkCompactCollector::MarkRootObject(Root root, HeapObject obj) { ...@@ -42,7 +42,7 @@ void MarkCompactCollector::MarkRootObject(Root root, HeapObject obj) {
void MinorMarkCompactCollector::MarkRootObject(HeapObject obj) { void MinorMarkCompactCollector::MarkRootObject(HeapObject obj) {
if (Heap::InYoungGeneration(obj) && if (Heap::InYoungGeneration(obj) &&
non_atomic_marking_state_.WhiteToGrey(obj)) { non_atomic_marking_state_.WhiteToBlack(obj)) {
main_thread_worklist_local_.Push(obj); main_thread_worklist_local_.Push(obj);
} }
} }
......
This diff is collapsed.
...@@ -176,13 +176,6 @@ class LiveObjectVisitor : AllStatic { ...@@ -176,13 +176,6 @@ class LiveObjectVisitor : AllStatic {
Visitor* visitor, Visitor* visitor,
IterationMode iteration_mode); IterationMode iteration_mode);
// Visits black objects on a MemoryChunk. The visitor is not allowed to fail
// visitation for an object.
template <class Visitor, typename MarkingState>
static void VisitGreyObjectsNoFail(MemoryChunk* chunk, MarkingState* state,
Visitor* visitor,
IterationMode iteration_mode);
template <typename MarkingState> template <typename MarkingState>
static void RecomputeLiveBytes(MemoryChunk* chunk, MarkingState* state); static void RecomputeLiveBytes(MemoryChunk* chunk, MarkingState* state);
}; };
...@@ -207,7 +200,7 @@ class MinorMarkingState final ...@@ -207,7 +200,7 @@ class MinorMarkingState final
chunk->young_generation_live_byte_count_ += by; chunk->young_generation_live_byte_count_ += by;
} }
intptr_t live_bytes(MemoryChunk* chunk) const { intptr_t live_bytes(const MemoryChunk* chunk) const {
return chunk->young_generation_live_byte_count_; return chunk->young_generation_live_byte_count_;
} }
...@@ -234,7 +227,7 @@ class MinorNonAtomicMarkingState final ...@@ -234,7 +227,7 @@ class MinorNonAtomicMarkingState final
by, std::memory_order_relaxed); by, std::memory_order_relaxed);
} }
intptr_t live_bytes(MemoryChunk* chunk) const { intptr_t live_bytes(const MemoryChunk* chunk) const {
return chunk->young_generation_live_byte_count_.load( return chunk->young_generation_live_byte_count_.load(
std::memory_order_relaxed); std::memory_order_relaxed);
} }
......
...@@ -47,37 +47,37 @@ class MarkingStateBase { ...@@ -47,37 +47,37 @@ class MarkingStateBase {
#endif // V8_COMPRESS_POINTERS #endif // V8_COMPRESS_POINTERS
} }
V8_INLINE MarkBit MarkBitFrom(HeapObject obj) { V8_INLINE MarkBit MarkBitFrom(const HeapObject obj) const {
return MarkBitFrom(BasicMemoryChunk::FromHeapObject(obj), obj.ptr()); return MarkBitFrom(BasicMemoryChunk::FromHeapObject(obj), obj.ptr());
} }
// {addr} may be tagged or aligned. // {addr} may be tagged or aligned.
V8_INLINE MarkBit MarkBitFrom(BasicMemoryChunk* p, Address addr) { V8_INLINE MarkBit MarkBitFrom(const BasicMemoryChunk* p, Address addr) const {
return static_cast<ConcreteState*>(this)->bitmap(p)->MarkBitFromIndex( return static_cast<const ConcreteState*>(this)->bitmap(p)->MarkBitFromIndex(
p->AddressToMarkbitIndex(addr)); p->AddressToMarkbitIndex(addr));
} }
Marking::ObjectColor Color(HeapObject obj) { Marking::ObjectColor Color(const HeapObject obj) const {
return Marking::Color(MarkBitFrom(obj)); return Marking::Color(MarkBitFrom(obj));
} }
V8_INLINE bool IsImpossible(HeapObject obj) { V8_INLINE bool IsImpossible(const HeapObject obj) const {
return Marking::IsImpossible<access_mode>(MarkBitFrom(obj)); return Marking::IsImpossible<access_mode>(MarkBitFrom(obj));
} }
V8_INLINE bool IsBlack(HeapObject obj) { V8_INLINE bool IsBlack(const HeapObject obj) const {
return Marking::IsBlack<access_mode>(MarkBitFrom(obj)); return Marking::IsBlack<access_mode>(MarkBitFrom(obj));
} }
V8_INLINE bool IsWhite(HeapObject obj) { V8_INLINE bool IsWhite(const HeapObject obj) const {
return Marking::IsWhite<access_mode>(MarkBitFrom(obj)); return Marking::IsWhite<access_mode>(MarkBitFrom(obj));
} }
V8_INLINE bool IsGrey(HeapObject obj) { V8_INLINE bool IsGrey(const HeapObject obj) const {
return Marking::IsGrey<access_mode>(MarkBitFrom(obj)); return Marking::IsGrey<access_mode>(MarkBitFrom(obj));
} }
V8_INLINE bool IsBlackOrGrey(HeapObject obj) { V8_INLINE bool IsBlackOrGrey(const HeapObject obj) const {
return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj)); return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment