#include "src/heap/heap-layout-inl.h"
#include "src/heap/marking-inl.h"
#include "src/heap/memory-chunk.h"
#include "src/objects/objects-inl.h"
namespace v8::internal {
bool HeapLayout::InYoungGenerationForStickyMarkbits(const MemoryChunk* chunk,
Tagged<HeapObject> object) {
CHECK(v8_flags.sticky_mark_bits.value());
return !chunk->IsOnlyOldOrMajorMarkingOn() &&
!MarkingBitmap::MarkBitFromAddress(Isolate::Current(),
object.address())
.template Get<AccessMode::ATOMIC>();
}
void HeapLayout::CheckYoungGenerationConsistency(const MemoryChunk* chunk) {
#ifdef DEBUG
const MemoryChunkMetadata* metadata = chunk->Metadata();
SLOW_DCHECK(metadata->IsWritable());
Heap* heap = metadata->heap();
SLOW_DCHECK(heap != nullptr);
DCHECK_IMPLIES(heap->gc_state() == Heap::NOT_IN_GC, chunk->IsToPage());
#endif
}
bool HeapLayout::IsSelfForwarded(Tagged<HeapObject> object) {
return IsSelfForwarded(object, GetPtrComprCageBase(object));
}
bool HeapLayout::IsSelfForwarded(Tagged<HeapObject> object,
PtrComprCageBase cage_base) {
return IsSelfForwarded(object, object->map_word(cage_base, kRelaxedLoad));
}
bool HeapLayout::IsSelfForwarded(Tagged<HeapObject> object, MapWord map_word) {
return map_word == MapWord::FromForwardingAddress(object, object);
}
bool HeapLayout::IsForwardedPointerTo(Tagged<HeapObject> src,
Tagged<HeapObject> dest) {
return src->map_word(kRelaxedLoad).ToForwardingAddress(src) == dest;
}
}