#ifndef V8_HEAP_HEAP_WRITE_BARRIER_INL_H_
#define V8_HEAP_HEAP_WRITE_BARRIER_INL_H_
#include "src/heap/heap-write-barrier.h"
#include "src/heap/marking-barrier.h"
#include "src/heap/memory-chunk.h"
#include "src/objects/compressed-slots-inl.h"
#include "src/objects/maybe-object-inl.h"
namespace v8 {
namespace internal {
V8_EXPORT_PRIVATE bool Heap_PageFlagsAreConsistent(Tagged<HeapObject> object);
V8_EXPORT_PRIVATE void Heap_CombinedGenerationalAndSharedBarrierSlow(
Tagged<HeapObject> object, Address slot, Tagged<HeapObject> value);
V8_EXPORT_PRIVATE void Heap_CombinedGenerationalAndSharedEphemeronBarrierSlow(
Tagged<EphemeronHashTable> table, Address slot, Tagged<HeapObject> value);
V8_EXPORT_PRIVATE void Heap_GenerationalBarrierForCodeSlow(
Tagged<InstructionStream> host, RelocInfo* rinfo,
Tagged<HeapObject> object);
V8_EXPORT_PRIVATE void Heap_GenerationalEphemeronKeyBarrierSlow(
Heap* heap, Tagged<HeapObject> table, Address slot);
inline bool IsCodeSpaceObject(Tagged<HeapObject> object);
inline bool IsTrustedSpaceObject(Tagged<HeapObject> object);
V8_EXPORT_PRIVATE bool HeapObjectInYoungGenerationSticky(
MemoryChunk* chunk, Tagged<HeapObject> object);
inline bool HeapObjectInYoungGeneration(MemoryChunk* chunk,
Tagged<HeapObject> object) { … }
inline bool HeapObjectInYoungGeneration(Tagged<HeapObject> object) { … }
namespace heap_internals {
inline void CombinedWriteBarrierInternal(Tagged<HeapObject> host,
HeapObjectSlot slot,
Tagged<HeapObject> value,
WriteBarrierMode mode) { … }
}
inline void WriteBarrierForCode(Tagged<InstructionStream> host,
RelocInfo* rinfo, Tagged<Object> value,
WriteBarrierMode mode) { … }
inline void WriteBarrierForCode(Tagged<InstructionStream> host,
RelocInfo* rinfo, Tagged<HeapObject> value,
WriteBarrierMode mode) { … }
inline void CombinedWriteBarrier(Tagged<HeapObject> host, ObjectSlot slot,
Tagged<Object> value, WriteBarrierMode mode) { … }
inline void CombinedWriteBarrier(Tagged<HeapObject> host, MaybeObjectSlot slot,
Tagged<MaybeObject> value,
WriteBarrierMode mode) { … }
inline void CombinedWriteBarrier(HeapObjectLayout* host,
TaggedMemberBase* member, Tagged<Object> value,
WriteBarrierMode mode) { … }
inline void CombinedEphemeronWriteBarrier(Tagged<EphemeronHashTable> host,
ObjectSlot slot, Tagged<Object> value,
WriteBarrierMode mode) { … }
inline void IndirectPointerWriteBarrier(Tagged<HeapObject> host,
IndirectPointerSlot slot,
Tagged<HeapObject> value,
WriteBarrierMode mode) { … }
inline void JSDispatchHandleWriteBarrier(Tagged<HeapObject> host,
JSDispatchHandle handle,
WriteBarrierMode mode) { … }
inline void ProtectedPointerWriteBarrier(Tagged<TrustedObject> host,
ProtectedPointerSlot slot,
Tagged<TrustedObject> value,
WriteBarrierMode mode) { … }
inline void GenerationalBarrierForCode(Tagged<InstructionStream> host,
RelocInfo* rinfo,
Tagged<HeapObject> object) { … }
inline WriteBarrierMode GetWriteBarrierModeForObject(
Tagged<HeapObject> object, const DisallowGarbageCollection* promise) { … }
inline bool ObjectInYoungGeneration(Tagged<Object> object) { … }
inline bool IsReadOnlyHeapObject(Tagged<HeapObject> object) { … }
inline bool IsCodeSpaceObject(Tagged<HeapObject> object) { … }
inline bool IsTrustedSpaceObject(Tagged<HeapObject> object) { … }
bool WriteBarrier::IsMarking(Tagged<HeapObject> object) { … }
void WriteBarrier::Marking(Tagged<HeapObject> host, ObjectSlot slot,
Tagged<Object> value) { … }
void WriteBarrier::Marking(Tagged<HeapObject> host, MaybeObjectSlot slot,
Tagged<MaybeObject> value) { … }
void WriteBarrier::Marking(Tagged<HeapObject> host, HeapObjectSlot slot,
Tagged<HeapObject> value) { … }
void WriteBarrier::Marking(Tagged<InstructionStream> host,
RelocInfo* reloc_info, Tagged<HeapObject> value) { … }
void WriteBarrier::Shared(Tagged<InstructionStream> host, RelocInfo* reloc_info,
Tagged<HeapObject> value) { … }
void WriteBarrier::Marking(Tagged<JSArrayBuffer> host,
ArrayBufferExtension* extension) { … }
void WriteBarrier::Marking(Tagged<DescriptorArray> descriptor_array,
int number_of_own_descriptors) { … }
void WriteBarrier::Marking(Tagged<HeapObject> host, IndirectPointerSlot slot) { … }
void WriteBarrier::Marking(Tagged<TrustedObject> host,
ProtectedPointerSlot slot,
Tagged<TrustedObject> value) { … }
void WriteBarrier::Marking(Tagged<HeapObject> host, JSDispatchHandle handle) { … }
void WriteBarrier::MarkingFromGlobalHandle(Tagged<Object> value) { … }
void WriteBarrier::CombinedBarrierForCppHeapPointer(Tagged<JSObject> host,
void* value) { … }
void WriteBarrier::GenerationalBarrierForCppHeapPointer(Tagged<JSObject> host,
void* value) { … }
#ifdef ENABLE_SLOW_DCHECKS
template <typename T>
bool WriteBarrier::IsRequired(Tagged<HeapObject> host, T value) {
if (HeapObjectInYoungGeneration(host)) return false;
if (IsSmi(value)) return false;
if (value.IsCleared()) return false;
Tagged<HeapObject> target = value.GetHeapObject();
if (ReadOnlyHeap::Contains(target)) return false;
return !IsImmortalImmovableHeapObject(target);
}
template <typename T>
bool WriteBarrier::IsRequired(const HeapObjectLayout* host, T value) {
if (HeapObjectInYoungGeneration(host)) return false;
if (IsSmi(value)) return false;
if (value.IsCleared()) return false;
Tagged<HeapObject> target = value.GetHeapObject();
if (ReadOnlyHeap::Contains(target)) return false;
return !IsImmortalImmovableHeapObject(target);
}
#endif
}
}
#endif