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 <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 ASSERT(reference_set != NULL); | 367 ASSERT(reference_set != NULL); |
368 bool is_unreachable = true; | 368 bool is_unreachable = true; |
369 // Test each key object for reachability. If a key object is | 369 // Test each key object for reachability. If a key object is |
370 // reachable, all value objects should be marked. | 370 // reachable, all value objects should be marked. |
371 for (intptr_t k = 0; k < reference_set->num_keys(); ++k) { | 371 for (intptr_t k = 0; k < reference_set->num_keys(); ++k) { |
372 if (!IsUnreachable(*reference_set->get_key(k))) { | 372 if (!IsUnreachable(*reference_set->get_key(k))) { |
373 for (intptr_t v = 0; v < reference_set->num_values(); ++v) { | 373 for (intptr_t v = 0; v < reference_set->num_values(); ++v) { |
374 visitor->VisitPointer(reference_set->get_value(v)); | 374 visitor->VisitPointer(reference_set->get_value(v)); |
375 } | 375 } |
376 is_unreachable = false; | 376 is_unreachable = false; |
377 delete reference_set; | |
378 break; | 377 break; |
Ivan Posva
2014/04/17 23:47:44
Please add a comment that this break is breaking o
siva
2014/04/21 18:04:14
Done.
| |
379 } | 378 } |
380 } | 379 } |
381 // If all key objects are unreachable put the reference on a | 380 // If all key objects are unreachable put the reference on a |
382 // delay queue. This reference will be revisited if another | 381 // delay queue. This reference will be revisited if another |
383 // reference is marked. | 382 // reference is marked. |
384 if (is_unreachable) { | 383 if (is_unreachable) { |
385 state->DelayWeakReferenceSet(reference_set); | 384 state->DelayWeakReferenceSet(reference_set); |
386 } | 385 } |
387 } | 386 } |
388 if (!visitor->marking_stack()->IsEmpty()) { | 387 if (!visitor->marking_stack()->IsEmpty()) { |
389 DrainMarkingStack(isolate, visitor); | 388 DrainMarkingStack(isolate, visitor); |
390 } else { | 389 } else { |
391 // Break out of the loop if there has been no forward process. | 390 // Break out of the loop if there has been no forward process. |
392 break; | 391 break; |
393 } | 392 } |
394 } | 393 } |
395 // Deallocate any unmarked references on the delay queue. | 394 // All weak reference sets are zone allocated and unmarked references on |
396 if (state->delayed_weak_reference_sets() != NULL) { | 395 // the delay queue will be freed when the zone is released in the epilog |
397 WeakReferenceSet* queue = state->delayed_weak_reference_sets(); | 396 // callback. |
398 state->set_delayed_weak_reference_sets(NULL); | |
399 while (queue != NULL) { | |
400 delete WeakReferenceSet::Pop(&queue); | |
401 } | |
402 } | |
403 } | 397 } |
404 | 398 |
405 | 399 |
406 void GCMarker::DrainMarkingStack(Isolate* isolate, | 400 void GCMarker::DrainMarkingStack(Isolate* isolate, |
407 MarkingVisitor* visitor) { | 401 MarkingVisitor* visitor) { |
408 while (!visitor->marking_stack()->IsEmpty()) { | 402 while (!visitor->marking_stack()->IsEmpty()) { |
409 RawObject* raw_obj = visitor->marking_stack()->Pop(); | 403 RawObject* raw_obj = visitor->marking_stack()->Pop(); |
410 visitor->VisitingOldObject(raw_obj); | 404 visitor->VisitingOldObject(raw_obj); |
411 if (raw_obj->GetClassId() != kWeakPropertyCid) { | 405 if (raw_obj->GetClassId() != kWeakPropertyCid) { |
412 raw_obj->VisitPointers(visitor); | 406 raw_obj->VisitPointers(visitor); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 MarkingWeakVisitor mark_weak; | 491 MarkingWeakVisitor mark_weak; |
498 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 492 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
499 mark.Finalize(); | 493 mark.Finalize(); |
500 ProcessWeakTables(page_space); | 494 ProcessWeakTables(page_space); |
501 ProcessObjectIdTable(isolate); | 495 ProcessObjectIdTable(isolate); |
502 | 496 |
503 Epilogue(isolate, invoke_api_callbacks); | 497 Epilogue(isolate, invoke_api_callbacks); |
504 } | 498 } |
505 | 499 |
506 } // namespace dart | 500 } // namespace dart |
OLD | NEW |