summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/evacuation-verifier-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/evacuation-verifier-inl.h')
-rw-r--r--deps/v8/src/heap/evacuation-verifier-inl.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/deps/v8/src/heap/evacuation-verifier-inl.h b/deps/v8/src/heap/evacuation-verifier-inl.h
new file mode 100644
index 0000000000..cf1eee1351
--- /dev/null
+++ b/deps/v8/src/heap/evacuation-verifier-inl.h
@@ -0,0 +1,64 @@
+// Copyright 2022 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_HEAP_EVACUATION_VERIFIER_INL_H_
+#define V8_HEAP_EVACUATION_VERIFIER_INL_H_
+
+#include "src/heap/evacuation-verifier.h"
+#include "src/heap/heap-inl.h"
+#include "src/heap/mark-compact.h"
+
+namespace v8 {
+namespace internal {
+
+#ifdef VERIFY_HEAP
+
+void FullEvacuationVerifier::VerifyHeapObjectImpl(HeapObject heap_object) {
+ if (!ShouldVerifyObject(heap_object)) return;
+ CHECK_IMPLIES(Heap::InYoungGeneration(heap_object),
+ Heap::InToPage(heap_object));
+ CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(heap_object));
+}
+
+bool FullEvacuationVerifier::ShouldVerifyObject(HeapObject heap_object) {
+ const bool in_shared_heap = heap_object.InSharedWritableHeap();
+ return heap_->isolate()->is_shared_heap_isolate() ? in_shared_heap
+ : !in_shared_heap;
+}
+
+template <typename TSlot>
+void FullEvacuationVerifier::VerifyPointersImpl(TSlot start, TSlot end) {
+ for (TSlot current = start; current < end; ++current) {
+ typename TSlot::TObject object = current.load(cage_base());
+ HeapObject heap_object;
+ if (object.GetHeapObjectIfStrong(&heap_object)) {
+ VerifyHeapObjectImpl(heap_object);
+ }
+ }
+}
+
+void YoungGenerationEvacuationVerifier::VerifyHeapObjectImpl(
+ HeapObject heap_object) {
+ CHECK_IMPLIES(Heap::InYoungGeneration(heap_object),
+ Heap::InToPage(heap_object));
+}
+
+template <typename TSlot>
+void YoungGenerationEvacuationVerifier::VerifyPointersImpl(TSlot start,
+ TSlot end) {
+ for (TSlot current = start; current < end; ++current) {
+ typename TSlot::TObject object = current.load(cage_base());
+ HeapObject heap_object;
+ if (object.GetHeapObject(&heap_object)) {
+ VerifyHeapObjectImpl(heap_object);
+ }
+ }
+}
+
+#endif // VERIFY_HEAP
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_HEAP_EVACUATION_VERIFIER_INL_H_