| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 class Thread; |
| 62 | 62 |
| 63 DECLARE_FLAG(bool, verify_handles); | 63 DECLARE_FLAG(bool, verify_handles); |
| 64 DECLARE_DEBUG_FLAG(bool, trace_handles); | |
| 65 | 64 |
| 66 class HandleVisitor { | 65 class HandleVisitor { |
| 67 public: | 66 public: |
| 68 explicit HandleVisitor(Thread* thread) : thread_(thread) {} | 67 explicit HandleVisitor(Thread* thread) : thread_(thread) {} |
| 69 virtual ~HandleVisitor() {} | 68 virtual ~HandleVisitor() {} |
| 70 | 69 |
| 71 Thread* thread() const { return thread_; } | 70 Thread* thread() const { return thread_; } |
| 72 | 71 |
| 73 virtual void VisitHandle(uword addr) = 0; | 72 virtual void VisitHandle(uword addr) = 0; |
| 74 | 73 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 static const int kOffsetOfRawPtr = kWordSize; | 249 static const int kOffsetOfRawPtr = kWordSize; |
| 251 class VMHandles : public Handles<kVMHandleSizeInWords, | 250 class VMHandles : public Handles<kVMHandleSizeInWords, |
| 252 kVMHandlesPerChunk, | 251 kVMHandlesPerChunk, |
| 253 kOffsetOfRawPtr> { | 252 kOffsetOfRawPtr> { |
| 254 public: | 253 public: |
| 255 static const int kOffsetOfRawPtrInHandle = kOffsetOfRawPtr; | 254 static const int kOffsetOfRawPtrInHandle = kOffsetOfRawPtr; |
| 256 | 255 |
| 257 VMHandles() : Handles<kVMHandleSizeInWords, | 256 VMHandles() : Handles<kVMHandleSizeInWords, |
| 258 kVMHandlesPerChunk, | 257 kVMHandlesPerChunk, |
| 259 kOffsetOfRawPtr>() { | 258 kOffsetOfRawPtr>() { |
| 260 #ifdef DEBUG | |
| 261 if (FLAG_trace_handles) { | 259 if (FLAG_trace_handles) { |
| 262 OS::PrintErr("*** Starting a new VM handle block 0x%" Px "\n", | 260 OS::PrintErr("*** Starting a new VM handle block 0x%" Px "\n", |
| 263 reinterpret_cast<intptr_t>(this)); | 261 reinterpret_cast<intptr_t>(this)); |
| 264 } | 262 } |
| 265 #endif | |
| 266 } | 263 } |
| 267 ~VMHandles(); | 264 ~VMHandles(); |
| 268 | 265 |
| 269 // Visit all object pointers stored in the various handles. | 266 // Visit all object pointers stored in the various handles. |
| 270 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 267 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 271 | 268 |
| 272 // Allocates a handle in the current handle scope of 'zone', which must be | 269 // Allocates a handle in the current handle scope of 'zone', which must be |
| 273 // the current zone. This handle is valid only in the current handle scope | 270 // the current zone. This handle is valid only in the current handle scope |
| 274 // and is destroyed when the current handle scope ends. | 271 // and is destroyed when the current handle scope ends. |
| 275 static uword AllocateHandle(Zone* zone); | 272 static uword AllocateHandle(Zone* zone); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 }; | 350 }; |
| 354 #endif // defined(DEBUG) | 351 #endif // defined(DEBUG) |
| 355 | 352 |
| 356 // Macro to start a no handles scope in the code. | 353 // Macro to start a no handles scope in the code. |
| 357 #define NOHANDLESCOPE(thread) \ | 354 #define NOHANDLESCOPE(thread) \ |
| 358 dart::NoHandleScope no_vm_internal_handles_scope_(thread); | 355 dart::NoHandleScope no_vm_internal_handles_scope_(thread); |
| 359 | 356 |
| 360 } // namespace dart | 357 } // namespace dart |
| 361 | 358 |
| 362 #endif // VM_HANDLES_H_ | 359 #endif // VM_HANDLES_H_ |
| OLD | NEW |