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>::VisitUnvisitedScopedHandles( | |
53 ObjectPointerVisitor* visitor) { | |
54 HandlesBlock* block = &first_scoped_block_; | |
55 while (block != NULL && block != last_visited_block_) { | |
56 block->VisitUnvisitedObjectPointers(visitor); | |
57 block = block->next_block(); | |
58 } | |
59 // We want this to point to first_scoped_block.next, | |
60 // Because pointers are still being added to first_scoped_block | |
61 // So it may be "partially new", and require a partial scan. | |
62 last_visited_block_ = first_scoped_block_.next_block(); | |
63 } | |
64 | |
65 | |
66 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | |
67 void Handles<kHandleSizeInWords, | |
68 kHandlesPerChunk, | |
69 kOffsetOfRawPtr>::Visit(HandleVisitor* visitor) { | 52 kOffsetOfRawPtr>::Visit(HandleVisitor* visitor) { |
70 // Visit all zone handles. | 53 // Visit all zone handles. |
71 HandlesBlock* block = zone_blocks_; | 54 HandlesBlock* block = zone_blocks_; |
72 while (block != NULL) { | 55 while (block != NULL) { |
73 block->Visit(visitor); | 56 block->Visit(visitor); |
74 block = block->next_block(); | 57 block = block->next_block(); |
75 } | 58 } |
76 | 59 |
77 // Visit all scoped handles. | 60 // Visit all scoped handles. |
78 block = &first_scoped_block_; | 61 block = &first_scoped_block_; |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { | 315 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { |
333 visitor->VisitPointer( | 316 visitor->VisitPointer( |
334 reinterpret_cast<RawObject**>(&data_[i + kOffsetOfRawPtr/kWordSize])); | 317 reinterpret_cast<RawObject**>(&data_[i + kOffsetOfRawPtr/kWordSize])); |
335 } | 318 } |
336 } | 319 } |
337 | 320 |
338 | 321 |
339 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 322 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
340 void Handles<kHandleSizeInWords, | 323 void Handles<kHandleSizeInWords, |
341 kHandlesPerChunk, | 324 kHandlesPerChunk, |
342 kOffsetOfRawPtr>::HandlesBlock::VisitUnvisitedObjectPointers( | |
343 ObjectPointerVisitor* visitor) { | |
344 ASSERT(visitor != NULL); | |
345 | |
346 // last_visited_handle_ picks up where we were last time, | |
347 // so there is nothing in the intialization position of this for loop. | |
348 | |
349 while (last_visited_handle_ < next_handle_slot_) { | |
350 last_visited_handle_ += kHandleSizeInWords; | |
351 uword* addr = &data_[last_visited_handle_ + kOffsetOfRawPtr / kWordSize]; | |
352 visitor->VisitPointer(reinterpret_cast<RawObject**>(addr)); | |
353 } | |
354 } | |
355 | |
356 | |
357 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | |
358 void Handles<kHandleSizeInWords, | |
359 kHandlesPerChunk, | |
360 kOffsetOfRawPtr>::HandlesBlock::Visit(HandleVisitor* visitor) { | 325 kOffsetOfRawPtr>::HandlesBlock::Visit(HandleVisitor* visitor) { |
361 ASSERT(visitor != NULL); | 326 ASSERT(visitor != NULL); |
362 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { | 327 for (intptr_t i = 0; i < next_handle_slot_; i += kHandleSizeInWords) { |
363 visitor->VisitHandle(reinterpret_cast<uword>(&data_[i])); | 328 visitor->VisitHandle(reinterpret_cast<uword>(&data_[i])); |
364 } | 329 } |
365 } | 330 } |
366 | 331 |
367 | 332 |
368 #if defined(DEBUG) | 333 #if defined(DEBUG) |
369 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 334 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
(...skipping 13 matching lines...) Expand all Loading... |
383 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> | 348 template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr> |
384 int Handles<kHandleSizeInWords, | 349 int Handles<kHandleSizeInWords, |
385 kHandlesPerChunk, | 350 kHandlesPerChunk, |
386 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { | 351 kOffsetOfRawPtr>::HandlesBlock::HandleCount() const { |
387 return (next_handle_slot_ / kHandleSizeInWords); | 352 return (next_handle_slot_ / kHandleSizeInWords); |
388 } | 353 } |
389 | 354 |
390 } // namespace dart | 355 } // namespace dart |
391 | 356 |
392 #endif // VM_HANDLES_IMPL_H_ | 357 #endif // VM_HANDLES_IMPL_H_ |
OLD | NEW |