| 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 <map> |
| 9 |
| 8 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 9 #include "platform/utils.h" | 11 #include "platform/utils.h" |
| 10 #include "vm/flags.h" | 12 #include "vm/flags.h" |
| 11 #include "vm/globals.h" | 13 #include "vm/globals.h" |
| 12 #include "vm/raw_object.h" | 14 #include "vm/raw_object.h" |
| 13 #include "vm/virtual_memory.h" | 15 #include "vm/virtual_memory.h" |
| 14 #include "vm/visitor.h" | 16 #include "vm/visitor.h" |
| 15 | 17 |
| 16 namespace dart { | 18 namespace dart { |
| 17 | 19 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 *end = to_->end(); | 82 *end = to_->end(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 // Returns true if the last scavenge had a promotion failure. | 85 // Returns true if the last scavenge had a promotion failure. |
| 84 bool HadPromotionFailure() { | 86 bool HadPromotionFailure() { |
| 85 return had_promotion_failure_; | 87 return had_promotion_failure_; |
| 86 } | 88 } |
| 87 | 89 |
| 88 void WriteProtect(bool read_only); | 90 void WriteProtect(bool read_only); |
| 89 | 91 |
| 92 void SetPeer(RawObject* raw_obj, void* peer); |
| 93 |
| 94 void* GetPeer(RawObject* raw_obj); |
| 95 |
| 96 int64_t PeerCount() const; |
| 97 |
| 90 private: | 98 private: |
| 91 // Ids for time and data records in Heap::GCStats. | 99 // Ids for time and data records in Heap::GCStats. |
| 92 enum { | 100 enum { |
| 93 // Time | 101 // Time |
| 94 kVisitIsolateRoots = 0, | 102 kVisitIsolateRoots = 0, |
| 95 kIterateStoreBuffers = 1, | 103 kIterateStoreBuffers = 1, |
| 96 kProcessToSpace = 2, | 104 kProcessToSpace = 2, |
| 97 kIterateWeaks = 3, | 105 kIterateWeaks = 3, |
| 98 // Data | 106 // Data |
| 99 kStoreBufferEntries = 0, | 107 kStoreBufferEntries = 0, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 130 uword PopFromPromotedStack() { | 138 uword PopFromPromotedStack() { |
| 131 uword result = *reinterpret_cast<uword*>(end_); | 139 uword result = *reinterpret_cast<uword*>(end_); |
| 132 end_ += sizeof(result); | 140 end_ += sizeof(result); |
| 133 ASSERT(end_ <= to_->end()); | 141 ASSERT(end_ <= to_->end()); |
| 134 return result; | 142 return result; |
| 135 } | 143 } |
| 136 bool PromotedStackHasMore() const { | 144 bool PromotedStackHasMore() const { |
| 137 return end_ < to_->end(); | 145 return end_ < to_->end(); |
| 138 } | 146 } |
| 139 | 147 |
| 140 void ProcessWeakTables(); | 148 void ProcessPeerReferents(); |
| 141 | 149 |
| 142 VirtualMemory* space_; | 150 VirtualMemory* space_; |
| 143 MemoryRegion* to_; | 151 MemoryRegion* to_; |
| 144 MemoryRegion* from_; | 152 MemoryRegion* from_; |
| 145 | 153 |
| 146 Heap* heap_; | 154 Heap* heap_; |
| 147 | 155 |
| 156 typedef std::map<RawObject*, void*> PeerTable; |
| 157 PeerTable peer_table_; |
| 158 |
| 148 // Current allocation top and end. These values are being accessed directly | 159 // Current allocation top and end. These values are being accessed directly |
| 149 // from generated code. | 160 // from generated code. |
| 150 uword top_; | 161 uword top_; |
| 151 uword end_; | 162 uword end_; |
| 152 | 163 |
| 153 // A pointer to the first unscanned object. Scanning completes when | 164 // A pointer to the first unscanned object. Scanning completes when |
| 154 // this value meets the allocation top. | 165 // this value meets the allocation top. |
| 155 uword resolved_top_; | 166 uword resolved_top_; |
| 156 | 167 |
| 157 // Objects below this address have survived a scavenge. | 168 // Objects below this address have survived a scavenge. |
| 158 uword survivor_end_; | 169 uword survivor_end_; |
| 159 | 170 |
| 160 // All object are aligned to this value. | 171 // All object are aligned to this value. |
| 161 uword object_alignment_; | 172 uword object_alignment_; |
| 162 | 173 |
| 163 // Keep track whether a scavenge is currently running. | 174 // Keep track whether a scavenge is currently running. |
| 164 bool scavenging_; | 175 bool scavenging_; |
| 165 // Keep track whether the scavenge had a promotion failure. | 176 // Keep track whether the scavenge had a promotion failure. |
| 166 bool had_promotion_failure_; | 177 bool had_promotion_failure_; |
| 167 | 178 |
| 168 friend class ScavengerVisitor; | 179 friend class ScavengerVisitor; |
| 169 friend class ScavengerWeakVisitor; | 180 friend class ScavengerWeakVisitor; |
| 170 | 181 |
| 171 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 182 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
| 172 }; | 183 }; |
| 173 | 184 |
| 174 } // namespace dart | 185 } // namespace dart |
| 175 | 186 |
| 176 #endif // VM_SCAVENGER_H_ | 187 #endif // VM_SCAVENGER_H_ |
| OLD | NEW |