| 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(PageSpace* page_space) { |
| 382 PageSpace::PeerTable* peer_table = page_space->GetPeerTable(); |
| 383 PageSpace::PeerTable::iterator it = peer_table->begin(); |
| 384 while (it != peer_table->end()) { |
| 385 RawObject* raw_obj = it->first; |
| 386 ASSERT(raw_obj->IsHeapObject()); |
| 387 if (raw_obj->IsMarked()) { |
| 388 // The object has survived. Do nothing. |
| 389 ++it; |
| 390 } else { |
| 391 // The object has become garbage. Remove its record. |
| 392 peer_table->erase(it++); |
| 393 } |
| 394 } |
| 395 } |
| 396 |
| 397 |
| 381 void GCMarker::MarkObjects(Isolate* isolate, | 398 void GCMarker::MarkObjects(Isolate* isolate, |
| 382 PageSpace* page_space, | 399 PageSpace* page_space, |
| 383 bool invoke_api_callbacks) { | 400 bool invoke_api_callbacks) { |
| 384 MarkingStack marking_stack; | 401 MarkingStack marking_stack; |
| 385 Prologue(isolate, invoke_api_callbacks); | 402 Prologue(isolate, invoke_api_callbacks); |
| 386 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); | 403 MarkingVisitor mark(isolate, heap_, page_space, &marking_stack); |
| 387 IterateRoots(isolate, &mark, !invoke_api_callbacks); | 404 IterateRoots(isolate, &mark, !invoke_api_callbacks); |
| 388 DrainMarkingStack(isolate, &mark); | 405 DrainMarkingStack(isolate, &mark); |
| 389 IterateWeakReferences(isolate, &mark); | 406 IterateWeakReferences(isolate, &mark); |
| 390 MarkingWeakVisitor mark_weak; | 407 MarkingWeakVisitor mark_weak; |
| 391 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 408 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
| 392 mark.Finalize(); | 409 mark.Finalize(); |
| 410 ProcessPeerReferents(page_space); |
| 393 Epilogue(isolate, invoke_api_callbacks); | 411 Epilogue(isolate, invoke_api_callbacks); |
| 394 } | 412 } |
| 395 | 413 |
| 396 } // namespace dart | 414 } // namespace dart |
| OLD | NEW |