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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 ASSERT(to_->Contains(result)); | 53 ASSERT(to_->Contains(result)); |
54 ASSERT((result & kObjectAlignmentMask) == object_alignment_); | 54 ASSERT((result & kObjectAlignmentMask) == object_alignment_); |
55 | 55 |
56 top_ += size; | 56 top_ += size; |
57 ASSERT(to_->Contains(top_) || (top_ == to_->end())); | 57 ASSERT(to_->Contains(top_) || (top_ == to_->end())); |
58 return result; | 58 return result; |
59 } | 59 } |
60 | 60 |
61 // Collect the garbage in this scavenger. | 61 // Collect the garbage in this scavenger. |
62 void Scavenge(); | 62 void Scavenge(); |
| 63 void Scavenge(bool invoke_api_callbacks); |
63 | 64 |
64 // Accessors to generate code for inlined allocation. | 65 // Accessors to generate code for inlined allocation. |
65 uword* TopAddress() { return &top_; } | 66 uword* TopAddress() { return &top_; } |
66 uword* EndAddress() { return &end_; } | 67 uword* EndAddress() { return &end_; } |
67 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); } | 68 static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); } |
68 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); } | 69 static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); } |
69 | 70 |
70 intptr_t in_use() const { return (top_ - FirstObjectStart()); } | 71 intptr_t in_use() const { return (top_ - FirstObjectStart()); } |
71 | 72 |
72 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 73 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
73 | 74 |
74 private: | 75 private: |
75 uword FirstObjectStart() const { return to_->start() | object_alignment_; } | 76 uword FirstObjectStart() const { return to_->start() | object_alignment_; } |
76 void Prologue(); | 77 void Prologue(Isolate* isolate, bool invoke_api_callbacks); |
77 void IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor); | 78 void IterateRoots(Isolate* isolate, |
78 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); | 79 ObjectPointerVisitor* visitor, |
| 80 bool visit_prologue_weak_persistent_handles); |
| 81 void IterateWeakRoots(Isolate* isolate, |
| 82 HandleVisitor* visitor, |
| 83 bool visit_prologue_weak_persistent_handles); |
79 void ProcessToSpace(ObjectPointerVisitor* visitor); | 84 void ProcessToSpace(ObjectPointerVisitor* visitor); |
80 void Epilogue(); | 85 void Epilogue(Isolate* isolate, bool invoke_api_callbacks); |
81 | 86 |
82 // During a scavenge we need to remember the promoted objects. | 87 // During a scavenge we need to remember the promoted objects. |
83 // This is implemented as a stack of objects at the end of the to space. As | 88 // This is implemented as a stack of objects at the end of the to space. As |
84 // object sizes are always greater than sizeof(uword) and promoted objects do | 89 // object sizes are always greater than sizeof(uword) and promoted objects do |
85 // not consume space in the to space they leave enough room for this stack. | 90 // not consume space in the to space they leave enough room for this stack. |
86 void PushToPromotedStack(uword addr) { | 91 void PushToPromotedStack(uword addr) { |
87 end_ -= sizeof(addr); | 92 end_ -= sizeof(addr); |
88 ASSERT(end_ > top_); | 93 ASSERT(end_ > top_); |
89 *reinterpret_cast<uword*>(end_) = addr; | 94 *reinterpret_cast<uword*>(end_) = addr; |
90 } | 95 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 129 |
125 friend class ScavengerVisitor; | 130 friend class ScavengerVisitor; |
126 friend class ScavengerWeakVisitor; | 131 friend class ScavengerWeakVisitor; |
127 | 132 |
128 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 133 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
129 }; | 134 }; |
130 | 135 |
131 } // namespace dart | 136 } // namespace dart |
132 | 137 |
133 #endif // VM_SCAVENGER_H_ | 138 #endif // VM_SCAVENGER_H_ |
OLD | NEW |