OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IMPL_H_ | 5 #ifndef VM_HANDLES_IMPL_H_ |
6 #define VM_HANDLES_IMPL_H_ | 6 #define VM_HANDLES_IMPL_H_ |
7 | 7 |
8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
9 #include "vm/heap_trace.h" | |
10 #include "vm/visitor.h" | 9 #include "vm/visitor.h" |
11 | 10 |
12 namespace dart { | 11 namespace dart { |
13 | 12 |
14 DECLARE_DEBUG_FLAG(bool, trace_handles); | 13 DECLARE_DEBUG_FLAG(bool, trace_handles); |
15 | 14 |
16 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 15 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
17 void Handles<kHandleSizeInWords, | 16 void Handles<kHandleSizeInWords, |
18 kHandlesPerChunk, | 17 kHandlesPerChunk, |
19 kOffsetOfRawPtr>::VisitObjectPointers( | 18 kOffsetOfRawPtr>::VisitObjectPointers( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 108 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
110 uword Handles<kHandleSizeInWords, | 109 uword Handles<kHandleSizeInWords, |
111 kHandlesPerChunk, | 110 kHandlesPerChunk, |
112 kOffsetOfRawPtr>::AllocateZoneHandle(Isolate* isolate) { | 111 kOffsetOfRawPtr>::AllocateZoneHandle(Isolate* isolate) { |
113 ASSERT(isolate != NULL); | 112 ASSERT(isolate != NULL); |
114 ASSERT(isolate->current_zone() != NULL); | 113 ASSERT(isolate->current_zone() != NULL); |
115 ASSERT(isolate->no_handle_scope_depth() == 0); | 114 ASSERT(isolate->no_handle_scope_depth() == 0); |
116 Handles* handles = isolate->current_zone()->handles(); | 115 Handles* handles = isolate->current_zone()->handles(); |
117 ASSERT(handles != NULL); | 116 ASSERT(handles != NULL); |
118 uword address = handles->AllocateHandleInZone(); | 117 uword address = handles->AllocateHandleInZone(); |
119 if (HeapTrace::is_enabled()) { | |
120 uword zone_addr = reinterpret_cast<uword>(isolate->current_zone()); | |
121 isolate->heap()->trace()->TraceAllocateZoneHandle(address, zone_addr); | |
122 } | |
123 return address; | 118 return address; |
124 } | 119 } |
125 | 120 |
126 | 121 |
127 // Figure out the current zone using the current Isolate and | 122 // Figure out the current zone using the current Isolate and |
128 // check if the specified handle has been allocated in this zone. | 123 // check if the specified handle has been allocated in this zone. |
129 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 124 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
130 bool Handles<kHandleSizeInWords, | 125 bool Handles<kHandleSizeInWords, |
131 kHandlesPerChunk, | 126 kHandlesPerChunk, |
132 kOffsetOfRawPtr>::IsZoneHandle(uword handle) { | 127 kOffsetOfRawPtr>::IsZoneHandle(uword handle) { |
(...skipping 13 matching lines...) Expand all Loading... |
146 kHandlesPerChunk, | 141 kHandlesPerChunk, |
147 kOffsetOfRawPtr>::DeleteAll() { | 142 kOffsetOfRawPtr>::DeleteAll() { |
148 // Delete all the zone allocated handle blocks. | 143 // Delete all the zone allocated handle blocks. |
149 // GCTrace does not need to trace this call to DeleteHandleBlocks, | 144 // GCTrace does not need to trace this call to DeleteHandleBlocks, |
150 // since the individual zone deletions will be caught | 145 // since the individual zone deletions will be caught |
151 // by instrumentation in the BaseZone destructor. | 146 // by instrumentation in the BaseZone destructor. |
152 DeleteHandleBlocks(zone_blocks_); | 147 DeleteHandleBlocks(zone_blocks_); |
153 zone_blocks_ = NULL; | 148 zone_blocks_ = NULL; |
154 | 149 |
155 // Delete all the scoped handle blocks. | 150 // Delete all the scoped handle blocks. |
156 // Do not trace if there is no current isolate. This can happen during | |
157 // isolate shutdown. | |
158 if (HeapTrace::is_enabled() && Isolate::Current() != NULL) { | |
159 Isolate::Current()->heap()->trace()->TraceDeleteScopedHandles(); | |
160 } | |
161 | |
162 | |
163 scoped_blocks_ = first_scoped_block_.next_block(); | 151 scoped_blocks_ = first_scoped_block_.next_block(); |
164 DeleteHandleBlocks(scoped_blocks_); | 152 DeleteHandleBlocks(scoped_blocks_); |
165 first_scoped_block_.ReInit(); | 153 first_scoped_block_.ReInit(); |
166 scoped_blocks_ = &first_scoped_block_; | 154 scoped_blocks_ = &first_scoped_block_; |
167 } | 155 } |
168 | 156 |
169 | 157 |
170 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 158 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
171 void Handles<kHandleSizeInWords, | 159 void Handles<kHandleSizeInWords, |
172 kHandlesPerChunk, | 160 kHandlesPerChunk, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 383 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
396 int Handles<kHandleSizeInWords, | 384 int Handles<kHandleSizeInWords, |
397 kHandlesPerChunk, | 385 kHandlesPerChunk, |
398 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 386 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
399 return (next_handle_slot_ / kHandleSizeInWords); | 387 return (next_handle_slot_ / kHandleSizeInWords); |
400 } | 388 } |
401 | 389 |
402 } // namespace dart | 390 } // namespace dart |
403 | 391 |
404 #endif // VM_HANDLES_IMPL_H_ | 392 #endif // VM_HANDLES_IMPL_H_ |
OLD | NEW |