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

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

Issue 2992753002: Prepares allocation for proper sync with mutator and bg threads. (Closed)
Patch Set: Adds locking when creating new TLABs 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"
11 #include "vm/flags.h" 11 #include "vm/flags.h"
12 #include "vm/globals.h" 12 #include "vm/globals.h"
13 #include "vm/lockers.h"
13 #include "vm/raw_object.h" 14 #include "vm/raw_object.h"
14 #include "vm/ring_buffer.h" 15 #include "vm/ring_buffer.h"
15 #include "vm/spaces.h" 16 #include "vm/spaces.h"
16 #include "vm/virtual_memory.h" 17 #include "vm/virtual_memory.h"
17 #include "vm/visitor.h" 18 #include "vm/visitor.h"
18 19
19 namespace dart { 20 namespace dart {
20 21
21 // Forward declarations. 22 // Forward declarations.
22 class Heap; 23 class Heap;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // During a scavenge this function only returns true for addresses that will 119 // During a scavenge this function only returns true for addresses that will
119 // be part of the surviving objects. 120 // be part of the surviving objects.
120 bool Contains(uword addr) const { return to_->Contains(addr); } 121 bool Contains(uword addr) const { return to_->Contains(addr); }
121 122
122 RawObject* FindObject(FindObjectVisitor* visitor) const; 123 RawObject* FindObject(FindObjectVisitor* visitor) const;
123 124
124 uword TryAllocateNewTLAB(Thread* thread, intptr_t size) { 125 uword TryAllocateNewTLAB(Thread* thread, intptr_t size) {
125 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 126 ASSERT(Utils::IsAligned(size, kObjectAlignment));
126 ASSERT(heap_ != Dart::vm_isolate()->heap()); 127 ASSERT(heap_ != Dart::vm_isolate()->heap());
127 ASSERT(!scavenging_); 128 ASSERT(!scavenging_);
129 MutexLocker ml(space_lock_);
128 uword result = top_; 130 uword result = top_;
129 intptr_t remaining = end_ - top_; 131 intptr_t remaining = end_ - top_;
130 if (remaining < size) { 132 if (remaining < size) {
131 return 0; 133 return 0;
132 } 134 }
133 ASSERT(to_->Contains(result)); 135 ASSERT(to_->Contains(result));
134 ASSERT((result & kObjectAlignmentMask) == object_alignment_); 136 ASSERT((result & kObjectAlignmentMask) == object_alignment_);
135 top_ += size; 137 top_ += size;
136 ASSERT(to_->Contains(top_) || (top_ == to_->end())); 138 ASSERT(to_->Contains(top_) || (top_ == to_->end()));
137 ASSERT(result < top_); 139 ASSERT(result < top_);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 intptr_t collections() const { return collections_; } 230 intptr_t collections() const { return collections_; }
229 231
230 #ifndef PRODUCT 232 #ifndef PRODUCT
231 void PrintToJSONObject(JSONObject* object) const; 233 void PrintToJSONObject(JSONObject* object) const;
232 #endif // !PRODUCT 234 #endif // !PRODUCT
233 235
234 void AllocateExternal(intptr_t size); 236 void AllocateExternal(intptr_t size);
235 void FreeExternal(intptr_t size); 237 void FreeExternal(intptr_t size);
236 238
237 void MakeNewSpaceIterable() const; 239 void MakeNewSpaceIterable() const;
238 uword FirstObjectStart() const { return to_->start() | object_alignment_; } 240 int64_t FreeSpaceInWords(Isolate* isolate) const;
241 void MakeAllTLABsIterable(Isolate* isolate) const;
242 void FlushTLS() const;
rmacnak 2017/08/10 18:37:07 There is no definition of FlushTLS.
danunez 2017/08/10 20:36:46 Removed this declaration.
243 void AbandonAllTLABs(Isolate* isolate);
239 244
240 private: 245 private:
241 // Ids for time and data records in Heap::GCStats. 246 // Ids for time and data records in Heap::GCStats.
242 enum { 247 enum {
243 // Time 248 // Time
244 kDummyScavengeTime = 0, 249 kDummyScavengeTime = 0,
245 kSafePoint = 1, 250 kSafePoint = 1,
246 kVisitIsolateRoots = 2, 251 kVisitIsolateRoots = 2,
247 kIterateStoreBuffers = 3, 252 kIterateStoreBuffers = 3,
248 kProcessToSpace = 4, 253 kProcessToSpace = 4,
249 kIterateWeaks = 5, 254 kIterateWeaks = 5,
250 // Data 255 // Data
251 kStoreBufferEntries = 0, 256 kStoreBufferEntries = 0,
252 kDataUnused1 = 1, 257 kDataUnused1 = 1,
253 kDataUnused2 = 2, 258 kDataUnused2 = 2,
254 kToKBAfterStoreBuffer = 3 259 kToKBAfterStoreBuffer = 3
255 }; 260 };
256 261
262 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
257 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks); 263 SemiSpace* Prologue(Isolate* isolate, bool invoke_api_callbacks);
258 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor); 264 void IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor);
259 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor); 265 void IterateObjectIdTable(Isolate* isolate, ScavengerVisitor* visitor);
260 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor); 266 void IterateRoots(Isolate* isolate, ScavengerVisitor* visitor);
261 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor); 267 void IterateWeakProperties(Isolate* isolate, ScavengerVisitor* visitor);
262 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor); 268 void IterateWeakReferences(Isolate* isolate, ScavengerVisitor* visitor);
263 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor); 269 void IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor);
264 void ProcessToSpace(ScavengerVisitor* visitor); 270 void ProcessToSpace(ScavengerVisitor* visitor);
265 void EnqueueWeakProperty(RawWeakProperty* raw_weak); 271 void EnqueueWeakProperty(RawWeakProperty* raw_weak);
266 uword ProcessWeakProperty(RawWeakProperty* raw_weak, 272 uword ProcessWeakProperty(RawWeakProperty* raw_weak,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 int64_t gc_time_micros_; 332 int64_t gc_time_micros_;
327 intptr_t collections_; 333 intptr_t collections_;
328 static const int kStatsHistoryCapacity = 2; 334 static const int kStatsHistoryCapacity = 2;
329 RingBuffer<ScavengeStats, kStatsHistoryCapacity> stats_history_; 335 RingBuffer<ScavengeStats, kStatsHistoryCapacity> stats_history_;
330 336
331 // The total size of external data associated with objects in this scavenger. 337 // The total size of external data associated with objects in this scavenger.
332 intptr_t external_size_; 338 intptr_t external_size_;
333 339
334 bool failed_to_promote_; 340 bool failed_to_promote_;
335 341
342 Mutex* space_lock_;
rmacnak 2017/08/10 18:37:07 // Protects allocation of TLABs.
danunez 2017/08/10 20:36:46 Done.
336 friend class ScavengerVisitor; 343 friend class ScavengerVisitor;
337 friend class ScavengerWeakVisitor; 344 friend class ScavengerWeakVisitor;
338 345
339 DISALLOW_COPY_AND_ASSIGN(Scavenger); 346 DISALLOW_COPY_AND_ASSIGN(Scavenger);
340 }; 347 };
341 348
342 } // namespace dart 349 } // namespace dart
343 350
344 #endif // RUNTIME_VM_SCAVENGER_H_ 351 #endif // RUNTIME_VM_SCAVENGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698