OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_HANDLES_H_ | 5 #ifndef VM_HANDLES_H_ |
6 #define VM_HANDLES_H_ | 6 #define VM_HANDLES_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DECLARE_FLAG(bool, verify_handles); | 62 DECLARE_FLAG(bool, verify_handles); |
63 DECLARE_DEBUG_FLAG(bool, trace_handles); | 63 DECLARE_DEBUG_FLAG(bool, trace_handles); |
64 | 64 |
65 class HandleVisitor { | 65 class HandleVisitor { |
66 public: | 66 public: |
67 explicit HandleVisitor(Isolate* isolate) : isolate_(isolate) {} | 67 explicit HandleVisitor(Isolate* isolate) : isolate_(isolate) {} |
68 virtual ~HandleVisitor() {} | 68 virtual ~HandleVisitor() {} |
69 | 69 |
70 Isolate* isolate() const { return isolate_; } | 70 Isolate* isolate() const { return isolate_; } |
71 | 71 |
72 virtual void VisitHandle(uword addr, bool is_prologue_weak) = 0; | 72 virtual void VisitHandle(uword addr) = 0; |
73 | 73 |
74 private: | 74 private: |
75 Isolate* isolate_; | 75 Isolate* isolate_; |
76 | 76 |
77 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleVisitor); | 77 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleVisitor); |
78 }; | 78 }; |
79 | 79 |
80 | 80 |
81 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 81 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
82 class Handles { | 82 class Handles { |
(...skipping 14 matching lines...) Expand all Loading... |
97 void VisitScopedHandles(ObjectPointerVisitor* visitor); | 97 void VisitScopedHandles(ObjectPointerVisitor* visitor); |
98 | 98 |
99 // Visit all blocks that have been added since the last time | 99 // Visit all blocks that have been added since the last time |
100 // this method was called. | 100 // this method was called. |
101 // Be careful with this, since multiple users of this method could | 101 // Be careful with this, since multiple users of this method could |
102 // interfere with eachother. | 102 // interfere with eachother. |
103 // Currently only used by GC trace facility. | 103 // Currently only used by GC trace facility. |
104 void VisitUnvisitedScopedHandles(ObjectPointerVisitor* visitor); | 104 void VisitUnvisitedScopedHandles(ObjectPointerVisitor* visitor); |
105 | 105 |
106 // Visit all of the various handles. | 106 // Visit all of the various handles. |
107 void Visit(HandleVisitor* visitor, bool is_prologue_weak); | 107 void Visit(HandleVisitor* visitor); |
108 | 108 |
109 // Reset the handles so that we can reuse. | 109 // Reset the handles so that we can reuse. |
110 void Reset(); | 110 void Reset(); |
111 | 111 |
112 // Allocates a handle in the current handle scope. This handle is valid only | 112 // Allocates a handle in the current handle scope. This handle is valid only |
113 // in the current handle scope and is destroyed when the current handle | 113 // in the current handle scope and is destroyed when the current handle |
114 // scope ends. | 114 // scope ends. |
115 static uword AllocateHandle(Isolate* isolate); | 115 static uword AllocateHandle(Isolate* isolate); |
116 | 116 |
117 // Allocates a handle in the current zone. This handle will be destroyed | 117 // Allocates a handle in the current zone. This handle will be destroyed |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ASSERT(!IsFull()); | 172 ASSERT(!IsFull()); |
173 uword handle_address = reinterpret_cast<uword>(data_ + next_handle_slot_); | 173 uword handle_address = reinterpret_cast<uword>(data_ + next_handle_slot_); |
174 next_handle_slot_ += kHandleSizeInWords; | 174 next_handle_slot_ += kHandleSizeInWords; |
175 return handle_address; | 175 return handle_address; |
176 } | 176 } |
177 | 177 |
178 // Visit all object pointers in the handle block. | 178 // Visit all object pointers in the handle block. |
179 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 179 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
180 | 180 |
181 // Visit all of the handles in the handle block. | 181 // Visit all of the handles in the handle block. |
182 void Visit(HandleVisitor* visitor, bool is_prologue_weak); | 182 void Visit(HandleVisitor* visitor); |
183 | 183 |
184 #if defined(DEBUG) | 184 #if defined(DEBUG) |
185 // Zaps the free handle area to an uninitialized value. | 185 // Zaps the free handle area to an uninitialized value. |
186 void ZapFreeHandles(); | 186 void ZapFreeHandles(); |
187 #endif | 187 #endif |
188 | 188 |
189 // Returns number of active handles in the handle block. | 189 // Returns number of active handles in the handle block. |
190 int HandleCount() const; | 190 int HandleCount() const; |
191 | 191 |
192 // Accessors. | 192 // Accessors. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 }; | 348 }; |
349 #endif // defined(DEBUG) | 349 #endif // defined(DEBUG) |
350 | 350 |
351 // Macro to start a no handles scope in the code. | 351 // Macro to start a no handles scope in the code. |
352 #define NOHANDLESCOPE(isolate) \ | 352 #define NOHANDLESCOPE(isolate) \ |
353 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); | 353 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); |
354 | 354 |
355 } // namespace dart | 355 } // namespace dart |
356 | 356 |
357 #endif // VM_HANDLES_H_ | 357 #endif // VM_HANDLES_H_ |
OLD | NEW |