Flutter Engine
The Flutter Engine
marker.h
Go to the documentation of this file.
1// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4
5#ifndef RUNTIME_VM_HEAP_MARKER_H_
6#define RUNTIME_VM_HEAP_MARKER_H_
7
8#include "vm/allocation.h"
9#include "vm/heap/gc_shared.h"
11#include "vm/os_thread.h" // Mutex.
12
13namespace dart {
14
15// Forward declarations.
16class HandleVisitor;
17class Heap;
18class IsolateGroup;
19class ObjectPointerVisitor;
20class PageSpace;
21template <bool sync>
22class MarkingVisitorBase;
23class Page;
24class Thread;
25
26// The class GCMarker is used to mark reachable old generation objects as part
27// of the mark-sweep collection. The marking bit used is defined in
28// UntaggedObject. Instances have a lifetime that spans from the beginning of
29// concurrent marking (or stop-the-world marking) until marking is complete. In
30// particular, an instance may be created and destroyed on different threads if
31// the isolate is exited during concurrent marking.
32class GCMarker {
33 public:
34 GCMarker(IsolateGroup* isolate_group, Heap* heap);
35 ~GCMarker();
36
37 // Mark roots synchronously, then spawn tasks to concurrently drain the
38 // marking queue. Only called when no marking or sweeping is in progress.
39 // Marking must later be finalized by calling MarkObjects.
40 void StartConcurrentMark(PageSpace* page_space);
41
42 // Contribute to marking.
44 void IncrementalMarkWithSizeBudget(PageSpace* page_space, intptr_t size);
45 void IncrementalMarkWithTimeBudget(PageSpace* page_space, int64_t deadline);
46
47 // (Re)mark roots, drain the marking queue and finalize weak references.
48 // Does not required StartConcurrentMark to have been previously called.
49 void MarkObjects(PageSpace* page_space);
50
51 intptr_t marked_words() const { return marked_bytes_ >> kWordSizeLog2; }
52 intptr_t MarkedWordsPerMicro() const;
53
54 void PruneWeak(Scavenger* scavenger);
55
56 private:
57 void Prologue();
58 void Epilogue();
59 void ResetSlices();
60 void IterateRoots(ObjectPointerVisitor* visitor);
61 void IterateWeakRoots(Thread* thread);
62 void ProcessWeakHandles(Thread* thread);
63 void ProcessWeakTables(Thread* thread);
64 void ProcessRememberedSet(Thread* thread);
65
66 // Called by anyone: finalize and accumulate stats from 'visitor'.
67 template <class MarkingVisitorType>
68 void FinalizeResultsFrom(MarkingVisitorType* visitor);
69
70 IsolateGroup* const isolate_group_;
71 Heap* const heap_;
72 // The regular marking worklists, divided by generation. The marker and the
73 // write-barrier push here. Dividing by generation allows faster filtering at
74 // the end of a scavenge.
75 MarkingStack old_marking_stack_;
76 MarkingStack new_marking_stack_;
77 // New-space objects whose scanning is being delayed because they are still in
78 // a TLAB and subject to write barrier eliminiation. Unlike
79 // [deferred_marking_stack_], the objects are always marked and never
80 // repeated. Tney can be folded back into the regular mark list after a
81 // scavenge, preventing accumulation of STW work.
82 MarkingStack tlab_deferred_marking_stack_;
83 // Objects that need to be marked (non-writable instructions) or scanned
84 // (object used in a barrier-skipping context) during the final STW phase.
85 // Unlike the other mark lists, objects might be repeated in this list, and
86 // need to be scanned even if they are already marked.
87 MarkingStack deferred_marking_stack_;
88 GCLinkedLists global_list_;
89 MarkingVisitorBase<true>** visitors_;
90
91 Monitor root_slices_monitor_;
92 RelaxedAtomic<intptr_t> root_slices_started_;
93 intptr_t root_slices_finished_;
94 intptr_t root_slices_count_;
95 RelaxedAtomic<intptr_t> weak_slices_started_;
96
97 uintptr_t marked_bytes_;
98 int64_t marked_micros_;
99
100 friend class ConcurrentMarkTask;
101 friend class ParallelMarkTask;
102 friend class Scavenger;
103 template <bool sync>
104 friend class MarkingVisitorBase;
106};
107
108} // namespace dart
109
110#endif // RUNTIME_VM_HEAP_MARKER_H_
void IncrementalMarkWithSizeBudget(PageSpace *page_space, intptr_t size)
Definition: marker.cc:1198
GCMarker(IsolateGroup *isolate_group, Heap *heap)
Definition: marker.cc:1088
intptr_t MarkedWordsPerMicro() const
Definition: marker.cc:1071
void IncrementalMarkWithTimeBudget(PageSpace *page_space, int64_t deadline)
Definition: marker.cc:1223
void PruneWeak(Scavenger *scavenger)
Definition: marker.cc:1396
void StartConcurrentMark(PageSpace *page_space)
Definition: marker.cc:1118
intptr_t marked_words() const
Definition: marker.h:51
void MarkObjects(PageSpace *page_space)
Definition: marker.cc:1291
void IncrementalMarkWithUnlimitedBudget(PageSpace *page_space)
Definition: marker.cc:1179
Definition: dart_vm.cc:33
constexpr intptr_t kWordSizeLog2
Definition: globals.h:507
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
Definition: switches.h:259
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition: globals.h:593