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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // add code that will allocate new handles during this critical area. | 51 // add code that will allocate new handles during this critical area. |
52 // { | 52 // { |
53 // NOHANDLESCOPE(isolate); | 53 // NOHANDLESCOPE(isolate); |
54 // .... | 54 // .... |
55 // .... | 55 // .... |
56 // } | 56 // } |
57 | 57 |
58 | 58 |
59 // Forward declarations. | 59 // Forward declarations. |
60 class ObjectPointerVisitor; | 60 class ObjectPointerVisitor; |
| 61 class Thread; |
61 | 62 |
62 DECLARE_FLAG(bool, verify_handles); | 63 DECLARE_FLAG(bool, verify_handles); |
63 DECLARE_DEBUG_FLAG(bool, trace_handles); | 64 DECLARE_DEBUG_FLAG(bool, trace_handles); |
64 | 65 |
65 class HandleVisitor { | 66 class HandleVisitor { |
66 public: | 67 public: |
67 explicit HandleVisitor(Isolate* isolate) : isolate_(isolate) {} | 68 explicit HandleVisitor(Thread* thread) : thread_(thread) {} |
68 virtual ~HandleVisitor() {} | 69 virtual ~HandleVisitor() {} |
69 | 70 |
70 Isolate* isolate() const { return isolate_; } | 71 Thread* thread() const { return thread_; } |
71 | 72 |
72 virtual void VisitHandle(uword addr) = 0; | 73 virtual void VisitHandle(uword addr) = 0; |
73 | 74 |
74 private: | 75 private: |
75 Isolate* isolate_; | 76 Thread* thread_; |
76 | 77 |
77 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleVisitor); | 78 DISALLOW_IMPLICIT_CONSTRUCTORS(HandleVisitor); |
78 }; | 79 }; |
79 | 80 |
80 | 81 |
81 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 82 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
82 class Handles { | 83 class Handles { |
83 public: | 84 public: |
84 Handles() | 85 Handles() |
85 : zone_blocks_(NULL), | 86 : zone_blocks_(NULL), |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void ZapFreeScopedHandles(); | 232 void ZapFreeScopedHandles(); |
232 #endif | 233 #endif |
233 | 234 |
234 HandlesBlock* zone_blocks_; // List of zone handles. | 235 HandlesBlock* zone_blocks_; // List of zone handles. |
235 HandlesBlock first_scoped_block_; // First block of scoped handles. | 236 HandlesBlock first_scoped_block_; // First block of scoped handles. |
236 HandlesBlock* scoped_blocks_; // List of scoped handles. | 237 HandlesBlock* scoped_blocks_; // List of scoped handles. |
237 | 238 |
238 friend class HandleScope; | 239 friend class HandleScope; |
239 friend class Dart; | 240 friend class Dart; |
240 friend class ObjectStore; | 241 friend class ObjectStore; |
241 friend class Isolate; | 242 friend class Thread; |
242 DISALLOW_ALLOCATION(); | 243 DISALLOW_ALLOCATION(); |
243 DISALLOW_COPY_AND_ASSIGN(Handles); | 244 DISALLOW_COPY_AND_ASSIGN(Handles); |
244 }; | 245 }; |
245 | 246 |
246 | 247 |
247 static const int kVMHandleSizeInWords = 2; | 248 static const int kVMHandleSizeInWords = 2; |
248 static const int kVMHandlesPerChunk = 64; | 249 static const int kVMHandlesPerChunk = 64; |
249 static const int kOffsetOfRawPtr = kWordSize; | 250 static const int kOffsetOfRawPtr = kWordSize; |
250 class VMHandles : public Handles<kVMHandleSizeInWords, | 251 class VMHandles : public Handles<kVMHandleSizeInWords, |
251 kVMHandlesPerChunk, | 252 kVMHandlesPerChunk, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 }; | 354 }; |
354 #endif // defined(DEBUG) | 355 #endif // defined(DEBUG) |
355 | 356 |
356 // Macro to start a no handles scope in the code. | 357 // Macro to start a no handles scope in the code. |
357 #define NOHANDLESCOPE(isolate_or_thread) \ | 358 #define NOHANDLESCOPE(isolate_or_thread) \ |
358 dart::NoHandleScope no_vm_internal_handles_scope_(isolate_or_thread); | 359 dart::NoHandleScope no_vm_internal_handles_scope_(isolate_or_thread); |
359 | 360 |
360 } // namespace dart | 361 } // namespace dart |
361 | 362 |
362 #endif // VM_HANDLES_H_ | 363 #endif // VM_HANDLES_H_ |
OLD | NEW |