Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: runtime/vm/scavenger.h

Issue 2985863002: Changes new space allocation from simple bump pointer allocation from (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 ~Scavenger(); 114 ~Scavenger();
115 115
116 // Check whether this Scavenger contains this address. 116 // Check whether this Scavenger contains this address.
117 // During scavenging both the to and from spaces contain "legal" objects. 117 // During scavenging both the to and from spaces contain "legal" objects.
118 // During a scavenge this function only returns true for addresses that will 118 // During a scavenge this function only returns true for addresses that will
119 // be part of the surviving objects. 119 // be part of the surviving objects.
120 bool Contains(uword addr) const { return to_->Contains(addr); } 120 bool Contains(uword addr) const { return to_->Contains(addr); }
121 121
122 RawObject* FindObject(FindObjectVisitor* visitor) const; 122 RawObject* FindObject(FindObjectVisitor* visitor) const;
123 123
124 uword TryAllocateNewTLAB(intptr_t size) {
125 ASSERT(Utils::IsAligned(size, kObjectAlignment));
126 ASSERT(heap_ != Dart::vm_isolate()->heap());
127 ASSERT(!scavenging_);
128 uword result = top_;
129 intptr_t remaining = end_ - top_;
130 if (remaining < size) {
131 return 0;
132 }
133 ASSERT(to_->Contains(result));
134 ASSERT((result & kObjectAlignmentMask) == object_alignment_);
135 top_ += size;
136 ASSERT(to_->Contains(top_) || (top_ == to_->end()));
137 return result;
138 }
139
124 uword AllocateGC(intptr_t size) { 140 uword AllocateGC(intptr_t size) {
125 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 141 ASSERT(Utils::IsAligned(size, kObjectAlignment));
126 ASSERT(heap_ != Dart::vm_isolate()->heap()); 142 ASSERT(heap_ != Dart::vm_isolate()->heap());
127 ASSERT(scavenging_); 143 ASSERT(scavenging_);
128 uword result = top_; 144 uword result = top_;
129 intptr_t remaining = end_ - top_; 145 intptr_t remaining = end_ - top_;
130 146
131 // This allocation happens only in GC and only when copying objects to 147 // This allocation happens only in GC and only when copying objects to
132 // the new to_ space. It must succeed. 148 // the new to_ space. It must succeed.
133 ASSERT(size <= remaining); 149 ASSERT(size <= remaining);
134 ASSERT(to_->Contains(result)); 150 ASSERT(to_->Contains(result));
135 ASSERT((result & kObjectAlignmentMask) == object_alignment_); 151 ASSERT((result & kObjectAlignmentMask) == object_alignment_);
136 top_ += size; 152 top_ += size;
137 ASSERT(to_->Contains(top_) || (top_ == to_->end())); 153 ASSERT(to_->Contains(top_) || (top_ == to_->end()));
138 return result; 154 return result;
139 } 155 }
140 156
141 uword TryAllocateInTLAB(Thread* thread, intptr_t size) { 157 uword TryAllocateInTLAB(Thread* thread, intptr_t size) {
142 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 158 ASSERT(Utils::IsAligned(size, kObjectAlignment));
143 ASSERT(heap_ != Dart::vm_isolate()->heap()); 159 ASSERT(heap_ != Dart::vm_isolate()->heap());
144 ASSERT(thread->IsMutatorThread()); 160 ASSERT(thread->IsMutatorThread());
145 ASSERT(thread->isolate()->IsMutatorThreadScheduled()); 161 ASSERT(thread->isolate()->IsMutatorThreadScheduled());
162 ASSERT(thread->top() <= top_);
163 ASSERT(thread->end() == top_);
146 #if defined(DEBUG) 164 #if defined(DEBUG)
147 if (FLAG_gc_at_alloc) { 165 if (FLAG_gc_at_alloc) {
148 ASSERT(!scavenging_); 166 ASSERT(!scavenging_);
149 Scavenge(); 167 Scavenge();
150 } 168 }
151 #endif 169 #endif
152 uword top = thread->top(); 170 uword top = thread->top();
153 uword end = thread->end(); 171 uword end = thread->end();
154 uword result = top; 172 uword result = top;
155 intptr_t remaining = end - top; 173 intptr_t remaining = end - top;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 226
209 intptr_t collections() const { return collections_; } 227 intptr_t collections() const { return collections_; }
210 228
211 #ifndef PRODUCT 229 #ifndef PRODUCT
212 void PrintToJSONObject(JSONObject* object) const; 230 void PrintToJSONObject(JSONObject* object) const;
213 #endif // !PRODUCT 231 #endif // !PRODUCT
214 232
215 void AllocateExternal(intptr_t size); 233 void AllocateExternal(intptr_t size);
216 void FreeExternal(intptr_t size); 234 void FreeExternal(intptr_t size);
217 235
218 void FlushTLS() const; 236 uword FlushTLS() const;
237 void UnflushTLS(uword value) const;
238 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
219 239
220 private: 240 private:
221 // Ids for time and data records in Heap::GCStats. 241 // Ids for time and data records in Heap::GCStats.
222 enum { 242 enum {
223 // Time 243 // Time
224 kDummyScavengeTime = 0, 244 kDummyScavengeTime = 0,
225 kSafePoint = 1, 245 kSafePoint = 1,
226 kVisitIsolateRoots = 2, 246 kVisitIsolateRoots = 2,
227 kIterateStoreBuffers = 3, 247 kIterateStoreBuffers = 3,
228 kProcessToSpace = 4, 248 kProcessToSpace = 4,
229 kIterateWeaks = 5, 249 kIterateWeaks = 5,
230 // Data 250 // Data
231 kStoreBufferEntries = 0, 251 kStoreBufferEntries = 0,
232 kDataUnused1 = 1, 252 kDataUnused1 = 1,
233 kDataUnused2 = 2, 253 kDataUnused2 = 2,
234 kToKBAfterStoreBuffer = 3 254 kToKBAfterStoreBuffer = 3
235 }; 255 };
236 256
237 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
238 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks); 257 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks);
239 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor); 258 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor);
240 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor); 259 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor);
241 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor); 260 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor);
242 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor); 261 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor);
243 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); 262 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor);
244 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); 263 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor);
245 void ProcessToSpace(ScavengerVisitor* visitor); 264 void ProcessToSpace(ScavengerVisitor* visitor);
246 void EnqueueWeakProperty(RawWeakProperty* raw_weak); 265 void EnqueueWeakProperty(RawWeakProperty* raw_weak);
247 uword ProcessWeakProperty(RawWeakProperty* raw_weak, 266 uword ProcessWeakProperty(RawWeakProperty* raw_weak,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 335
317 friend class ScavengerVisitor; 336 friend class ScavengerVisitor;
318 friend class ScavengerWeakVisitor; 337 friend class ScavengerWeakVisitor;
319 338
320 DISALLOW_COPY_AND_ASSIGN(Scavenger); 339 DISALLOW_COPY_AND_ASSIGN(Scavenger);
321 }; 340 };
322 341
323 } // namespace dart 342 } // namespace dart
324 343
325 #endif // RUNTIME_VM_SCAVENGER_H_ 344 #endif // RUNTIME_VM_SCAVENGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698