Flutter Engine
The Flutter Engine
verifier.h
Go to the documentation of this file.
1// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_HEAP_VERIFIER_H_
6#define RUNTIME_VM_HEAP_VERIFIER_H_
7
8#include "vm/flags.h"
9#include "vm/globals.h"
10#include "vm/handle_visitor.h"
11#include "vm/handles.h"
12#include "vm/thread.h"
13#include "vm/visitor.h"
14
15namespace dart {
16
17// Forward declarations.
18class IsolateGroup;
19class ObjectSet;
20
22
24 public:
26 ObjectSet* allocated_set,
27 MarkExpectation mark_expectation)
28 : isolate_group_(isolate_group),
29 allocated_set_(allocated_set),
30 mark_expectation_(mark_expectation) {}
31
32 void VisitObject(ObjectPtr obj) override;
33
34 private:
35 IsolateGroup* isolate_group_;
36 ObjectSet* allocated_set_;
37 MarkExpectation mark_expectation_;
38
39 DISALLOW_COPY_AND_ASSIGN(VerifyObjectVisitor);
40};
41
42// A sample object pointer visitor implementation which verifies that
43// the pointers visited are contained in the isolate heap.
45 public:
47 ObjectSet* allocated_set,
48 const char* msg)
50 allocated_set_(allocated_set),
51 msg_(msg) {
52 ASSERT(msg_ != nullptr);
53 }
54
55 void VisitPointers(ObjectPtr* first, ObjectPtr* last) override;
56#if defined(DART_COMPRESSED_POINTERS)
57 void VisitCompressedPointers(uword heap_base,
59 CompressedObjectPtr* last) override;
60#endif
61
62 static void VerifyPointers(const char* msg,
63 MarkExpectation mark_expectation = kForbidMarked);
64
65 private:
66 ObjectSet* allocated_set_;
67 const char* msg_;
68
69 DISALLOW_COPY_AND_ASSIGN(VerifyPointersVisitor);
70};
71
73 public:
75 : HandleVisitor(Thread::Current()), visitor_(visitor) {}
76
77 void VisitHandle(uword addr) override;
78
79 private:
80 ObjectPointerVisitor* visitor_;
81
82 ObjectSet* allocated_set;
83
84 DISALLOW_COPY_AND_ASSIGN(VerifyWeakPointersVisitor);
85};
86
87#if defined(DEBUG)
88class VerifyCanonicalVisitor : public ObjectVisitor {
89 public:
90 explicit VerifyCanonicalVisitor(Thread* thread);
91 void VisitObject(ObjectPtr obj) override;
92
93 private:
94 Thread* thread_;
95 Instance& instanceHandle_;
96
97 DISALLOW_COPY_AND_ASSIGN(VerifyCanonicalVisitor);
98};
99#endif // defined(DEBUG)
100
101} // namespace dart
102
103#endif // RUNTIME_VM_HEAP_VERIFIER_H_
IsolateGroup * isolate_group() const
Definition: visitor.h:25
void VisitCompressedPointers(uword heap_base, CompressedObjectPtr *first, CompressedObjectPtr *last)
Definition: visitor.h:43
void VisitObject(ObjectPtr obj) override
Definition: verifier.cc:19
VerifyObjectVisitor(IsolateGroup *isolate_group, ObjectSet *allocated_set, MarkExpectation mark_expectation)
Definition: verifier.h:25
VerifyPointersVisitor(IsolateGroup *isolate_group, ObjectSet *allocated_set, const char *msg)
Definition: verifier.h:46
void VisitPointers(ObjectPtr *first, ObjectPtr *last) override
Definition: verifier.cc:46
static void VerifyPointers(const char *msg, MarkExpectation mark_expectation=kForbidMarked)
Definition: verifier.cc:81
VerifyWeakPointersVisitor(VerifyPointersVisitor *visitor)
Definition: verifier.h:74
void VisitHandle(uword addr) override
Definition: verifier.cc:74
#define ASSERT(E)
Definition: dart_vm.cc:33
uintptr_t uword
Definition: globals.h:501
MarkExpectation
Definition: verifier.h:21
@ kAllowMarked
Definition: verifier.h:21
@ kRequireMarked
Definition: verifier.h:21
@ kForbidMarked
Definition: verifier.h:21
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:581