| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 | 122 |
| 123 class MarkingVisitor : public ObjectPointerVisitor { | 123 class MarkingVisitor : public ObjectPointerVisitor { |
| 124 public: | 124 public: |
| 125 MarkingVisitor(Isolate* isolate, | 125 MarkingVisitor(Isolate* isolate, |
| 126 Heap* heap, | 126 Heap* heap, |
| 127 PageSpace* page_space, | 127 PageSpace* page_space, |
| 128 MarkingStack* marking_stack, | 128 MarkingStack* marking_stack, |
| 129 bool visit_function_code) | 129 bool visit_function_code) |
| 130 : ObjectPointerVisitor(isolate), | 130 : ObjectPointerVisitor(isolate), |
| 131 thread_(Thread::Current()), |
| 131 heap_(heap), | 132 heap_(heap), |
| 132 vm_heap_(Dart::vm_isolate()->heap()), | 133 vm_heap_(Dart::vm_isolate()->heap()), |
| 133 class_table_(isolate->class_table()), | 134 class_table_(isolate->class_table()), |
| 134 page_space_(page_space), | 135 page_space_(page_space), |
| 135 marking_stack_(marking_stack), | 136 marking_stack_(marking_stack), |
| 136 visiting_old_object_(NULL), | 137 visiting_old_object_(NULL), |
| 137 visit_function_code_(visit_function_code) { | 138 visit_function_code_(visit_function_code) { |
| 138 ASSERT(heap_ != vm_heap_); | 139 ASSERT(heap_ != vm_heap_); |
| 140 ASSERT(thread_->isolate() == isolate); |
| 139 } | 141 } |
| 140 | 142 |
| 141 MarkingStack* marking_stack() const { return marking_stack_; } | 143 MarkingStack* marking_stack() const { return marking_stack_; } |
| 142 | 144 |
| 143 void VisitPointers(RawObject** first, RawObject** last) { | 145 void VisitPointers(RawObject** first, RawObject** last) { |
| 144 for (RawObject** current = first; current <= last; current++) { | 146 for (RawObject** current = first; current <= last; current++) { |
| 145 MarkObject(*current, current); | 147 MarkObject(*current, current); |
| 146 } | 148 } |
| 147 } | 149 } |
| 148 | 150 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return; | 221 return; |
| 220 } | 222 } |
| 221 | 223 |
| 222 // Skip over new objects, but verify consistency of heap while at it. | 224 // Skip over new objects, but verify consistency of heap while at it. |
| 223 if (raw_obj->IsNewObject()) { | 225 if (raw_obj->IsNewObject()) { |
| 224 // TODO(iposva): Add consistency check. | 226 // TODO(iposva): Add consistency check. |
| 225 if ((visiting_old_object_ != NULL) && | 227 if ((visiting_old_object_ != NULL) && |
| 226 !visiting_old_object_->IsRemembered()) { | 228 !visiting_old_object_->IsRemembered()) { |
| 227 ASSERT(p != NULL); | 229 ASSERT(p != NULL); |
| 228 visiting_old_object_->SetRememberedBitUnsynchronized(); | 230 visiting_old_object_->SetRememberedBitUnsynchronized(); |
| 229 isolate()->store_buffer()->AddObjectGC(visiting_old_object_); | 231 thread_->StoreBufferAddObjectGC(visiting_old_object_); |
| 230 } | 232 } |
| 231 return; | 233 return; |
| 232 } | 234 } |
| 233 if (RawObject::IsVariableSizeClassId(raw_obj->GetClassId())) { | 235 if (RawObject::IsVariableSizeClassId(raw_obj->GetClassId())) { |
| 234 class_table_->UpdateLiveOld(raw_obj->GetClassId(), raw_obj->Size()); | 236 class_table_->UpdateLiveOld(raw_obj->GetClassId(), raw_obj->Size()); |
| 235 } else { | 237 } else { |
| 236 class_table_->UpdateLiveOld(raw_obj->GetClassId(), 0); | 238 class_table_->UpdateLiveOld(raw_obj->GetClassId(), 0); |
| 237 } | 239 } |
| 238 | 240 |
| 239 MarkAndPush(raw_obj); | 241 MarkAndPush(raw_obj); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 } | 282 } |
| 281 if (FLAG_log_code_drop) { | 283 if (FLAG_log_code_drop) { |
| 282 ISL_Print(" total detached current: %" Pd "\n", current_code_count); | 284 ISL_Print(" total detached current: %" Pd "\n", current_code_count); |
| 283 ISL_Print(" total detached unoptimized: %" Pd "\n", | 285 ISL_Print(" total detached unoptimized: %" Pd "\n", |
| 284 unoptimized_code_count); | 286 unoptimized_code_count); |
| 285 } | 287 } |
| 286 } | 288 } |
| 287 | 289 |
| 290 Thread* thread_; |
| 288 Heap* heap_; | 291 Heap* heap_; |
| 289 Heap* vm_heap_; | 292 Heap* vm_heap_; |
| 290 ClassTable* class_table_; | 293 ClassTable* class_table_; |
| 291 PageSpace* page_space_; | 294 PageSpace* page_space_; |
| 292 MarkingStack* marking_stack_; | 295 MarkingStack* marking_stack_; |
| 293 RawObject* visiting_old_object_; | 296 RawObject* visiting_old_object_; |
| 294 typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet; | 297 typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet; |
| 295 typedef std::pair<RawObject*, RawWeakProperty*> DelaySetEntry; | 298 typedef std::pair<RawObject*, RawWeakProperty*> DelaySetEntry; |
| 296 DelaySet delay_set_; | 299 DelaySet delay_set_; |
| 297 const bool visit_function_code_; | 300 const bool visit_function_code_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 334 |
| 332 private: | 335 private: |
| 333 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor); | 336 DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor); |
| 334 }; | 337 }; |
| 335 | 338 |
| 336 | 339 |
| 337 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) { | 340 void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) { |
| 338 if (invoke_api_callbacks && (isolate->gc_prologue_callback() != NULL)) { | 341 if (invoke_api_callbacks && (isolate->gc_prologue_callback() != NULL)) { |
| 339 (isolate->gc_prologue_callback())(); | 342 (isolate->gc_prologue_callback())(); |
| 340 } | 343 } |
| 344 Thread::PrepareForGC(); |
| 341 // The store buffers will be rebuilt as part of marking, reset them now. | 345 // The store buffers will be rebuilt as part of marking, reset them now. |
| 342 isolate->store_buffer()->Reset(); | 346 isolate->store_buffer()->Reset(); |
| 343 } | 347 } |
| 344 | 348 |
| 345 | 349 |
| 346 void GCMarker::Epilogue(Isolate* isolate, bool invoke_api_callbacks) { | 350 void GCMarker::Epilogue(Isolate* isolate, bool invoke_api_callbacks) { |
| 347 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { | 351 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { |
| 348 (isolate->gc_epilogue_callback())(); | 352 (isolate->gc_epilogue_callback())(); |
| 349 } | 353 } |
| 350 } | 354 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 MarkingWeakVisitor mark_weak; | 538 MarkingWeakVisitor mark_weak; |
| 535 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); | 539 IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks); |
| 536 mark.Finalize(); | 540 mark.Finalize(); |
| 537 ProcessWeakTables(page_space); | 541 ProcessWeakTables(page_space); |
| 538 ProcessObjectIdTable(isolate); | 542 ProcessObjectIdTable(isolate); |
| 539 } | 543 } |
| 540 Epilogue(isolate, invoke_api_callbacks); | 544 Epilogue(isolate, invoke_api_callbacks); |
| 541 } | 545 } |
| 542 | 546 |
| 543 } // namespace dart | 547 } // namespace dart |
| OLD | NEW |