#ifndef V8_OBJECTS_CASTING_INL_H_
#define V8_OBJECTS_CASTING_INL_H_
#include "src/objects/casting.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h"
#include "src/heap/heap-layout.h"
#include "src/heap/heap.h"
#include "src/objects/heap-object.h"
namespace v8::internal {
#ifdef DEBUG
template <typename T>
bool GCAwareObjectTypeCheck(Tagged<Object> object, const Heap* heap) {
Tagged<HeapObject> heap_object = UncheckedCast<HeapObject>(object);
if ((heap->gc_state() == Heap::SCAVENGE) &&
MemoryChunk::FromHeapObject(heap_object)->IsLargePage()) {
return true;
}
MapWord map_word = heap_object->map_word(
PtrComprCageBase(heap->isolate()->cage_base()), kRelaxedLoad);
if ((heap->gc_state() == Heap::SCAVENGE) &&
HeapLayout::InYoungGeneration(heap_object) &&
((heap->ConservativeStackScanningModeForMinorGC() !=
Heap::StackScanMode::kNone) ||
heap->ShouldUsePrecisePinningForMinorGC()) &&
map_word.IsForwardingAddress() &&
HeapLayout::IsSelfForwarded(heap_object, map_word)) {
return true;
}
if (heap->IsInGC() && map_word.IsForwardingAddress() &&
Is<T>(map_word.ToForwardingAddress(heap_object))) {
return true;
}
return Is<T>(object);
}
#endif
}
#endif