| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 | 58 |
| 59 // Forward declarations. | 59 // Forward declarations. |
| 60 class ObjectPointerVisitor; | 60 class ObjectPointerVisitor; |
| 61 | 61 |
| 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 virtual void VisitHandle(uword addr) = 0; | 67 virtual void VisitHandle(uword addr, bool is_prologue_weak) = 0; |
| 68 | 68 |
| 69 virtual ~HandleVisitor() { | 69 virtual ~HandleVisitor() { |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 | 73 |
| 74 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 74 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 75 class Handles { | 75 class Handles { |
| 76 public: | 76 public: |
| 77 Handles() | 77 Handles() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 void VisitScopedHandles(ObjectPointerVisitor* visitor); | 90 void VisitScopedHandles(ObjectPointerVisitor* visitor); |
| 91 | 91 |
| 92 // Visit all blocks that have been added since the last time | 92 // Visit all blocks that have been added since the last time |
| 93 // this method was called. | 93 // this method was called. |
| 94 // Be careful with this, since multiple users of this method could | 94 // Be careful with this, since multiple users of this method could |
| 95 // interfere with eachother. | 95 // interfere with eachother. |
| 96 // Currently only used by GC trace facility. | 96 // Currently only used by GC trace facility. |
| 97 void VisitUnvisitedScopedHandles(ObjectPointerVisitor* visitor); | 97 void VisitUnvisitedScopedHandles(ObjectPointerVisitor* visitor); |
| 98 | 98 |
| 99 // Visit all of the various handles. | 99 // Visit all of the various handles. |
| 100 void Visit(HandleVisitor* visitor); | 100 void Visit(HandleVisitor* visitor, bool is_prologue_weak); |
| 101 | 101 |
| 102 // Reset the handles so that we can reuse. | 102 // Reset the handles so that we can reuse. |
| 103 void Reset(); | 103 void Reset(); |
| 104 | 104 |
| 105 // Allocates a handle in the current handle scope. This handle is valid only | 105 // Allocates a handle in the current handle scope. This handle is valid only |
| 106 // in the current handle scope and is destroyed when the current handle | 106 // in the current handle scope and is destroyed when the current handle |
| 107 // scope ends. | 107 // scope ends. |
| 108 static uword AllocateHandle(Isolate* isolate); | 108 static uword AllocateHandle(Isolate* isolate); |
| 109 | 109 |
| 110 // Allocates a handle in the current zone. This handle will be destroyed | 110 // 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... |
| 165 ASSERT(!IsFull()); | 165 ASSERT(!IsFull()); |
| 166 uword handle_address = reinterpret_cast<uword>(data_ + next_handle_slot_); | 166 uword handle_address = reinterpret_cast<uword>(data_ + next_handle_slot_); |
| 167 next_handle_slot_ += kHandleSizeInWords; | 167 next_handle_slot_ += kHandleSizeInWords; |
| 168 return handle_address; | 168 return handle_address; |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Visit all object pointers in the handle block. | 171 // Visit all object pointers in the handle block. |
| 172 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 172 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 173 | 173 |
| 174 // Visit all of the handles in the handle block. | 174 // Visit all of the handles in the handle block. |
| 175 void Visit(HandleVisitor* visitor); | 175 void Visit(HandleVisitor* visitor, bool is_prologue_weak); |
| 176 | 176 |
| 177 #if defined(DEBUG) | 177 #if defined(DEBUG) |
| 178 // Zaps the free handle area to an uninitialized value. | 178 // Zaps the free handle area to an uninitialized value. |
| 179 void ZapFreeHandles(); | 179 void ZapFreeHandles(); |
| 180 #endif | 180 #endif |
| 181 | 181 |
| 182 // Returns number of active handles in the handle block. | 182 // Returns number of active handles in the handle block. |
| 183 int HandleCount() const; | 183 int HandleCount() const; |
| 184 | 184 |
| 185 // Accessors. | 185 // Accessors. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 }; | 341 }; |
| 342 #endif // defined(DEBUG) | 342 #endif // defined(DEBUG) |
| 343 | 343 |
| 344 // Macro to start a no handles scope in the code. | 344 // Macro to start a no handles scope in the code. |
| 345 #define NOHANDLESCOPE(isolate) \ | 345 #define NOHANDLESCOPE(isolate) \ |
| 346 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); | 346 dart::NoHandleScope no_vm_internal_handles_scope_(isolate); |
| 347 | 347 |
| 348 } // namespace dart | 348 } // namespace dart |
| 349 | 349 |
| 350 #endif // VM_HANDLES_H_ | 350 #endif // VM_HANDLES_H_ |
| OLD | NEW |