| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #include "vm/gc_marker.h" | 5 #include "vm/gc_marker.h" |
| 6 | 6 |
| 7 #include "vm/allocation.h" | 7 #include "vm/allocation.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/pages.h" | 10 #include "vm/pages.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 void GCMarker::IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor) { | 234 void GCMarker::IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor) { |
| 235 isolate->VisitWeakPersistentHandles(visitor); | 235 isolate->VisitWeakPersistentHandles(visitor); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 void GCMarker::IterateWeakReferences(Isolate* isolate, | 239 void GCMarker::IterateWeakReferences(Isolate* isolate, |
| 240 MarkingVisitor* visitor) { | 240 MarkingVisitor* visitor) { |
| 241 ApiState* state = isolate->api_state(); | 241 ApiState* state = isolate->api_state(); |
| 242 ASSERT(state != NULL); | 242 ASSERT(state != NULL); |
| 243 for (;;) { | 243 while (true) { |
| 244 WeakReference* queue = state->delayed_weak_references(); | 244 WeakReference* queue = state->delayed_weak_references(); |
| 245 if (queue == NULL) { | 245 if (queue == NULL) { |
| 246 break; | 246 // The delay queue is empty therefore no clean-up is required. |
| 247 return; |
| 247 } | 248 } |
| 248 state->set_delayed_weak_references(NULL); | 249 state->set_delayed_weak_references(NULL); |
| 249 while (queue != NULL) { | 250 while (queue != NULL) { |
| 250 WeakReference* reference = WeakReference::Pop(&queue); | 251 WeakReference* reference = WeakReference::Pop(&queue); |
| 251 ASSERT(reference != NULL); | 252 ASSERT(reference != NULL); |
| 252 bool is_unreachable = true; | 253 bool is_unreachable = true; |
| 253 // Test each key object for reachability. If a key object is | 254 // Test each key object for reachability. If a key object is |
| 254 // reachable, all value objects should be marked. | 255 // reachable, all value objects should be marked. |
| 255 for (intptr_t k = 0; k < reference->num_keys(); ++k) { | 256 for (intptr_t k = 0; k < reference->num_keys(); ++k) { |
| 256 if (!IsUnreachable(*reference->get_key(k))) { | 257 if (!IsUnreachable(*reference->get_key(k))) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 Prologue(isolate); | 302 Prologue(isolate); |
| 302 MarkingVisitor mark(heap_, page_space, &marking_stack); | 303 MarkingVisitor mark(heap_, page_space, &marking_stack); |
| 303 IterateRoots(isolate, &mark); | 304 IterateRoots(isolate, &mark); |
| 304 DrainMarkingStack(isolate, &mark); | 305 DrainMarkingStack(isolate, &mark); |
| 305 IterateWeakReferences(isolate, &mark); | 306 IterateWeakReferences(isolate, &mark); |
| 306 MarkingWeakVisitor mark_weak; | 307 MarkingWeakVisitor mark_weak; |
| 307 IterateWeakRoots(isolate, &mark_weak); | 308 IterateWeakRoots(isolate, &mark_weak); |
| 308 } | 309 } |
| 309 | 310 |
| 310 } // namespace dart | 311 } // namespace dart |
| OLD | NEW |