| 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 RUNTIME_VM_GC_MARKER_H_ | 5 #ifndef RUNTIME_VM_GC_MARKER_H_ |
| 6 #define RUNTIME_VM_GC_MARKER_H_ | 6 #define RUNTIME_VM_GC_MARKER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/os_thread.h" // Mutex. | 9 #include "vm/os_thread.h" // Mutex. |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Forward declarations. | 13 // Forward declarations. |
| 14 class HandleVisitor; | 14 class HandleVisitor; |
| 15 class Heap; | 15 class Heap; |
| 16 class Isolate; | 16 class Isolate; |
| 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), marked_bytes_(0) {} | 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, | |
| 31 bool collect_code); | 30 bool collect_code); |
| 32 | 31 |
| 33 intptr_t marked_words() { return marked_bytes_ >> kWordSizeLog2; } | 32 intptr_t marked_words() { return marked_bytes_ >> kWordSizeLog2; } |
| 34 | 33 |
| 35 private: | 34 private: |
| 36 void Prologue(Isolate* isolate, bool invoke_api_callbacks); | 35 void Prologue(Isolate* isolate); |
| 37 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); | 36 void Epilogue(Isolate* isolate); |
| 38 void IterateRoots(Isolate* isolate, | 37 void IterateRoots(Isolate* isolate, |
| 39 ObjectPointerVisitor* visitor, | 38 ObjectPointerVisitor* visitor, |
| 40 intptr_t slice_index, | 39 intptr_t slice_index, |
| 41 intptr_t num_slices); | 40 intptr_t num_slices); |
| 42 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); | 41 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); |
| 43 template <class MarkingVisitorType> | 42 template <class MarkingVisitorType> |
| 44 void IterateWeakReferences(Isolate* isolate, MarkingVisitorType* visitor); | 43 void IterateWeakReferences(Isolate* isolate, MarkingVisitorType* visitor); |
| 45 void ProcessWeakTables(PageSpace* page_space); | 44 void ProcessWeakTables(PageSpace* page_space); |
| 46 void ProcessObjectIdTable(Isolate* isolate); | 45 void ProcessObjectIdTable(Isolate* isolate); |
| 47 | 46 |
| 48 // Called by anyone: finalize and accumulate stats from 'visitor'. | 47 // Called by anyone: finalize and accumulate stats from 'visitor'. |
| 49 template <class MarkingVisitorType> | 48 template <class MarkingVisitorType> |
| 50 void FinalizeResultsFrom(MarkingVisitorType* visitor); | 49 void FinalizeResultsFrom(MarkingVisitorType* visitor); |
| 51 | 50 |
| 52 Heap* heap_; | 51 Heap* heap_; |
| 53 | 52 |
| 54 Mutex stats_mutex_; | 53 Mutex stats_mutex_; |
| 55 // TODO(koda): Remove after verifying it's redundant w.r.t. ClassHeapStats. | 54 // TODO(koda): Remove after verifying it's redundant w.r.t. ClassHeapStats. |
| 56 uintptr_t marked_bytes_; | 55 uintptr_t marked_bytes_; |
| 57 | 56 |
| 58 friend class MarkTask; | 57 friend class MarkTask; |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(GCMarker); | 58 DISALLOW_IMPLICIT_CONSTRUCTORS(GCMarker); |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 } // namespace dart | 61 } // namespace dart |
| 63 | 62 |
| 64 #endif // RUNTIME_VM_GC_MARKER_H_ | 63 #endif // RUNTIME_VM_GC_MARKER_H_ |
| OLD | NEW |