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/thread.h" | 9 #include "vm/thread.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DECLARE_DEBUG_FLAG(bool, trace_handles); | |
15 | |
16 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 14 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
17 void Handles<kHandleSizeInWords, | 15 void Handles<kHandleSizeInWords, |
18 kHandlesPerChunk, | 16 kHandlesPerChunk, |
19 kOffsetOfRawPtr>::VisitObjectPointers( | 17 kOffsetOfRawPtr>::VisitObjectPointers( |
20 ObjectPointerVisitor* visitor) { | 18 ObjectPointerVisitor* visitor) { |
21 // Visit all zone handles. | 19 // Visit all zone handles. |
22 HandlesBlock* block = zone_blocks_; | 20 HandlesBlock* block = zone_blocks_; |
23 while (block != NULL) { | 21 while (block != NULL) { |
24 block->VisitObjectPointers(visitor); | 22 block->VisitObjectPointers(visitor); |
25 block = block->next_block(); | 23 block = block->next_block(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 blocks = blocks->next_block(); | 167 blocks = blocks->next_block(); |
170 delete block; | 168 delete block; |
171 } | 169 } |
172 } | 170 } |
173 | 171 |
174 | 172 |
175 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 173 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
176 void Handles<kHandleSizeInWords, | 174 void Handles<kHandleSizeInWords, |
177 kHandlesPerChunk, | 175 kHandlesPerChunk, |
178 kOffsetOfRawPtr>::SetupNextScopeBlock() { | 176 kOffsetOfRawPtr>::SetupNextScopeBlock() { |
179 #if defined(DEBUG) | |
180 if (FLAG_trace_handles) { | 177 if (FLAG_trace_handles) { |
181 OS::PrintErr("*** Handle Counts for (0x%" Px "):Zone = %d,Scoped = %d\n", | 178 OS::PrintErr("*** Handle Counts for (0x%" Px "):Zone = %d,Scoped = %d\n", |
182 reinterpret_cast<intptr_t>(this), | 179 reinterpret_cast<intptr_t>(this), |
183 CountZoneHandles(), CountScopedHandles()); | 180 CountZoneHandles(), CountScopedHandles()); |
184 } | 181 } |
185 #endif | |
186 if (scoped_blocks_->next_block() == NULL) { | 182 if (scoped_blocks_->next_block() == NULL) { |
187 scoped_blocks_->set_next_block(new HandlesBlock(NULL)); | 183 scoped_blocks_->set_next_block(new HandlesBlock(NULL)); |
188 } | 184 } |
189 scoped_blocks_ = scoped_blocks_->next_block(); | 185 scoped_blocks_ = scoped_blocks_->next_block(); |
190 scoped_blocks_->set_next_handle_slot(0); | 186 scoped_blocks_->set_next_handle_slot(0); |
191 #if defined(DEBUG) | 187 #if defined(DEBUG) |
192 scoped_blocks_->ZapFreeHandles(); | 188 scoped_blocks_->ZapFreeHandles(); |
193 #endif | 189 #endif |
194 } | 190 } |
195 | 191 |
(...skipping 28 matching lines...) Expand all Loading... |
224 iterator = iterator->next_block(); | 220 iterator = iterator->next_block(); |
225 } | 221 } |
226 return false; | 222 return false; |
227 } | 223 } |
228 | 224 |
229 | 225 |
230 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 226 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
231 void Handles<kHandleSizeInWords, | 227 void Handles<kHandleSizeInWords, |
232 kHandlesPerChunk, | 228 kHandlesPerChunk, |
233 kOffsetOfRawPtr>::SetupNextZoneBlock() { | 229 kOffsetOfRawPtr>::SetupNextZoneBlock() { |
234 #if defined(DEBUG) | |
235 if (FLAG_trace_handles) { | 230 if (FLAG_trace_handles) { |
236 OS::PrintErr("*** Handle Counts for (0x%" Px "):Zone = %d,Scoped = %d\n", | 231 OS::PrintErr("*** Handle Counts for (0x%" Px "):Zone = %d,Scoped = %d\n", |
237 reinterpret_cast<intptr_t>(this), | 232 reinterpret_cast<intptr_t>(this), |
238 CountZoneHandles(), CountScopedHandles()); | 233 CountZoneHandles(), CountScopedHandles()); |
239 } | 234 } |
240 #endif | |
241 zone_blocks_ = new HandlesBlock(zone_blocks_); | 235 zone_blocks_ = new HandlesBlock(zone_blocks_); |
242 ASSERT(zone_blocks_ != NULL); | 236 ASSERT(zone_blocks_ != NULL); |
243 } | 237 } |
244 | 238 |
245 | 239 |
246 #if defined(DEBUG) | 240 #if defined(DEBUG) |
247 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 241 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
248 void Handles<kHandleSizeInWords, | 242 void Handles<kHandleSizeInWords, |
249 kHandlesPerChunk, | 243 kHandlesPerChunk, |
250 kOffsetOfRawPtr>::VerifyScopedHandleState() { | 244 kOffsetOfRawPtr>::VerifyScopedHandleState() { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 363 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
370 int Handles<kHandleSizeInWords, | 364 int Handles<kHandleSizeInWords, |
371 kHandlesPerChunk, | 365 kHandlesPerChunk, |
372 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 366 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
373 return (next_handle_slot_ / kHandleSizeInWords); | 367 return (next_handle_slot_ / kHandleSizeInWords); |
374 } | 368 } |
375 | 369 |
376 } // namespace dart | 370 } // namespace dart |
377 | 371 |
378 #endif // VM_HANDLES_IMPL_H_ | 372 #endif // VM_HANDLES_IMPL_H_ |
OLD | NEW |