| 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" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool invoke_api_callbacks); | 153 bool invoke_api_callbacks); |
| 154 | 154 |
| 155 bool IsUnreachable(RawObject** p); | 155 bool IsUnreachable(RawObject** p); |
| 156 | 156 |
| 157 // During a scavenge we need to remember the promoted objects. | 157 // During a scavenge we need to remember the promoted objects. |
| 158 // This is implemented as a stack of objects at the end of the to space. As | 158 // This is implemented as a stack of objects at the end of the to space. As |
| 159 // object sizes are always greater than sizeof(uword) and promoted objects do | 159 // object sizes are always greater than sizeof(uword) and promoted objects do |
| 160 // not consume space in the to space they leave enough room for this stack. | 160 // not consume space in the to space they leave enough room for this stack. |
| 161 void PushToPromotedStack(uword addr) { | 161 void PushToPromotedStack(uword addr) { |
| 162 ASSERT(scavenging_); | 162 ASSERT(scavenging_); |
| 163 ASSERT(external_size_ == 0); | |
| 164 end_ -= sizeof(addr); | 163 end_ -= sizeof(addr); |
| 165 ASSERT(end_ > top_); | 164 ASSERT(end_ > top_); |
| 166 *reinterpret_cast<uword*>(end_) = addr; | 165 *reinterpret_cast<uword*>(end_) = addr; |
| 167 } | 166 } |
| 168 uword PopFromPromotedStack() { | 167 uword PopFromPromotedStack() { |
| 169 ASSERT(scavenging_); | 168 ASSERT(scavenging_); |
| 170 ASSERT(external_size_ == 0); | |
| 171 uword result = *reinterpret_cast<uword*>(end_); | 169 uword result = *reinterpret_cast<uword*>(end_); |
| 172 end_ += sizeof(result); | 170 end_ += sizeof(result); |
| 173 ASSERT(end_ <= to_->end()); | 171 ASSERT(end_ <= to_->end()); |
| 174 return result; | 172 return result; |
| 175 } | 173 } |
| 176 bool PromotedStackHasMore() const { | 174 bool PromotedStackHasMore() const { |
| 177 ASSERT(scavenging_); | 175 ASSERT(scavenging_); |
| 178 ASSERT(external_size_ == 0); | |
| 179 return end_ < to_->end(); | 176 return end_ < to_->end(); |
| 180 } | 177 } |
| 181 | 178 |
| 182 void ProcessWeakTables(); | 179 void ProcessWeakTables(); |
| 183 | 180 |
| 184 VirtualMemory* space_; | 181 VirtualMemory* space_; |
| 185 MemoryRegion* to_; | 182 MemoryRegion* to_; |
| 186 MemoryRegion* from_; | 183 MemoryRegion* from_; |
| 187 | 184 |
| 188 Heap* heap_; | 185 Heap* heap_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 204 | 201 |
| 205 // Keep track whether a scavenge is currently running. | 202 // Keep track whether a scavenge is currently running. |
| 206 bool scavenging_; | 203 bool scavenging_; |
| 207 // Keep track whether the scavenge had a promotion failure. | 204 // Keep track whether the scavenge had a promotion failure. |
| 208 bool had_promotion_failure_; | 205 bool had_promotion_failure_; |
| 209 | 206 |
| 210 int64_t gc_time_micros_; | 207 int64_t gc_time_micros_; |
| 211 intptr_t collections_; | 208 intptr_t collections_; |
| 212 | 209 |
| 213 // The total size of external data associated with objects in this scavenger. | 210 // The total size of external data associated with objects in this scavenger. |
| 214 // External allocations decrease end_. If promoted stack is in use, this is 0. | |
| 215 intptr_t external_size_; | 211 intptr_t external_size_; |
| 216 | 212 |
| 217 friend class ScavengerVisitor; | 213 friend class ScavengerVisitor; |
| 218 friend class ScavengerWeakVisitor; | 214 friend class ScavengerWeakVisitor; |
| 219 | 215 |
| 220 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 216 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
| 221 }; | 217 }; |
| 222 | 218 |
| 223 } // namespace dart | 219 } // namespace dart |
| 224 | 220 |
| 225 #endif // VM_SCAVENGER_H_ | 221 #endif // VM_SCAVENGER_H_ |
| OLD | NEW |