blob: a9785fb284f7c94d45e5eba2a1a13f1f260d31b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2020 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.
#include "src/heap/conservative-stack-visitor.h"
#include "src/execution/isolate-inl.h"
#include "src/heap/mark-compact.h"
#include "src/objects/visitors.h"
#ifdef V8_COMPRESS_POINTERS
#include "src/common/ptr-compr-inl.h"
#endif // V8_COMPRESS_POINTERS
namespace v8 {
namespace internal {
ConservativeStackVisitor::ConservativeStackVisitor(Isolate* isolate,
RootVisitor* delegate)
: isolate_(isolate), delegate_(delegate) {}
void ConservativeStackVisitor::VisitPointer(const void* pointer) {
auto address = reinterpret_cast<Address>(const_cast<void*>(pointer));
VisitConservativelyIfPointer(address);
#ifdef V8_COMPRESS_POINTERS
V8HeapCompressionScheme::ProcessIntermediatePointers(
isolate_, address,
[this](Address ptr) { VisitConservativelyIfPointer(ptr); });
#endif // V8_COMPRESS_POINTERS
}
void ConservativeStackVisitor::VisitConservativelyIfPointer(Address address) {
Address base_ptr;
#ifdef V8_ENABLE_INNER_POINTER_RESOLUTION_MB
base_ptr = isolate_->heap()->mark_compact_collector()->FindBasePtrForMarking(
address);
#else
#error "Some inner pointer resolution mechanism is needed"
#endif // V8_ENABLE_INNER_POINTER_RESOLUTION_MB
if (base_ptr == kNullAddress) return;
HeapObject obj = HeapObject::FromAddress(base_ptr);
Object root = obj;
delegate_->VisitRootPointer(Root::kHandleScope, nullptr,
FullObjectSlot(&root));
// Check that the delegate visitor did not modify the root slot.
DCHECK_EQ(root, obj);
}
} // namespace internal
} // namespace v8
|