Commit 5a50fed9 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Add shared barrier to range barrier

The range barrier needs to update the old-to-shared remembered set as
well.

Bug: v8:11708
Change-Id: I79c077bb0131f026bd8c6726100df8c5b576eaca
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3828100Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82532}
parent e43e535d
...@@ -7336,7 +7336,7 @@ void Heap::EphemeronKeyWriteBarrierFromCode(Address raw_object, ...@@ -7336,7 +7336,7 @@ void Heap::EphemeronKeyWriteBarrierFromCode(Address raw_object,
} }
enum RangeWriteBarrierMode { enum RangeWriteBarrierMode {
kDoGenerational = 1 << 0, kDoGenerationalOrShared = 1 << 0,
kDoMarking = 1 << 1, kDoMarking = 1 << 1,
kDoEvacuationSlotRecording = 1 << 2, kDoEvacuationSlotRecording = 1 << 2,
}; };
...@@ -7345,7 +7345,7 @@ template <int kModeMask, typename TSlot> ...@@ -7345,7 +7345,7 @@ template <int kModeMask, typename TSlot>
void Heap::WriteBarrierForRangeImpl(MemoryChunk* source_page, HeapObject object, void Heap::WriteBarrierForRangeImpl(MemoryChunk* source_page, HeapObject object,
TSlot start_slot, TSlot end_slot) { TSlot start_slot, TSlot end_slot) {
// At least one of generational or marking write barrier should be requested. // At least one of generational or marking write barrier should be requested.
static_assert(kModeMask & (kDoGenerational | kDoMarking)); static_assert(kModeMask & (kDoGenerationalOrShared | kDoMarking));
// kDoEvacuationSlotRecording implies kDoMarking. // kDoEvacuationSlotRecording implies kDoMarking.
static_assert(!(kModeMask & kDoEvacuationSlotRecording) || static_assert(!(kModeMask & kDoEvacuationSlotRecording) ||
(kModeMask & kDoMarking)); (kModeMask & kDoMarking));
...@@ -7362,10 +7362,14 @@ void Heap::WriteBarrierForRangeImpl(MemoryChunk* source_page, HeapObject object, ...@@ -7362,10 +7362,14 @@ void Heap::WriteBarrierForRangeImpl(MemoryChunk* source_page, HeapObject object,
HeapObject value_heap_object; HeapObject value_heap_object;
if (!value.GetHeapObject(&value_heap_object)) continue; if (!value.GetHeapObject(&value_heap_object)) continue;
if ((kModeMask & kDoGenerational) && if (kModeMask & kDoGenerationalOrShared) {
Heap::InYoungGeneration(value_heap_object)) { if (Heap::InYoungGeneration(value_heap_object)) {
RememberedSet<OLD_TO_NEW>::Insert<AccessMode::NON_ATOMIC>(source_page, RememberedSet<OLD_TO_NEW>::Insert<AccessMode::NON_ATOMIC>(
slot.address()); source_page, slot.address());
} else if (value_heap_object.InSharedWritableHeap()) {
RememberedSet<OLD_TO_SHARED>::Insert<AccessMode::ATOMIC>(
source_page, slot.address());
}
} }
if ((kModeMask & kDoMarking) && if ((kModeMask & kDoMarking) &&
...@@ -7393,7 +7397,7 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot, ...@@ -7393,7 +7397,7 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot,
base::Flags<RangeWriteBarrierMode> mode; base::Flags<RangeWriteBarrierMode> mode;
if (!source_page->InYoungGeneration()) { if (!source_page->InYoungGeneration()) {
mode |= kDoGenerational; mode |= kDoGenerationalOrShared;
} }
if (incremental_marking()->IsMarking()) { if (incremental_marking()->IsMarking()) {
...@@ -7409,9 +7413,9 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot, ...@@ -7409,9 +7413,9 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot,
return; return;
// Generational only. // Generational only.
case kDoGenerational: case kDoGenerationalOrShared:
return WriteBarrierForRangeImpl<kDoGenerational>(source_page, object, return WriteBarrierForRangeImpl<kDoGenerationalOrShared>(
start_slot, end_slot); source_page, object, start_slot, end_slot);
// Marking, no evacuation slot recording. // Marking, no evacuation slot recording.
case kDoMarking: case kDoMarking:
return WriteBarrierForRangeImpl<kDoMarking>(source_page, object, return WriteBarrierForRangeImpl<kDoMarking>(source_page, object,
...@@ -7422,13 +7426,13 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot, ...@@ -7422,13 +7426,13 @@ void Heap::WriteBarrierForRange(HeapObject object, TSlot start_slot,
source_page, object, start_slot, end_slot); source_page, object, start_slot, end_slot);
// Generational and marking, no evacuation slot recording. // Generational and marking, no evacuation slot recording.
case kDoGenerational | kDoMarking: case kDoGenerationalOrShared | kDoMarking:
return WriteBarrierForRangeImpl<kDoGenerational | kDoMarking>( return WriteBarrierForRangeImpl<kDoGenerationalOrShared | kDoMarking>(
source_page, object, start_slot, end_slot); source_page, object, start_slot, end_slot);
// Generational and marking with evacuation slot recording. // Generational and marking with evacuation slot recording.
case kDoGenerational | kDoMarking | kDoEvacuationSlotRecording: case kDoGenerationalOrShared | kDoMarking | kDoEvacuationSlotRecording:
return WriteBarrierForRangeImpl<kDoGenerational | kDoMarking | return WriteBarrierForRangeImpl<kDoGenerationalOrShared | kDoMarking |
kDoEvacuationSlotRecording>( kDoEvacuationSlotRecording>(
source_page, object, start_slot, end_slot); source_page, object, start_slot, end_slot);
......
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