| 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 | 9 |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if (!raw_key->IsMarked()) { | 371 if (!raw_key->IsMarked()) { |
| 372 // Key is white. Delay the weak property. | 372 // Key is white. Delay the weak property. |
| 373 visitor->DelayWeakProperty(raw_weak); | 373 visitor->DelayWeakProperty(raw_weak); |
| 374 } else { | 374 } else { |
| 375 // Key is gray or black. Make the weak property black. | 375 // Key is gray or black. Make the weak property black. |
| 376 raw_weak->VisitPointers(visitor); | 376 raw_weak->VisitPointers(visitor); |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 | 379 |
| 380 | 380 |
| 381 void GCMarker::ProcessPeerReferents() { |
| 382 std::map<RawObject*, void*>::iterator it = peer_->begin(); |
| 383 while (it != peer_->end()) { |
| 384 RawObject* raw_obj = it->first; |
| 385 ASSERT(raw_obj->IsHeapObject()); |
| 386 if (raw_obj->IsMarked()) { |
| 387 // The object has survived. Do nothing. |
| 388 ++it; |
| 389 } else { |
| 390 // The object has become garbage. Remove its record. |
| 391 peer_->erase(it++); |
| 392 } |
| 393 } |
| 394 } |
| 395 |
| 396 |
| 381 void GCMarker::MarkObjects(Isolate* isolate, | 397 void GCMarker::MarkObjects(Isolate* isolate, |
| 382 PageSpace* page_space, | 398 PageSpace* page_space, |
| 383 bool invoke_api_callbacks) { | 399 bool invoke_api_callbacks) { |
| 384 MarkingStack marking_stack; | 400 MarkingStack marking_stack; |
| 385 Prologue(isolate, invoke_api_callbacks); | 401 Prologue(isolate, invoke_api_callbacks); |
| 386 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); | 402 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); |
| 387 IterateRoots(isolate, &mark, !invoke_api_callbacks); | 403 IterateRoots(isolate, &mark, !invoke_api_callbacks); |
| 388 DrainMarkingStack(isolate, &mark); | 404 DrainMarkingStack(isolate, &mark); |
| 389 IterateWeakReferences(isolate, &mark); | 405 IterateWeakReferences(isolate, &mark); |
| 390 MarkingWeakVisitor mark_weak; | 406 MarkingWeakVisitor mark_weak; |
| 391 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 407 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
| 392 mark.Finalize(); | 408 mark.Finalize(); |
| 409 ProcessPeerReferents(); |
| 393 Epilogue(isolate, invoke_api_callbacks); | 410 Epilogue(isolate, invoke_api_callbacks); |
| 394 } | 411 } |
| 395 | 412 |
| 396 } // namespace dart | 413 } // namespace dart |
| OLD | NEW |