Commit 3e3dd792 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap, deserializer] Use full write barrier in the deserializer

Instead of invoking both the generational and marking barrier
explicitly, we can just invoke the combined barrier which does both
for us.

Also we simply use the full write barrier for all writes in the deserializer. While we could avoid the generational barrier in a few
cases, this only costs us a single predictable untaken branch without
an additional load.

Bug: v8:11708
Change-Id: Iebd0af06efe42a3ac4e5725131362600ab16bc7a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3662900
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80712}
parent ab2aa72d
......@@ -92,21 +92,6 @@ struct MemoryChunk {
V8_INLINE bool InCodeSpace() const { return GetFlags() & kIsExecutableBit; }
};
inline void GenerationalBarrierInternal(HeapObject object, Address slot,
HeapObject value) {
DCHECK(Heap_PageFlagsAreConsistent(object));
heap_internals::MemoryChunk* value_chunk =
heap_internals::MemoryChunk::FromHeapObject(value);
heap_internals::MemoryChunk* object_chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
if (!value_chunk->InYoungGeneration() || object_chunk->InYoungGeneration()) {
return;
}
Heap_GenerationalBarrierSlow(object, slot, value);
}
inline void CombinedWriteBarrierInternal(HeapObject host, HeapObjectSlot slot,
HeapObject value,
WriteBarrierMode mode) {
......@@ -228,15 +213,6 @@ inline void CombinedEphemeronWriteBarrier(EphemeronHashTable host,
}
}
inline void GenerationalBarrier(HeapObject object, MaybeObjectSlot slot,
MaybeObject value) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
HeapObject value_heap_object;
if (!value->GetHeapObject(&value_heap_object)) return;
heap_internals::GenerationalBarrierInternal(object, slot.address(),
value_heap_object);
}
inline void GenerationalBarrierForCode(Code host, RelocInfo* rinfo,
HeapObject object) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
......
......@@ -42,8 +42,6 @@ void CombinedEphemeronWriteBarrier(EphemeronHashTable object, ObjectSlot slot,
Object value, WriteBarrierMode mode);
// Generational write barrier.
void GenerationalBarrier(HeapObject object, MaybeObjectSlot slot,
MaybeObject value);
void GenerationalBarrierForCode(Code host, RelocInfo* rinfo, HeapObject object);
// Shared heap write barrier.
......
......@@ -70,9 +70,7 @@ class SlotAccessorForHeapObject {
int Write(MaybeObject value, int slot_offset = 0) {
MaybeObjectSlot current_slot = slot() + slot_offset;
current_slot.Relaxed_Store(value);
WriteBarrier::Marking(*object_, current_slot, value);
// No need for a generational write barrier.
DCHECK(!Heap::InYoungGeneration(value));
CombinedWriteBarrier(*object_, current_slot, value, UPDATE_WRITE_BARRIER);
return 1;
}
int Write(HeapObject value, HeapObjectReferenceType ref_type,
......@@ -84,26 +82,6 @@ class SlotAccessorForHeapObject {
return Write(*value, ref_type, slot_offset);
}
// Same as Write, but additionally with a generational barrier.
int WriteWithGenerationalBarrier(MaybeObject value) {
MaybeObjectSlot current_slot = slot();
current_slot.Relaxed_Store(value);
WriteBarrier::Marking(*object_, current_slot, value);
if (Heap::InYoungGeneration(value)) {
GenerationalBarrier(*object_, current_slot, value);
}
return 1;
}
int WriteWithGenerationalBarrier(HeapObject value,
HeapObjectReferenceType ref_type) {
return WriteWithGenerationalBarrier(
HeapObjectReference::From(value, ref_type));
}
int WriteWithGenerationalBarrier(Handle<HeapObject> value,
HeapObjectReferenceType ref_type) {
return WriteWithGenerationalBarrier(*value, ref_type);
}
private:
SlotAccessorForHeapObject(Handle<HeapObject> object, int offset)
: object_(object), offset_(offset) {}
......@@ -137,17 +115,6 @@ class SlotAccessorForRootSlots {
return Write(*value, ref_type, slot_offset);
}
int WriteWithGenerationalBarrier(MaybeObject value) { return Write(value); }
int WriteWithGenerationalBarrier(HeapObject value,
HeapObjectReferenceType ref_type) {
return WriteWithGenerationalBarrier(
HeapObjectReference::From(value, ref_type));
}
int WriteWithGenerationalBarrier(Handle<HeapObject> value,
HeapObjectReferenceType ref_type) {
return WriteWithGenerationalBarrier(*value, ref_type);
}
private:
const FullMaybeObjectSlot slot_;
};
......@@ -180,15 +147,6 @@ class SlotAccessorForHandle {
return 1;
}
int WriteWithGenerationalBarrier(HeapObject value,
HeapObjectReferenceType ref_type) {
return Write(value, ref_type);
}
int WriteWithGenerationalBarrier(Handle<HeapObject> value,
HeapObjectReferenceType ref_type) {
return Write(value, ref_type);
}
private:
Handle<HeapObject>* handle_;
IsolateT* isolate_;
......@@ -1035,11 +993,7 @@ int Deserializer<IsolateT>::ReadSingleBytecodeData(byte data,
case kAttachedReference: {
int index = source_.GetInt();
Handle<HeapObject> heap_object = attached_objects_[index];
// This is the only case where we might encounter new space objects, so
// maybe emit a generational write barrier.
return slot_accessor.WriteWithGenerationalBarrier(
heap_object, GetAndResetNextReferenceType());
return slot_accessor.Write(heap_object, GetAndResetNextReferenceType());
}
case kNop:
......
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