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