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