| 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 | 10 |
| 10 #include "vm/allocation.h" | 11 #include "vm/allocation.h" |
| 11 #include "vm/dart_api_state.h" | 12 #include "vm/dart_api_state.h" |
| 12 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
| 13 #include "vm/pages.h" | 14 #include "vm/pages.h" |
| 14 #include "vm/raw_object.h" | 15 #include "vm/raw_object.h" |
| 15 #include "vm/stack_frame.h" | 16 #include "vm/stack_frame.h" |
| 16 #include "vm/visitor.h" | 17 #include "vm/visitor.h" |
| 17 #include "vm/object_id_ring.h" | 18 #include "vm/object_id_ring.h" |
| 18 | 19 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 187 |
| 187 // Mark the object and push it on the marking stack. | 188 // Mark the object and push it on the marking stack. |
| 188 ASSERT(!raw_obj->IsMarked()); | 189 ASSERT(!raw_obj->IsMarked()); |
| 189 RawClass* raw_class = isolate()->class_table()->At(raw_obj->GetClassId()); | 190 RawClass* raw_class = isolate()->class_table()->At(raw_obj->GetClassId()); |
| 190 raw_obj->SetMarkBit(); | 191 raw_obj->SetMarkBit(); |
| 191 raw_obj->ClearRememberedBit(); | 192 raw_obj->ClearRememberedBit(); |
| 192 if (raw_obj->IsWatched()) { | 193 if (raw_obj->IsWatched()) { |
| 193 std::pair<DelaySet::iterator, DelaySet::iterator> ret; | 194 std::pair<DelaySet::iterator, DelaySet::iterator> ret; |
| 194 // Visit all elements with a key equal to raw_obj. | 195 // Visit all elements with a key equal to raw_obj. |
| 195 ret = delay_set_.equal_range(raw_obj); | 196 ret = delay_set_.equal_range(raw_obj); |
| 196 for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { | 197 // Create a copy of the range in a temporary vector to iterate over it |
| 198 // while delay_set_ may be modified. |
| 199 std::vector<DelaySetEntry> temp_copy(ret.first, ret.second); |
| 200 delay_set_.erase(ret.first, ret.second); |
| 201 for (std::vector<DelaySetEntry>::iterator it = temp_copy.begin(); |
| 202 it != temp_copy.end(); ++it) { |
| 197 it->second->VisitPointers(this); | 203 it->second->VisitPointers(this); |
| 198 } | 204 } |
| 199 delay_set_.erase(ret.first, ret.second); | |
| 200 raw_obj->ClearWatchedBit(); | 205 raw_obj->ClearWatchedBit(); |
| 201 } | 206 } |
| 202 marking_stack_->Push(raw_obj); | 207 marking_stack_->Push(raw_obj); |
| 203 | 208 |
| 204 // TODO(iposva): Should we mark the classes early? | 209 // TODO(iposva): Should we mark the classes early? |
| 205 MarkObject(raw_class, NULL); | 210 MarkObject(raw_class, NULL); |
| 206 } | 211 } |
| 207 | 212 |
| 208 void MarkObject(RawObject* raw_obj, RawObject** p) { | 213 void MarkObject(RawObject* raw_obj, RawObject** p) { |
| 209 // Fast exit if the raw object is a Smi. | 214 // Fast exit if the raw object is a Smi. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 266 } |
| 262 } | 267 } |
| 263 | 268 |
| 264 Heap* heap_; | 269 Heap* heap_; |
| 265 Heap* vm_heap_; | 270 Heap* vm_heap_; |
| 266 ClassTable* class_table_; | 271 ClassTable* class_table_; |
| 267 PageSpace* page_space_; | 272 PageSpace* page_space_; |
| 268 MarkingStack* marking_stack_; | 273 MarkingStack* marking_stack_; |
| 269 RawObject* visiting_old_object_; | 274 RawObject* visiting_old_object_; |
| 270 typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet; | 275 typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet; |
| 276 typedef std::pair<RawObject*, RawWeakProperty*> DelaySetEntry; |
| 271 DelaySet delay_set_; | 277 DelaySet delay_set_; |
| 272 const bool visit_function_code_; | 278 const bool visit_function_code_; |
| 273 GrowableArray<RawFunction*> skipped_code_functions_; | 279 GrowableArray<RawFunction*> skipped_code_functions_; |
| 274 | 280 |
| 275 DISALLOW_IMPLICIT_CONSTRUCTORS(MarkingVisitor); | 281 DISALLOW_IMPLICIT_CONSTRUCTORS(MarkingVisitor); |
| 276 }; | 282 }; |
| 277 | 283 |
| 278 | 284 |
| 279 bool IsUnreachable(const RawObject* raw_obj) { | 285 bool IsUnreachable(const RawObject* raw_obj) { |
| 280 if (!raw_obj->IsHeapObject()) { | 286 if (!raw_obj->IsHeapObject()) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 MarkingWeakVisitor mark_weak; | 497 MarkingWeakVisitor mark_weak; |
| 492 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 498 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
| 493 mark.Finalize(); | 499 mark.Finalize(); |
| 494 ProcessWeakTables(page_space); | 500 ProcessWeakTables(page_space); |
| 495 ProcessObjectIdTable(isolate); | 501 ProcessObjectIdTable(isolate); |
| 496 | 502 |
| 497 Epilogue(isolate, invoke_api_callbacks); | 503 Epilogue(isolate, invoke_api_callbacks); |
| 498 } | 504 } |
| 499 | 505 |
| 500 } // namespace dart | 506 } // namespace dart |
| OLD | NEW |