| 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/visitor.h" | 9 #include "vm/visitor.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 block = block->next_block(); | 43 block = block->next_block(); |
| 44 } while (block != NULL); | 44 } while (block != NULL); |
| 45 UNREACHABLE(); | 45 UNREACHABLE(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 49 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 50 void Handles<kHandleSizeInWords, | 50 void Handles<kHandleSizeInWords, |
| 51 kHandlesPerChunk, | 51 kHandlesPerChunk, |
| 52 kOffsetOfRawPtr>::Visit(HandleVisitor* visitor, | 52 kOffsetOfRawPtr>::Visit(HandleVisitor* visitor) { |
| 53 bool is_prologue_weak) { | |
| 54 // Visit all zone handles. | 53 // Visit all zone handles. |
| 55 HandlesBlock* block = zone_blocks_; | 54 HandlesBlock* block = zone_blocks_; |
| 56 while (block != NULL) { | 55 while (block != NULL) { |
| 57 block->Visit(visitor, is_prologue_weak); | 56 block->Visit(visitor); |
| 58 block = block->next_block(); | 57 block = block->next_block(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 // Visit all scoped handles. | 60 // Visit all scoped handles. |
| 62 block = &first_scoped_block_; | 61 block = &first_scoped_block_; |
| 63 do { | 62 do { |
| 64 block->Visit(visitor, is_prologue_weak); | 63 block->Visit(visitor); |
| 65 block = block->next_block(); | 64 block = block->next_block(); |
| 66 } while (block != NULL); | 65 } while (block != NULL); |
| 67 } | 66 } |
| 68 | 67 |
| 69 | 68 |
| 70 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 69 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 71 void Handles<kHandleSizeInWords, | 70 void Handles<kHandleSizeInWords, |
| 72 kHandlesPerChunk, | 71 kHandlesPerChunk, |
| 73 kOffsetOfRawPtr>::Reset() { | 72 kOffsetOfRawPtr>::Reset() { |
| 74 // Delete all the extra zone handle blocks allocated and reinit the first | 73 // Delete all the extra zone handle blocks allocated and reinit the first |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { | 334 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { |
| 336 visitor->VisitPointer( | 335 visitor->VisitPointer( |
| 337 reinterpret_cast<RawObject**>(&data_[i + kOffsetOfRawPtr/kWordSize])); | 336 reinterpret_cast<RawObject**>(&data_[i + kOffsetOfRawPtr/kWordSize])); |
| 338 } | 337 } |
| 339 } | 338 } |
| 340 | 339 |
| 341 | 340 |
| 342 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 341 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 343 void Handles<kHandleSizeInWords, | 342 void Handles<kHandleSizeInWords, |
| 344 kHandlesPerChunk, | 343 kHandlesPerChunk, |
| 345 kOffsetOfRawPtr>::HandlesBlock::Visit(HandleVisitor* visitor, | 344 kOffsetOfRawPtr>::HandlesBlock::Visit(HandleVisitor* visitor) { |
| 346 bool is_prologue_weak) { | |
| 347 ASSERT(visitor != NULL); | 345 ASSERT(visitor != NULL); |
| 348 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { | 346 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { |
| 349 visitor->VisitHandle(reinterpret_cast<uword>(&data_[i]), is_prologue_weak); | 347 visitor->VisitHandle(reinterpret_cast<uword>(&data_[i])); |
| 350 } | 348 } |
| 351 } | 349 } |
| 352 | 350 |
| 353 | 351 |
| 354 #if defined(DEBUG) | 352 #if defined(DEBUG) |
| 355 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 353 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 356 void Handles<kHandleSizeInWords, | 354 void Handles<kHandleSizeInWords, |
| 357 kHandlesPerChunk, | 355 kHandlesPerChunk, |
| 358 kOffsetOfRawPtr>::HandlesBlock::ZapFreeHandles() { | 356 kOffsetOfRawPtr>::HandlesBlock::ZapFreeHandles() { |
| 359 // Reinitialize the handle area to some uninitialized value. | 357 // Reinitialize the handle area to some uninitialized value. |
| 360 for (intptr_t i = next_handle_slot_; | 358 for (intptr_t i = next_handle_slot_; |
| 361 i < (kHandleSizeInWords * kHandlesPerChunk); | 359 i < (kHandleSizeInWords * kHandlesPerChunk); |
| 362 i++) { | 360 i++) { |
| 363 data_[i] = kZapUninitializedWord; | 361 data_[i] = kZapUninitializedWord; |
| 364 } | 362 } |
| 365 } | 363 } |
| 366 #endif | 364 #endif |
| 367 | 365 |
| 368 | 366 |
| 369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 367 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
| 370 int Handles<kHandleSizeInWords, | 368 int Handles<kHandleSizeInWords, |
| 371 kHandlesPerChunk, | 369 kHandlesPerChunk, |
| 372 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 370 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
| 373 return (next_handle_slot_ / kHandleSizeInWords); | 371 return (next_handle_slot_ / kHandleSizeInWords); |
| 374 } | 372 } |
| 375 | 373 |
| 376 } // namespace dart | 374 } // namespace dart |
| 377 | 375 |
| 378 #endif // VM_HANDLES_IMPL_H_ | 376 #endif // VM_HANDLES_IMPL_H_ |
| OLD | NEW |