5#ifndef RUNTIME_VM_HEAP_PAGES_H_
6#define RUNTIME_VM_HEAP_PAGES_H_
48 static constexpr intptr_t kHistoryLength = 4;
49 RingBuffer<Entry, kHistoryLength> history_;
51 DISALLOW_ALLOCATION();
61 int heap_growth_ratio,
63 int garbage_collection_time_ratio);
90 intptr_t growth_in_pages,
100 const int heap_growth_ratio_;
104 const double desired_utilization_;
107 const int heap_growth_max_;
111 const int garbage_collection_time_ratio_;
114 intptr_t hard_gc_threshold_in_words_;
117 intptr_t soft_gc_threshold_in_words_;
120 intptr_t idle_gc_threshold_in_words_;
142 bool is_executable =
false,
144 bool is_protected = (is_executable) && FLAG_write_protect_code;
145 bool is_locked =
false;
146 return TryAllocateInternal(
147 size, &freelists_[is_executable ? kExecutableFreelist : kDataFreelist],
148 is_executable, growth_policy, is_protected, is_locked);
158 return TryAllocatePromoLockedSlow(freelist,
size);
168 return AllocateSnapshotLockedSlow(freelist,
size);
190 page->set_never_evacuate(
true);
257 void AddGCTime(int64_t micros) { gc_time_micros_ += micros; }
284 desired = expected + size_in_words;
302 return &freelists_[kDataFreelist +
i];
311 pause_concurrent_marking_.
fetch_or(0);
315 intptr_t
tasks()
const {
return tasks_; }
322 return concurrent_marker_tasks_;
327 concurrent_marker_tasks_ = val;
331 return concurrent_marker_tasks_active_;
336 concurrent_marker_tasks_active_ = val;
339 return pause_concurrent_marking_.
load() != 0;
364 kConcurrentSweep = 0,
369 kSweepLargePages = 5,
372 uword TryAllocateDataLocked(FreeList* freelist,
375 bool is_executable =
false;
376 bool is_protected =
false;
377 bool is_locked =
true;
378 return TryAllocateInternal(
size, freelist, is_executable, growth_policy,
379 is_protected, is_locked);
387 uword TryAllocateInFreshPage(intptr_t
size,
392 uword TryAllocateInFreshLargePage(intptr_t
size,
397 uword TryAllocateDataBumpLocked(FreeList* freelist, intptr_t
size);
398 uword TryAllocatePromoLockedSlow(FreeList* freelist, intptr_t
size);
399 uword AllocateSnapshotLockedSlow(FreeList* freelist, intptr_t
size);
402 void MakeIterable()
const;
404 void AddPageLocked(Page*
page);
405 void AddLargePageLocked(Page*
page);
406 void AddExecPageLocked(Page*
page);
407 void RemovePageLocked(Page*
page, Page* previous_page);
408 void RemoveLargePageLocked(Page*
page, Page* previous_page);
409 void RemoveExecPageLocked(Page*
page, Page* previous_page);
411 Page* AllocatePage(
bool is_executable,
bool link =
true);
412 Page* AllocateLargePage(intptr_t
size,
bool is_executable);
414 void TruncateLargePage(Page*
page, intptr_t new_object_size_in_bytes);
415 void FreePage(Page*
page, Page* previous_page);
416 void FreeLargePage(Page*
page, Page* previous_page);
417 void FreePages(Page* pages);
419 void CollectGarbageHelper(Thread* thread,
bool compact,
bool finalize);
420 void VerifyStoreBuffers(
const char* msg);
423 void Sweep(
bool exclusive);
424 void ConcurrentSweep(IsolateGroup* isolate_group);
425 void Compact(Thread* thread);
427 static intptr_t LargePageSizeInWordsFor(intptr_t
size);
429 bool CanIncreaseCapacityInWordsLocked(intptr_t increase_in_words) {
430 if (max_capacity_in_words_ == 0) {
434 intptr_t free_capacity_in_words =
436 return ((free_capacity_in_words > 0) &&
437 (increase_in_words <= free_capacity_in_words));
447 const intptr_t num_freelists_;
449 kExecutableFreelist = 0,
452 FreeList* freelists_;
453 static constexpr intptr_t kOOMReservationSize = 32 *
KB;
454 FreeListElement* oom_reservation_ =
nullptr;
457 mutable Mutex pages_lock_;
458 Page* pages_ =
nullptr;
459 Page* pages_tail_ =
nullptr;
460 Page* exec_pages_ =
nullptr;
461 Page* exec_pages_tail_ =
nullptr;
462 Page* large_pages_ =
nullptr;
463 Page* large_pages_tail_ =
nullptr;
464 Page* image_pages_ =
nullptr;
465 Page* sweep_regular_ =
nullptr;
466 Page* sweep_large_ =
nullptr;
469 intptr_t max_capacity_in_words_;
474 RelaxedAtomic<intptr_t> allocated_black_in_words_;
477 mutable Monitor tasks_lock_;
479 intptr_t concurrent_marker_tasks_;
480 intptr_t concurrent_marker_tasks_active_;
481 AcqRelAtomic<uword> pause_concurrent_marking_;
485 Thread* iterating_thread_;
490 int64_t gc_time_micros_;
491 intptr_t collections_;
492 intptr_t mark_words_per_micro_;
494 bool enable_concurrent_mark_;
#define DEBUG_ASSERT(cond)
T fetch_or(T arg, std::memory_order order=std::memory_order_acq_rel)
T load(std::memory_order order=std::memory_order_acquire) const
DART_FORCE_INLINE bool TryAllocateBumpLocked(intptr_t size, uword *result)
bool IsOwnedByCurrentThread() const
bool IsOwnedByCurrentThread() const
bool ReachedSoftThreshold(SpaceUsage after) const
bool ReachedHardThreshold(SpaceUsage after) const
bool ReachedIdleThreshold(SpaceUsage current) const
void set_last_usage(SpaceUsage current)
void EvaluateAfterLoading(SpaceUsage after)
void EvaluateGarbageCollection(SpaceUsage before, SpaceUsage after, int64_t start, int64_t end)
PageSpaceController(Heap *heap, int heap_growth_ratio, int heap_growth_max, int garbage_collection_time_ratio)
void AddGarbageCollectionTime(int64_t start, int64_t end)
~PageSpaceGarbageCollectionHistory()
int GarbageCollectionTimeFraction()
PageSpaceGarbageCollectionHistory()
void set_concurrent_marker_tasks_active(intptr_t val)
void WriteProtectCode(bool read_only)
FreeList * DataFreeList(intptr_t i=0)
void PrintHeapMapToJSONStream(IsolateGroup *isolate_group, JSONStream *stream) const
intptr_t UsedInWords() const
bool ReachedSoftThreshold() const
void AllocateBlack(intptr_t size)
intptr_t concurrent_marker_tasks_active() const
bool ShouldStartIdleMarkSweep(int64_t deadline)
void IncrementalMarkWithSizeBudget(intptr_t size)
void AddGCTime(int64_t micros)
DART_FORCE_INLINE uword TryAllocatePromoLocked(FreeList *freelist, intptr_t size)
bool Contains(uword addr) const
int64_t gc_time_micros() const
void WriteProtect(bool read_only)
uword TryAllocate(intptr_t size, bool is_executable=false, GrowthPolicy growth_policy=kControlGrowth)
void TryReleaseReservation()
void AcquireLock(FreeList *freelist)
bool ReachedIdleThreshold() const
void IncrementCollections()
bool ShouldPerformIdleMarkCompact(int64_t deadline)
PageSpace(Heap *heap, intptr_t max_capacity_in_words)
void PushDependencyToConcurrentMarking()
bool pause_concurrent_marking() const
friend class ExclusiveLargePageIterator
void set_tasks(intptr_t val)
bool enable_concurrent_mark() const
void set_concurrent_marker_tasks(intptr_t val)
void IncrementalMarkWithTimeBudget(int64_t deadline)
intptr_t collections() const
void VisitObjects(ObjectVisitor *visitor) const
void CollectGarbage(Thread *thread, bool compact, bool finalize)
void ReleaseLock(FreeList *freelist)
void VisitObjectsNoImagePages(ObjectVisitor *visitor) const
void UpdateMaxCapacityLocked()
SpaceUsage GetCurrentUsage() const
bool DataContains(uword addr) const
void IncreaseCapacityInWordsLocked(intptr_t increase_in_words)
bool ReachedHardThreshold() const
bool CodeContains(uword addr) const
void EvaluateAfterLoading()
void VisitRememberedCards(PredicateObjectPointerVisitor *visitor) const
friend class HeapSnapshotWriter
DART_FORCE_INLINE uword AllocateSnapshotLocked(FreeList *freelist, intptr_t size)
void ReleaseBumpAllocation()
bool ContainsUnsafe(uword addr) const
intptr_t ImageInWords() const
void SetupImagePage(void *pointer, uword size, bool is_executable)
intptr_t CapacityInWords() const
void ResumeConcurrentMarking()
intptr_t concurrent_marker_tasks() const
void YieldConcurrentMarking()
void AddRegionsToObjectSet(ObjectSet *set) const
void AbandonMarkingForShutdown()
void FreedExternal(intptr_t size)
void PrintToJSONObject(JSONObject *object) const
void VisitObjectsImagePages(ObjectVisitor *visitor) const
void set_phase(Phase val)
bool AllocatedExternal(intptr_t size)
void IncreaseCapacityInWords(intptr_t increase_in_words)
void PauseConcurrentMarking()
bool IsValidAddress(uword addr) const
bool IsObjectFromImagePages(ObjectPtr object)
void ResetProgressBars() const
void AssistTasks(MonitorLocker *ml)
void VisitRoots(ObjectPointerVisitor *visitor)
Monitor * tasks_lock() const
void VisitObjectPointers(ObjectPointerVisitor *visitor) const
intptr_t ExternalInWords() const
GCMarker * marker() const
void set_enable_concurrent_mark(bool enable_concurrent_mark)
friend class PageSpaceController
void VisitObjectsUnsafe(ObjectVisitor *visitor) const
T load(std::memory_order order=std::memory_order_relaxed) const
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
bool compare_exchange_weak(T &expected, T desired, std::memory_order order=std::memory_order_relaxed)
RelaxedAtomic< intptr_t > external_in_words
RelaxedAtomic< intptr_t > capacity_in_words
RelaxedAtomic< intptr_t > used_in_words
def link(from_root, to_root)
constexpr intptr_t kWordSizeLog2
bool IsAllocatableViaFreeLists(intptr_t size)
const intptr_t kMaxAddrSpaceInWords
DECLARE_FLAG(bool, show_invisible_frames)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set