| 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 #ifndef VM_GC_MARKER_H_ | 5 #ifndef VM_GC_MARKER_H_ |
| 6 #define VM_GC_MARKER_H_ | 6 #define VM_GC_MARKER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 // Forward declarations. | 12 // Forward declarations. |
| 13 class HandleVisitor; | 13 class HandleVisitor; |
| 14 class Heap; | 14 class Heap; |
| 15 class Isolate; | 15 class Isolate; |
| 16 class MarkingVisitor; | 16 class MarkingVisitor; |
| 17 class ObjectPointerVisitor; | 17 class ObjectPointerVisitor; |
| 18 class PageSpace; | 18 class PageSpace; |
| 19 class RawWeakProperty; | 19 class RawWeakProperty; |
| 20 | 20 |
| 21 // The class GCMarker is used to mark reachable old generation objects as part | 21 // The class GCMarker is used to mark reachable old generation objects as part |
| 22 // of the mark-sweep collection. The marking bit used is defined in RawObject. | 22 // of the mark-sweep collection. The marking bit used is defined in RawObject. |
| 23 class GCMarker : public ValueObject { | 23 class GCMarker : public ValueObject { |
| 24 public: | 24 public: |
| 25 explicit GCMarker(Heap* heap) : heap_(heap) { } | 25 explicit GCMarker(Heap* heap) : heap_(heap), marked_bytes_(0) { } |
| 26 ~GCMarker() { } | 26 ~GCMarker() { } |
| 27 | 27 |
| 28 void MarkObjects(Isolate* isolate, | 28 void MarkObjects(Isolate* isolate, |
| 29 PageSpace* page_space, | 29 PageSpace* page_space, |
| 30 bool invoke_api_callbacks, | 30 bool invoke_api_callbacks, |
| 31 bool collect_code); | 31 bool collect_code); |
| 32 | 32 |
| 33 intptr_t marked_words() { return marked_bytes_ >> kWordSizeLog2; } |
| 34 |
| 33 private: | 35 private: |
| 34 void Prologue(Isolate* isolate, bool invoke_api_callbacks); | 36 void Prologue(Isolate* isolate, bool invoke_api_callbacks); |
| 35 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); | 37 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); |
| 36 void IterateRoots(Isolate* isolate, | 38 void IterateRoots(Isolate* isolate, |
| 37 ObjectPointerVisitor* visitor, | 39 ObjectPointerVisitor* visitor, |
| 38 bool visit_prologue_weak_persistent_handles); | 40 bool visit_prologue_weak_persistent_handles); |
| 39 void IterateWeakRoots(Isolate* isolate, | 41 void IterateWeakRoots(Isolate* isolate, |
| 40 HandleVisitor* visitor, | 42 HandleVisitor* visitor, |
| 41 bool visit_prologue_weak_persistent_handles); | 43 bool visit_prologue_weak_persistent_handles); |
| 42 void IterateWeakReferences(Isolate* isolate, MarkingVisitor* visitor); | 44 void IterateWeakReferences(Isolate* isolate, MarkingVisitor* visitor); |
| 43 void DrainMarkingStack(Isolate* isolate, MarkingVisitor* visitor); | 45 void DrainMarkingStack(Isolate* isolate, MarkingVisitor* visitor); |
| 44 void ProcessWeakProperty(RawWeakProperty* raw_weak, MarkingVisitor* visitor); | 46 void ProcessWeakProperty(RawWeakProperty* raw_weak, MarkingVisitor* visitor); |
| 45 void ProcessWeakTables(PageSpace* page_space); | 47 void ProcessWeakTables(PageSpace* page_space); |
| 46 void ProcessObjectIdTable(Isolate* isolate); | 48 void ProcessObjectIdTable(Isolate* isolate); |
| 47 | 49 |
| 48 | 50 |
| 49 Heap* heap_; | 51 Heap* heap_; |
| 52 intptr_t marked_bytes_; |
| 50 | 53 |
| 51 DISALLOW_IMPLICIT_CONSTRUCTORS(GCMarker); | 54 DISALLOW_IMPLICIT_CONSTRUCTORS(GCMarker); |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 } // namespace dart | 57 } // namespace dart |
| 55 | 58 |
| 56 #endif // VM_GC_MARKER_H_ | 59 #endif // VM_GC_MARKER_H_ |
| OLD | NEW |