| 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" | 9 #include "vm/heap_trace.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_count); | 14 DECLARE_DEBUG_FLAG(bool, trace_handles); |
| 15 | 15 |
| 16 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 16 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 17 void Handles<kHandleSizeInWords, | 17 void Handles<kHandleSizeInWords, |
| 18 kHandlesPerChunk, | 18 kHandlesPerChunk, |
| 19 kOffsetOfRawPtr>::VisitObjectPointers( | 19 kOffsetOfRawPtr>::VisitObjectPointers( |
| 20 ObjectPointerVisitor* visitor) { | 20 ObjectPointerVisitor* visitor) { |
| 21 // Visit all zone handles. | 21 // Visit all zone handles. |
| 22 HandlesBlock* block = zone_blocks_; | 22 HandlesBlock* block = zone_blocks_; |
| 23 while (block != NULL) { | 23 while (block != NULL) { |
| 24 block->VisitObjectPointers(visitor); | 24 block->VisitObjectPointers(visitor); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 delete block; | 178 delete block; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 183 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 184 void Handles<kHandleSizeInWords, | 184 void Handles<kHandleSizeInWords, |
| 185 kHandlesPerChunk, | 185 kHandlesPerChunk, |
| 186 kOffsetOfRawPtr>::SetupNextScopeBlock() { | 186 kOffsetOfRawPtr>::SetupNextScopeBlock() { |
| 187 #if defined(DEBUG) | 187 #if defined(DEBUG) |
| 188 if (FLAG_trace_handles_count) { | 188 if (FLAG_trace_handles) { |
| 189 OS::Print("Handle Counts: Zone = %d, Scoped = %d\n", | 189 OS::PrintErr("*** Handle Counts for (0x%"Px"):Zone = %d,Scoped = %d\n", |
| 190 CountZoneHandles(), CountScopedHandles()); | 190 reinterpret_cast<intptr_t>(this), |
| 191 CountZoneHandles(), CountScopedHandles()); |
| 191 } | 192 } |
| 192 #endif | 193 #endif |
| 193 if (scoped_blocks_->next_block() == NULL) { | 194 if (scoped_blocks_->next_block() == NULL) { |
| 194 scoped_blocks_->set_next_block(new HandlesBlock(NULL)); | 195 scoped_blocks_->set_next_block(new HandlesBlock(NULL)); |
| 195 } | 196 } |
| 196 scoped_blocks_ = scoped_blocks_->next_block(); | 197 scoped_blocks_ = scoped_blocks_->next_block(); |
| 197 scoped_blocks_->set_next_handle_slot(0); | 198 scoped_blocks_->set_next_handle_slot(0); |
| 198 #if defined(DEBUG) | 199 #if defined(DEBUG) |
| 199 scoped_blocks_->ZapFreeHandles(); | 200 scoped_blocks_->ZapFreeHandles(); |
| 200 #endif | 201 #endif |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 233 } |
| 233 return false; | 234 return false; |
| 234 } | 235 } |
| 235 | 236 |
| 236 | 237 |
| 237 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 238 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 238 void Handles<kHandleSizeInWords, | 239 void Handles<kHandleSizeInWords, |
| 239 kHandlesPerChunk, | 240 kHandlesPerChunk, |
| 240 kOffsetOfRawPtr>::SetupNextZoneBlock() { | 241 kOffsetOfRawPtr>::SetupNextZoneBlock() { |
| 241 #if defined(DEBUG) | 242 #if defined(DEBUG) |
| 242 if (FLAG_trace_handles_count) { | 243 if (FLAG_trace_handles) { |
| 243 OS::Print("Handle Counts: Zone = %d, Scoped = %d\n", | 244 OS::PrintErr("*** Handle Counts for (0x%"Px"):Zone = %d,Scoped = %d\n", |
| 244 CountZoneHandles(), CountScopedHandles()); | 245 reinterpret_cast<intptr_t>(this), |
| 246 CountZoneHandles(), CountScopedHandles()); |
| 245 } | 247 } |
| 246 #endif | 248 #endif |
| 247 zone_blocks_ = new HandlesBlock(zone_blocks_); | 249 zone_blocks_ = new HandlesBlock(zone_blocks_); |
| 248 ASSERT(zone_blocks_ != NULL); | 250 ASSERT(zone_blocks_ != NULL); |
| 249 } | 251 } |
| 250 | 252 |
| 251 | 253 |
| 252 #if defined(DEBUG) | 254 #if defined(DEBUG) |
| 253 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 255 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 254 void Handles<kHandleSizeInWords, | 256 void Handles<kHandleSizeInWords, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 395 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 394 int Handles<kHandleSizeInWords, | 396 int Handles<kHandleSizeInWords, |
| 395 kHandlesPerChunk, | 397 kHandlesPerChunk, |
| 396 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 398 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
| 397 return (next_handle_slot_ / kHandleSizeInWords); | 399 return (next_handle_slot_ / kHandleSizeInWords); |
| 398 } | 400 } |
| 399 | 401 |
| 400 } // namespace dart | 402 } // namespace dart |
| 401 | 403 |
| 402 #endif // VM_HANDLES_IMPL_H_ | 404 #endif // VM_HANDLES_IMPL_H_ |
| OLD | NEW |