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

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

Issue 3001423002: Initial idle GC logic. (Closed)
Patch Set: . 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // Fraction of promotion candidates that survived and was thereby promoted. 92 // Fraction of promotion candidates that survived and was thereby promoted.
93 // Returns zero if there were no promotion candidates. 93 // Returns zero if there were no promotion candidates.
94 double PromoCandidatesSuccessFraction() const { 94 double PromoCandidatesSuccessFraction() const {
95 return promo_candidates_in_words_ > 0 95 return promo_candidates_in_words_ > 0
96 ? promoted_in_words_ / 96 ? promoted_in_words_ /
97 static_cast<double>(promo_candidates_in_words_) 97 static_cast<double>(promo_candidates_in_words_)
98 : 0.0; 98 : 0.0;
99 } 99 }
100 100
101 intptr_t UsedBeforeInWords() const { return before_.used_in_words; }
102
101 int64_t DurationMicros() const { return end_micros_ - start_micros_; } 103 int64_t DurationMicros() const { return end_micros_ - start_micros_; }
102 104
103 private: 105 private:
104 int64_t start_micros_; 106 int64_t start_micros_;
105 int64_t end_micros_; 107 int64_t end_micros_;
106 SpaceUsage before_; 108 SpaceUsage before_;
107 SpaceUsage after_; 109 SpaceUsage after_;
108 intptr_t promo_candidates_in_words_; 110 intptr_t promo_candidates_in_words_;
109 intptr_t promoted_in_words_; 111 intptr_t promoted_in_words_;
110 }; 112 };
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return usage; 217 return usage;
216 } 218 }
217 219
218 void VisitObjects(ObjectVisitor* visitor) const; 220 void VisitObjects(ObjectVisitor* visitor) const;
219 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 221 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
220 222
221 void AddRegionsToObjectSet(ObjectSet* set) const; 223 void AddRegionsToObjectSet(ObjectSet* set) const;
222 224
223 void WriteProtect(bool read_only); 225 void WriteProtect(bool read_only);
224 226
227 bool ShouldPerformIdleScavenge(int64_t deadline);
228
225 void AddGCTime(int64_t micros) { gc_time_micros_ += micros; } 229 void AddGCTime(int64_t micros) { gc_time_micros_ += micros; }
226 230
227 int64_t gc_time_micros() const { return gc_time_micros_; } 231 int64_t gc_time_micros() const { return gc_time_micros_; }
228 232
229 void IncrementCollections() { collections_++; } 233 void IncrementCollections() { collections_++; }
230 234
231 intptr_t collections() const { return collections_; } 235 intptr_t collections() const { return collections_; }
232 236
233 #ifndef PRODUCT 237 #ifndef PRODUCT
234 void PrintToJSONObject(JSONObject* object) const; 238 void PrintToJSONObject(JSONObject* object) const;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 uword object_alignment_; 328 uword object_alignment_;
325 329
326 // Keep track whether a scavenge is currently running. 330 // Keep track whether a scavenge is currently running.
327 bool scavenging_; 331 bool scavenging_;
328 332
329 // Keep track of pending weak properties discovered while scagenging. 333 // Keep track of pending weak properties discovered while scagenging.
330 RawWeakProperty* delayed_weak_properties_; 334 RawWeakProperty* delayed_weak_properties_;
331 335
332 int64_t gc_time_micros_; 336 int64_t gc_time_micros_;
333 intptr_t collections_; 337 intptr_t collections_;
334 static const int kStatsHistoryCapacity = 2; 338 static const int kStatsHistoryCapacity = 4;
335 RingBuffer<ScavengeStats, kStatsHistoryCapacity> stats_history_; 339 RingBuffer<ScavengeStats, kStatsHistoryCapacity> stats_history_;
336 340
341 intptr_t scavenge_words_per_micro_;
342 intptr_t idle_scavenge_threshold_in_words_;
343
337 // The total size of external data associated with objects in this scavenger. 344 // The total size of external data associated with objects in this scavenger.
338 intptr_t external_size_; 345 intptr_t external_size_;
339 346
340 bool failed_to_promote_; 347 bool failed_to_promote_;
341 348
342 // Protects new space during the allocation of new TLABs 349 // Protects new space during the allocation of new TLABs
343 Mutex* space_lock_; 350 Mutex* space_lock_;
344 friend class ScavengerVisitor; 351 friend class ScavengerVisitor;
345 friend class ScavengerWeakVisitor; 352 friend class ScavengerWeakVisitor;
346 353
347 DISALLOW_COPY_AND_ASSIGN(Scavenger); 354 DISALLOW_COPY_AND_ASSIGN(Scavenger);
348 }; 355 };
349 356
350 } // namespace dart 357 } // namespace dart
351 358
352 #endif // RUNTIME_VM_SCAVENGER_H_ 359 #endif // RUNTIME_VM_SCAVENGER_H_
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/scavenger.cc » ('j') | runtime/vm/scavenger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698