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_VISITOR_H_ |
6 | #define RUNTIME_VM_VISITOR_H_ |
7 | |
8 | #include "vm/allocation.h" |
9 | #include "vm/class_table.h" |
10 | #include "vm/globals.h" |
11 | #include "vm/growable_array.h" |
12 | |
13 | namespace dart { |
14 | |
15 | // Forward declarations. |
16 | class Isolate; |
17 | class IsolateGroup; |
18 | |
19 | // An object pointer visitor interface. |
20 | class ObjectPointerVisitor { |
21 | public: |
22 | explicit ObjectPointerVisitor(IsolateGroup* isolate_group); |
23 | virtual ~ObjectPointerVisitor() {} |
24 | |
25 | IsolateGroup* isolate_group() const { return isolate_group_; } |
26 | |
27 | // Visit pointers inside the given typed data [view]. |
28 | // |
29 | // Range of pointers to visit 'first' <= pointer <= 'last'. |
30 | virtual void VisitTypedDataViewPointers(TypedDataViewPtr view, |
31 | CompressedObjectPtr* first, |
32 | CompressedObjectPtr* last) { |
33 | VisitCompressedPointers(heap_base: view->heap_base(), first, last); |
34 | } |
35 | |
36 | // Range of pointers to visit 'first' <= pointer <= 'last'. |
37 | virtual void VisitPointers(ObjectPtr* first, ObjectPtr* last) = 0; |
38 | #if defined(DART_COMPRESSED_POINTERS) |
39 | virtual void VisitCompressedPointers(uword heap_base, |
40 | CompressedObjectPtr* first, |
41 | CompressedObjectPtr* last) = 0; |
42 | #else |
43 | void VisitCompressedPointers(uword heap_base, |
44 | CompressedObjectPtr* first, |
45 | CompressedObjectPtr* last) { |
46 | VisitPointers(first, last); |
47 | } |
48 | #endif |
49 | |
50 | // len argument is the number of pointers to visit starting from 'p'. |
51 | void VisitPointers(ObjectPtr* p, intptr_t len) { |
52 | VisitPointers(first: p, last: (p + len - 1)); |
53 | } |
54 | |
55 | void VisitPointer(ObjectPtr* p) { VisitPointers(first: p, last: p); } |
56 | |
57 | const char* gc_root_type() const { return gc_root_type_; } |
58 | void set_gc_root_type(const char* gc_root_type) { |
59 | gc_root_type_ = gc_root_type; |
60 | } |
61 | |
62 | void clear_gc_root_type() { gc_root_type_ = "unknown"; } |
63 | |
64 | virtual bool visit_weak_persistent_handles() const { return false; } |
65 | |
66 | // When visiting objects to build retaining paths, trace field values |
67 | // through fields. |
68 | // Otherwise trace field values through isolate's field_table. |
69 | virtual bool trace_values_through_fields() const { return false; } |
70 | |
71 | const ClassTable* class_table() const { return class_table_; } |
72 | |
73 | // Returns true if pointers of the given SuspendState object can be visited. |
74 | // Compactor overrides this method in order to postpone visiting SuspendState |
75 | // objects with evacuated frames, as visiting them may touch other Dart |
76 | // objects (array of InstructionsTables) which have inconsistent state |
77 | // until compaction is finished. |
78 | virtual bool CanVisitSuspendStatePointers(SuspendStatePtr suspend_state) { |
79 | return true; |
80 | } |
81 | |
82 | private: |
83 | IsolateGroup* isolate_group_; |
84 | const char* gc_root_type_; |
85 | ClassTable* class_table_; |
86 | |
87 | DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectPointerVisitor); |
88 | }; |
89 | |
90 | // An object visitor interface. |
91 | class ObjectVisitor { |
92 | public: |
93 | ObjectVisitor() {} |
94 | |
95 | virtual ~ObjectVisitor() {} |
96 | |
97 | // Invoked for each object. |
98 | virtual void VisitObject(ObjectPtr obj) = 0; |
99 | |
100 | private: |
101 | DISALLOW_COPY_AND_ASSIGN(ObjectVisitor); |
102 | }; |
103 | |
104 | } // namespace dart |
105 | |
106 | #endif // RUNTIME_VM_VISITOR_H_ |
107 |
Definitions
- ObjectPointerVisitor
- ~ObjectPointerVisitor
- isolate_group
- VisitTypedDataViewPointers
- VisitCompressedPointers
- VisitPointers
- VisitPointer
- gc_root_type
- set_gc_root_type
- clear_gc_root_type
- visit_weak_persistent_handles
- trace_values_through_fields
- class_table
- CanVisitSuspendStatePointers
- ObjectPointerVisitor
- ObjectPointerVisitor
- ObjectVisitor
- ObjectVisitor
- ~ObjectVisitor
Learn more about Flutter for embedded and desktop on industrialflutter.com