| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_SCAVENGER_H_ | 5 #ifndef VM_SCAVENGER_H_ |
| 6 #define VM_SCAVENGER_H_ | 6 #define VM_SCAVENGER_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 12 #include "vm/raw_object.h" | 12 #include "vm/raw_object.h" |
| 13 #include "vm/virtual_memory.h" | 13 #include "vm/virtual_memory.h" |
| 14 #include "vm/visitor.h" | 14 #include "vm/visitor.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class Heap; | 19 class Heap; |
| 20 class Isolate; | 20 class Isolate; |
| 21 class ScavengerVisitor; |
| 21 | 22 |
| 22 DECLARE_FLAG(bool, gc_at_alloc); | 23 DECLARE_FLAG(bool, gc_at_alloc); |
| 23 | 24 |
| 24 class Scavenger { | 25 class Scavenger { |
| 25 public: | 26 public: |
| 26 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment); | 27 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment); |
| 27 ~Scavenger(); | 28 ~Scavenger(); |
| 28 | 29 |
| 29 // Check whether this Scavenger contains this address. | 30 // Check whether this Scavenger contains this address. |
| 30 // During scavenging both the to and from spaces contain "legal" objects. | 31 // During scavenging both the to and from spaces contain "legal" objects. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 // Returns true if the last scavenge had a promotion failure. | 83 // Returns true if the last scavenge had a promotion failure. |
| 83 bool HadPromotionFailure() { | 84 bool HadPromotionFailure() { |
| 84 return had_promotion_failure_; | 85 return had_promotion_failure_; |
| 85 } | 86 } |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 uword FirstObjectStart() const { return to_->start() | object_alignment_; } | 89 uword FirstObjectStart() const { return to_->start() | object_alignment_; } |
| 89 void Prologue(Isolate* isolate, bool invoke_api_callbacks); | 90 void Prologue(Isolate* isolate, bool invoke_api_callbacks); |
| 90 void IterateRoots(Isolate* isolate, | 91 void IterateRoots(Isolate* isolate, |
| 91 ObjectPointerVisitor* visitor, | 92 ScavengerVisitor* visitor, |
| 92 bool visit_prologue_weak_persistent_handles); | 93 bool visit_prologue_weak_persistent_handles); |
| 93 void IterateWeakReferences(Isolate* isolate, ObjectPointerVisitor* visitor); | 94 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); |
| 94 void IterateWeakRoots(Isolate* isolate, | 95 void IterateWeakRoots(Isolate* isolate, |
| 95 HandleVisitor* visitor, | 96 HandleVisitor* visitor, |
| 96 bool visit_prologue_weak_persistent_handles); | 97 bool visit_prologue_weak_persistent_handles); |
| 97 void ProcessToSpace(ObjectPointerVisitor* visitor); | 98 void ProcessToSpace(ScavengerVisitor* visitor); |
| 98 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); | 99 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); |
| 99 | 100 |
| 100 bool IsUnreachable(RawObject** p); | 101 bool IsUnreachable(RawObject** p); |
| 101 | 102 |
| 102 // During a scavenge we need to remember the promoted objects. | 103 // During a scavenge we need to remember the promoted objects. |
| 103 // This is implemented as a stack of objects at the end of the to space. As | 104 // This is implemented as a stack of objects at the end of the to space. As |
| 104 // object sizes are always greater than sizeof(uword) and promoted objects do | 105 // object sizes are always greater than sizeof(uword) and promoted objects do |
| 105 // not consume space in the to space they leave enough room for this stack. | 106 // not consume space in the to space they leave enough room for this stack. |
| 106 void PushToPromotedStack(uword addr) { | 107 void PushToPromotedStack(uword addr) { |
| 107 end_ -= sizeof(addr); | 108 end_ -= sizeof(addr); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 149 |
| 149 friend class ScavengerVisitor; | 150 friend class ScavengerVisitor; |
| 150 friend class ScavengerWeakVisitor; | 151 friend class ScavengerWeakVisitor; |
| 151 | 152 |
| 152 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 153 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 } // namespace dart | 156 } // namespace dart |
| 156 | 157 |
| 157 #endif // VM_SCAVENGER_H_ | 158 #endif // VM_SCAVENGER_H_ |
| OLD | NEW |