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 RUNTIME_VM_SCAVENGER_H_ | 5 #ifndef RUNTIME_VM_SCAVENGER_H_ |
6 #define RUNTIME_VM_SCAVENGER_H_ | 6 #define RUNTIME_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/dart.h" | 10 #include "vm/dart.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ASSERT(to_->Contains(result)); | 182 ASSERT(to_->Contains(result)); |
183 ASSERT((result & kObjectAlignmentMask) == object_alignment_); | 183 ASSERT((result & kObjectAlignmentMask) == object_alignment_); |
184 top += size; | 184 top += size; |
185 ASSERT((to_->Contains(top)) || (top == to_->end())); | 185 ASSERT((to_->Contains(top)) || (top == to_->end())); |
186 thread->set_top(top); | 186 thread->set_top(top); |
187 return result; | 187 return result; |
188 } | 188 } |
189 | 189 |
190 // Collect the garbage in this scavenger. | 190 // Collect the garbage in this scavenger. |
191 void Scavenge(); | 191 void Scavenge(); |
192 void Scavenge(bool invoke_api_callbacks); | |
193 | 192 |
194 // Promote all live objects. | 193 // Promote all live objects. |
195 void Evacuate(); | 194 void Evacuate(); |
196 | 195 |
197 uword top() { return top_; } | 196 uword top() { return top_; } |
198 uword end() { return end_; } | 197 uword end() { return end_; } |
199 | 198 |
200 void set_top(uword value) { top_ = value; } | 199 void set_top(uword value) { top_ = value; } |
201 void set_end(uword value) { | 200 void set_end(uword value) { |
202 ASSERT(to_->end() == value); | 201 ASSERT(to_->end() == value); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 kProcessToSpace = 4, | 251 kProcessToSpace = 4, |
253 kIterateWeaks = 5, | 252 kIterateWeaks = 5, |
254 // Data | 253 // Data |
255 kStoreBufferEntries = 0, | 254 kStoreBufferEntries = 0, |
256 kDataUnused1 = 1, | 255 kDataUnused1 = 1, |
257 kDataUnused2 = 2, | 256 kDataUnused2 = 2, |
258 kToKBAfterStoreBuffer = 3 | 257 kToKBAfterStoreBuffer = 3 |
259 }; | 258 }; |
260 | 259 |
261 uword FirstObjectStart() const { return to_->start() | object_alignment_; } | 260 uword FirstObjectStart() const { return to_->start() | object_alignment_; } |
262 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks); | 261 SemiSpace* Prologue(Isolate* isolate); |
263 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor); | 262 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor); |
264 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor); | 263 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor); |
265 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor); | 264 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor); |
266 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor); | 265 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor); |
267 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); | 266 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); |
268 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); | 267 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); |
269 void ProcessToSpace(ScavengerVisitor* visitor); | 268 void ProcessToSpace(ScavengerVisitor* visitor); |
270 void EnqueueWeakProperty(RawWeakProperty* raw_weak); | 269 void EnqueueWeakProperty(RawWeakProperty* raw_weak); |
271 uword ProcessWeakProperty(RawWeakProperty* raw_weak, | 270 uword ProcessWeakProperty(RawWeakProperty* raw_weak, |
272 ScavengerVisitor* visitor); | 271 ScavengerVisitor* visitor); |
273 void Epilogue(Isolate* isolate, SemiSpace* from, bool invoke_api_callbacks); | 272 void Epilogue(Isolate* isolate, SemiSpace* from); |
274 | 273 |
275 bool IsUnreachable(RawObject** p); | 274 bool IsUnreachable(RawObject** p); |
276 | 275 |
277 // During a scavenge we need to remember the promoted objects. | 276 // During a scavenge we need to remember the promoted objects. |
278 // This is implemented as a stack of objects at the end of the to space. As | 277 // This is implemented as a stack of objects at the end of the to space. As |
279 // object sizes are always greater than sizeof(uword) and promoted objects do | 278 // object sizes are always greater than sizeof(uword) and promoted objects do |
280 // not consume space in the to space they leave enough room for this stack. | 279 // not consume space in the to space they leave enough room for this stack. |
281 void PushToPromotedStack(uword addr) { | 280 void PushToPromotedStack(uword addr) { |
282 ASSERT(scavenging_); | 281 ASSERT(scavenging_); |
283 end_ -= sizeof(addr); | 282 end_ -= sizeof(addr); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 Mutex* space_lock_; | 341 Mutex* space_lock_; |
343 friend class ScavengerVisitor; | 342 friend class ScavengerVisitor; |
344 friend class ScavengerWeakVisitor; | 343 friend class ScavengerWeakVisitor; |
345 | 344 |
346 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 345 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
347 }; | 346 }; |
348 | 347 |
349 } // namespace dart | 348 } // namespace dart |
350 | 349 |
351 #endif // RUNTIME_VM_SCAVENGER_H_ | 350 #endif // RUNTIME_VM_SCAVENGER_H_ |
OLD | NEW |