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

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

Issue 2985863002: Changes new space allocation from simple bump pointer allocation from (Closed)
Patch Set: Zeroes out TLAB when needed. Changes variable and fn names Created 3 years, 4 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(Thread* thread, 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 ASSERT(result < top_);
138 thread->set_top(result);
139 thread->set_end(top_);
140 return result;
141 }
142
124 uword AllocateGC(intptr_t size) { 143 uword AllocateGC(intptr_t size) {
125 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 144 ASSERT(Utils::IsAligned(size, kObjectAlignment));
126 ASSERT(heap_ != Dart::vm_isolate()->heap()); 145 ASSERT(heap_ != Dart::vm_isolate()->heap());
127 ASSERT(scavenging_); 146 ASSERT(scavenging_);
128 uword result = top_; 147 uword result = top_;
129 intptr_t remaining = end_ - top_; 148 intptr_t remaining = end_ - top_;
130 149
131 // This allocation happens only in GC and only when copying objects to 150 // This allocation happens only in GC and only when copying objects to
132 // the new to_ space. It must succeed. 151 // the new to_ space. It must succeed.
133 ASSERT(size <= remaining); 152 ASSERT(size <= remaining);
134 ASSERT(to_->Contains(result)); 153 ASSERT(to_->Contains(result));
135 ASSERT((result & kObjectAlignmentMask) == object_alignment_); 154 ASSERT((result & kObjectAlignmentMask) == object_alignment_);
136 top_ += size; 155 top_ += size;
137 ASSERT(to_->Contains(top_) || (top_ == to_->end())); 156 ASSERT(to_->Contains(top_) || (top_ == to_->end()));
138 return result; 157 return result;
139 } 158 }
140 159
141 uword TryAllocateInTLAB(Thread* thread, intptr_t size) { 160 uword TryAllocateInTLAB(Thread* thread, intptr_t size) {
142 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 161 ASSERT(Utils::IsAligned(size, kObjectAlignment));
143 ASSERT(heap_ != Dart::vm_isolate()->heap()); 162 ASSERT(heap_ != Dart::vm_isolate()->heap());
144 ASSERT(thread->IsMutatorThread()); 163 ASSERT(thread->IsMutatorThread());
145 ASSERT(thread->isolate()->IsMutatorThreadScheduled()); 164 ASSERT(thread->isolate()->IsMutatorThreadScheduled());
165 ASSERT(thread->top() <= top_);
166 ASSERT(thread->end() == 0 || thread->end() == top_);
rmacnak 2017/07/26 21:30:30 ASSERT((thread->end() == 0) || (thread->end() == t
danunez 2017/07/26 22:07:12 Done.
146 #if defined(DEBUG) 167 #if defined(DEBUG)
147 if (FLAG_gc_at_alloc) { 168 if (FLAG_gc_at_alloc) {
148 ASSERT(!scavenging_); 169 ASSERT(!scavenging_);
149 Scavenge(); 170 Scavenge();
150 } 171 }
151 #endif 172 #endif
152 uword top = thread->top(); 173 uword top = thread->top();
153 uword end = thread->end(); 174 uword end = thread->end();
154 uword result = top; 175 uword result = top;
155 intptr_t remaining = end - top; 176 intptr_t remaining = end - top;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 229
209 intptr_t collections() const { return collections_; } 230 intptr_t collections() const { return collections_; }
210 231
211 #ifndef PRODUCT 232 #ifndef PRODUCT
212 void PrintToJSONObject(JSONObject* object) const; 233 void PrintToJSONObject(JSONObject* object) const;
213 #endif // !PRODUCT 234 #endif // !PRODUCT
214 235
215 void AllocateExternal(intptr_t size); 236 void AllocateExternal(intptr_t size);
216 void FreeExternal(intptr_t size); 237 void FreeExternal(intptr_t size);
217 238
218 void FlushTLS() const; 239 uword FlushTLS() const;
240 void UnflushTLS(uword value) const;
241 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
219 242
220 private: 243 private:
221 // Ids for time and data records in Heap::GCStats. 244 // Ids for time and data records in Heap::GCStats.
222 enum { 245 enum {
223 // Time 246 // Time
224 kDummyScavengeTime = 0, 247 kDummyScavengeTime = 0,
225 kSafePoint = 1, 248 kSafePoint = 1,
226 kVisitIsolateRoots = 2, 249 kVisitIsolateRoots = 2,
227 kIterateStoreBuffers = 3, 250 kIterateStoreBuffers = 3,
228 kProcessToSpace = 4, 251 kProcessToSpace = 4,
229 kIterateWeaks = 5, 252 kIterateWeaks = 5,
230 // Data 253 // Data
231 kStoreBufferEntries = 0, 254 kStoreBufferEntries = 0,
232 kDataUnused1 = 1, 255 kDataUnused1 = 1,
233 kDataUnused2 = 2, 256 kDataUnused2 = 2,
234 kToKBAfterStoreBuffer = 3 257 kToKBAfterStoreBuffer = 3
235 }; 258 };
236 259
237 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
238 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks); 260 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks);
239 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor); 261 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor);
240 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor); 262 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor);
241 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor); 263 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor);
242 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor); 264 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor);
243 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); 265 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor);
244 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); 266 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor);
245 void ProcessToSpace(ScavengerVisitor* visitor); 267 void ProcessToSpace(ScavengerVisitor* visitor);
246 void EnqueueWeakProperty(RawWeakProperty* raw_weak); 268 void EnqueueWeakProperty(RawWeakProperty* raw_weak);
247 uword ProcessWeakProperty(RawWeakProperty* raw_weak, 269 uword ProcessWeakProperty(RawWeakProperty* raw_weak,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 338
317 friend class ScavengerVisitor; 339 friend class ScavengerVisitor;
318 friend class ScavengerWeakVisitor; 340 friend class ScavengerWeakVisitor;
319 341
320 DISALLOW_COPY_AND_ASSIGN(Scavenger); 342 DISALLOW_COPY_AND_ASSIGN(Scavenger);
321 }; 343 };
322 344
323 } // namespace dart 345 } // namespace dart
324 346
325 #endif // RUNTIME_VM_SCAVENGER_H_ 347 #endif // RUNTIME_VM_SCAVENGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698