Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::Page Class Reference

#include <page.h>

Public Types

enum  PageFlags : uword {
  kExecutable = 1 << 0 , kLarge = 1 << 1 , kImage = 1 << 2 , kVMIsolate = 1 << 3 ,
  kNew = 1 << 4 , kEvacuationCandidate = 1 << 5
}
 

Public Member Functions

bool is_executable () const
 
bool is_large () const
 
bool is_image () const
 
bool is_vm_isolate () const
 
bool is_new () const
 
bool is_old () const
 
bool is_evacuation_candidate () const
 
Pagenext () const
 
void set_next (Page *next)
 
uword start () const
 
uword end () const
 
bool Contains (uword addr) const
 
uword object_start () const
 
uword old_object_start () const
 
uword new_object_start () const
 
uword object_end () const
 
intptr_t used () const
 
ForwardingPageforwarding_page () const
 
void RegisterUnwindingRecords ()
 
void UnregisterUnwindingRecords ()
 
void AllocateForwardingPage ()
 
void VisitObjects (ObjectVisitor *visitor) const
 
void VisitObjectsUnsafe (ObjectVisitor *visitor) const
 
void VisitObjectPointers (ObjectPointerVisitor *visitor) const
 
void WriteProtect (bool read_only)
 
uword original_top () const
 
uword original_end () const
 
intptr_t card_table_size () const
 
void RememberCard (ObjectPtr const *slot)
 
bool IsCardRemembered (ObjectPtr const *slot)
 
void VisitRememberedCards (ObjectPointerVisitor *visitor)
 
void ResetProgressBar ()
 
Threadowner () const
 
void RecordSurvivors ()
 
void EarlyTenure ()
 
uword promo_candidate_words () const
 
void Acquire (Thread *thread)
 
intptr_t Release (Thread *thread)
 
void Release ()
 
uword TryAllocateGC (intptr_t size)
 
void Unallocate (uword addr, intptr_t size)
 
bool IsSurvivor (uword raw_addr) const
 
bool IsResolved () const
 

Static Public Member Functions

static void Init ()
 
static void ClearCache ()
 
static intptr_t CachedSize ()
 
static void Cleanup ()
 
static constexpr intptr_t OldObjectStartOffset ()
 
static constexpr intptr_t NewObjectStartOffset ()
 
static intptr_t original_top_offset ()
 
static intptr_t original_end_offset ()
 
static PageOf (ObjectPtr obj)
 
static PageOf (uword addr)
 
static intptr_t card_table_offset ()
 

Static Public Attributes

static constexpr intptr_t kSlotsPerCardLog2 = 5
 
static constexpr intptr_t kBytesPerCardLog2
 

Friends

class CheckStoreBufferVisitor
 
class GCCompactor
 
class PageSpace
 
template<bool >
class ScavengerVisitorBase
 
class SemiSpace
 
class UnwindingRecords
 

Detailed Description

Definition at line 61 of file page.h.

Member Enumeration Documentation

◆ PageFlags

Enumerator
kExecutable 
kLarge 
kImage 
kVMIsolate 
kNew 
kEvacuationCandidate 

Definition at line 68 of file page.h.

68 : uword {
69 kExecutable = 1 << 0,
70 kLarge = 1 << 1,
71 kImage = 1 << 2,
72 kVMIsolate = 1 << 3,
73 kNew = 1 << 4,
74 kEvacuationCandidate = 1 << 5,
75 };
@ kNew
Definition page.h:73
@ kLarge
Definition page.h:70
@ kVMIsolate
Definition page.h:72
@ kExecutable
Definition page.h:69
@ kEvacuationCandidate
Definition page.h:74
@ kImage
Definition page.h:71
uintptr_t uword
Definition globals.h:501

Member Function Documentation

◆ Acquire()

void dart::Page::Acquire ( Thread thread)
inline

Definition at line 192 of file page.h.

192 {
193 ASSERT(owner_ == nullptr);
194 owner_ = thread;
195 ASSERT(thread->top() == 0);
196 ASSERT(thread->end() == 0);
197 thread->set_top(top_);
198 thread->set_end(end_);
199 thread->set_true_end(end_);
200 }
#define ASSERT(E)

◆ AllocateForwardingPage()

void dart::Page::AllocateForwardingPage ( )

Definition at line 112 of file compactor.cc.

112 {
113 ASSERT(forwarding_page_ == nullptr);
114 ASSERT((object_start() + sizeof(ForwardingPage)) < object_end());
115 ASSERT(Utils::IsAligned(sizeof(ForwardingPage), kObjectAlignment));
116 top_ -= sizeof(ForwardingPage);
117 forwarding_page_ = reinterpret_cast<ForwardingPage*>(top_.load());
118}
uword object_start() const
Definition page.h:93
uword object_end() const
Definition page.h:102
T load(std::memory_order order=std::memory_order_relaxed) const
Definition atomic.h:21
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:77
static constexpr intptr_t kObjectAlignment

◆ CachedSize()

intptr_t dart::Page::CachedSize ( )
static

Definition at line 51 of file page.cc.

51 {
52 MutexLocker ml(page_cache_mutex);
54}
static Mutex * page_cache_mutex
Definition page.cc:27
static constexpr intptr_t kPageSize
Definition page.h:27
static intptr_t page_cache_size
Definition page.cc:29

◆ card_table_offset()

static intptr_t dart::Page::card_table_offset ( )
inlinestatic

Definition at line 160 of file page.h.

160{ return OFFSET_OF(Page, card_table_); }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ card_table_size()

intptr_t dart::Page::card_table_size ( ) const
inline

Definition at line 156 of file page.h.

156 {
157 return memory_->size() >> kBytesPerCardLog2;
158 }
static constexpr intptr_t kBytesPerCardLog2
Definition page.h:153
intptr_t size() const

◆ Cleanup()

void dart::Page::Cleanup ( )
static

Definition at line 45 of file page.cc.

45 {
46 ClearCache();
47 delete page_cache_mutex;
48 page_cache_mutex = nullptr;
49}
static void ClearCache()
Definition page.cc:36

◆ ClearCache()

void dart::Page::ClearCache ( )
static

Definition at line 36 of file page.cc.

36 {
37 MutexLocker ml(page_cache_mutex);
40 while (page_cache_size > 0) {
42 }
43}
static VirtualMemory * page_cache[kPageCacheCapacity]
Definition page.cc:28
static constexpr intptr_t kPageCacheCapacity
Definition page.cc:26

◆ Contains()

bool dart::Page::Contains ( uword  addr) const
inline

Definition at line 91 of file page.h.

91{ return memory_->Contains(addr); }
bool Contains(uword addr) const

◆ EarlyTenure()

void dart::Page::EarlyTenure ( )
inline

Definition at line 186 of file page.h.

186{ survivor_end_ = end_; }

◆ end()

uword dart::Page::end ( ) const
inline

Definition at line 90 of file page.h.

90{ return memory_->end(); }

◆ forwarding_page()

ForwardingPage * dart::Page::forwarding_page ( ) const
inline

Definition at line 108 of file page.h.

108{ return forwarding_page_; }

◆ Init()

void dart::Page::Init ( )
static

Definition at line 31 of file page.cc.

31 {
32 ASSERT(page_cache_mutex == nullptr);
33 page_cache_mutex = new Mutex(NOT_IN_PRODUCT("page_cache_mutex"));
34}
#define NOT_IN_PRODUCT(code)
Definition globals.h:84

◆ is_evacuation_candidate()

bool dart::Page::is_evacuation_candidate ( ) const
inline

Definition at line 82 of file page.h.

82 {
83 return (flags_ & kEvacuationCandidate) != 0;
84 }

◆ is_executable()

bool dart::Page::is_executable ( ) const
inline

Definition at line 76 of file page.h.

76{ return (flags_ & kExecutable) != 0; }

◆ is_image()

bool dart::Page::is_image ( ) const
inline

Definition at line 78 of file page.h.

78{ return (flags_ & kImage) != 0; }

◆ is_large()

bool dart::Page::is_large ( ) const
inline

Definition at line 77 of file page.h.

77{ return (flags_ & kLarge) != 0; }

◆ is_new()

bool dart::Page::is_new ( ) const
inline

Definition at line 80 of file page.h.

80{ return (flags_ & kNew) != 0; }

◆ is_old()

bool dart::Page::is_old ( ) const
inline

Definition at line 81 of file page.h.

81{ return !is_new(); }
bool is_new() const
Definition page.h:80

◆ is_vm_isolate()

bool dart::Page::is_vm_isolate ( ) const
inline

Definition at line 79 of file page.h.

79{ return (flags_ & kVMIsolate) != 0; }

◆ IsCardRemembered()

bool dart::Page::IsCardRemembered ( ObjectPtr const *  slot)
inline

Definition at line 165 of file page.h.

165 {
166 return IsCardRemembered(reinterpret_cast<uword>(slot));
167 }
bool IsCardRemembered(ObjectPtr const *slot)
Definition page.h:165

◆ IsResolved()

bool dart::Page::IsResolved ( ) const
inline

Definition at line 248 of file page.h.

248{ return top_ == resolved_top_; }

◆ IsSurvivor()

bool dart::Page::IsSurvivor ( uword  raw_addr) const
inline

Definition at line 247 of file page.h.

247{ return raw_addr < survivor_end_; }

◆ new_object_start()

uword dart::Page::new_object_start ( ) const
inline

Definition at line 99 of file page.h.

99 {
100 return memory_->start() + NewObjectStartOffset();
101 }
static constexpr intptr_t NewObjectStartOffset()
Definition page.h:123
uword start() const

◆ NewObjectStartOffset()

static constexpr intptr_t dart::Page::NewObjectStartOffset ( )
inlinestaticconstexpr

Definition at line 123 of file page.h.

123 {
124 // Note weaker alignment because the bool/null offset tricks don't apply to
125 // new-space.
126 return Utils::RoundUp(sizeof(Page), kObjectAlignment,
128 }
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:105
static constexpr intptr_t kNewObjectAlignmentOffset

◆ next()

Page * dart::Page::next ( ) const
inline

Definition at line 86 of file page.h.

86{ return next_; }

◆ object_end()

uword dart::Page::object_end ( ) const
inline

Definition at line 102 of file page.h.

102 {
103 if (owner_ != nullptr) return owner_->top();
104 return top_;
105 }
uword top() const
Definition thread.h:696

◆ object_start()

uword dart::Page::object_start ( ) const
inline

Definition at line 93 of file page.h.

93 {
95 }
uword new_object_start() const
Definition page.h:99
uword old_object_start() const
Definition page.h:96

◆ Of() [1/2]

static Page * dart::Page::Of ( ObjectPtr  obj)
inlinestatic

Definition at line 141 of file page.h.

141 {
142 ASSERT(obj->IsHeapObject());
143 return reinterpret_cast<Page*>(static_cast<uword>(obj) & kPageMask);
144 }
static constexpr intptr_t kPageMask
Definition page.h:29

◆ Of() [2/2]

static Page * dart::Page::Of ( uword  addr)
inlinestatic

Definition at line 147 of file page.h.

147 {
148 return reinterpret_cast<Page*>(addr & kPageMask);
149 }

◆ old_object_start()

uword dart::Page::old_object_start ( ) const
inline

Definition at line 96 of file page.h.

96 {
97 return memory_->start() + OldObjectStartOffset();
98 }
static constexpr intptr_t OldObjectStartOffset()
Definition page.h:119

◆ OldObjectStartOffset()

static constexpr intptr_t dart::Page::OldObjectStartOffset ( )
inlinestaticconstexpr

Definition at line 119 of file page.h.

119 {
120 return Utils::RoundUp(sizeof(Page), kObjectStartAlignment,
122 }
static constexpr intptr_t kOldObjectAlignmentOffset
static constexpr intptr_t kObjectStartAlignment

◆ original_end()

uword dart::Page::original_end ( ) const
inline

Definition at line 134 of file page.h.

134{ return end_.load(std::memory_order_relaxed); }

◆ original_end_offset()

static intptr_t dart::Page::original_end_offset ( )
inlinestatic

Definition at line 136 of file page.h.

136{ return OFFSET_OF(Page, end_); }

◆ original_top()

uword dart::Page::original_top ( ) const
inline

Definition at line 133 of file page.h.

133{ return top_.load(std::memory_order_acquire); }

◆ original_top_offset()

static intptr_t dart::Page::original_top_offset ( )
inlinestatic

Definition at line 135 of file page.h.

135{ return OFFSET_OF(Page, top_); }

◆ owner()

Thread * dart::Page::owner ( ) const
inline

Definition at line 179 of file page.h.

179{ return owner_; }

◆ promo_candidate_words()

uword dart::Page::promo_candidate_words ( ) const
inline

Definition at line 188 of file page.h.

188 {
189 return (survivor_end_ - object_start()) / kWordSize;
190 }
constexpr intptr_t kWordSize
Definition globals.h:509

◆ RecordSurvivors()

void dart::Page::RecordSurvivors ( )
inline

Definition at line 182 of file page.h.

182{ survivor_end_ = object_end(); }

◆ RegisterUnwindingRecords()

void dart::Page::RegisterUnwindingRecords ( )

◆ Release() [1/2]

void dart::Page::Release ( )
inline

Definition at line 216 of file page.h.

216 {
217 if (owner_ != nullptr) {
218 Release(owner_);
219 }
220 }
void Release()
Definition page.h:216

◆ Release() [2/2]

intptr_t dart::Page::Release ( Thread thread)
inline

Definition at line 201 of file page.h.

201 {
202 ASSERT(owner_ == thread);
203 owner_ = nullptr;
204 uword old_top = top_;
205 uword new_top = thread->top();
206 top_.store(new_top, std::memory_order_release);
207 thread->set_top(0);
208 thread->set_end(0);
209 thread->set_true_end(0);
210#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
211 thread->heap_sampler().HandleReleasedTLAB(Thread::Current());
212#endif
213 ASSERT(new_top >= old_top);
214 return new_top - old_top;
215 }
void store(T arg, std::memory_order order=std::memory_order_relaxed)
Definition atomic.h:27
static Thread * Current()
Definition thread.h:361

◆ RememberCard()

void dart::Page::RememberCard ( ObjectPtr const *  slot)
inline

Definition at line 162 of file page.h.

162 {
163 RememberCard(reinterpret_cast<uword>(slot));
164 }
void RememberCard(ObjectPtr const *slot)
Definition page.h:162

◆ ResetProgressBar()

void dart::Page::ResetProgressBar ( )

Definition at line 278 of file page.cc.

278 {
279 progress_bar_ = 0;
280}

◆ set_next()

void dart::Page::set_next ( Page next)
inline

Definition at line 87 of file page.h.

87{ next_ = next; }
Page * next() const
Definition page.h:86

◆ start()

uword dart::Page::start ( ) const
inline

Definition at line 89 of file page.h.

89{ return memory_->start(); }

◆ TryAllocateGC()

uword dart::Page::TryAllocateGC ( intptr_t  size)
inline

Definition at line 222 of file page.h.

222 {
223 ASSERT(owner_ == nullptr);
224 uword result = top_;
225 uword new_top = result + size;
226 if (LIKELY(new_top <= end_)) {
227 top_ = new_top;
228 return result;
229 }
230 return 0;
231 }
GAsyncResult * result
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 LIKELY(cond)
Definition globals.h:260

◆ Unallocate()

void dart::Page::Unallocate ( uword  addr,
intptr_t  size 
)
inline

Definition at line 233 of file page.h.

233 {
234 ASSERT((addr + size) == top_);
235
236#if defined(DEBUG)
237 uword* cursor = reinterpret_cast<uword*>(addr);
238 uword* end = reinterpret_cast<uword*>(addr + size);
239 while (cursor < end) {
240 *cursor++ = kAllocationCanary;
241 }
242#endif
243
244 top_ -= size;
245 }
uword end() const
Definition page.h:90
static constexpr intptr_t kAllocationCanary
Definition globals.h:181

◆ UnregisterUnwindingRecords()

void dart::Page::UnregisterUnwindingRecords ( )

◆ used()

intptr_t dart::Page::used ( ) const
inline

Definition at line 106 of file page.h.

106{ return object_end() - object_start(); }

◆ VisitObjectPointers()

void dart::Page::VisitObjectPointers ( ObjectPointerVisitor visitor) const

Definition at line 196 of file page.cc.

196 {
197 ASSERT(Thread::Current()->OwnsGCSafepoint() ||
198 (Thread::Current()->task_kind() == Thread::kCompactorTask) ||
199 (Thread::Current()->task_kind() == Thread::kMarkerTask));
200 NoSafepointScope no_safepoint;
201 uword obj_addr = object_start();
202 uword end_addr = object_end();
203 while (obj_addr < end_addr) {
204 ObjectPtr raw_obj = UntaggedObject::FromAddr(obj_addr);
205 obj_addr += raw_obj->untag()->VisitPointers(visitor);
206 }
207 ASSERT(obj_addr == end_addr);
208}
@ kCompactorTask
Definition thread.h:351
static ObjectPtr FromAddr(uword addr)
Definition raw_object.h:495

◆ VisitObjects()

void dart::Page::VisitObjects ( ObjectVisitor visitor) const

Definition at line 173 of file page.cc.

173 {
174 ASSERT(Thread::Current()->OwnsGCSafepoint());
175 NoSafepointScope no_safepoint;
176 uword obj_addr = object_start();
177 uword end_addr = object_end();
178 while (obj_addr < end_addr) {
179 ObjectPtr raw_obj = UntaggedObject::FromAddr(obj_addr);
180 visitor->VisitObject(raw_obj);
181 obj_addr += raw_obj->untag()->HeapSize();
182 }
183 ASSERT(obj_addr == end_addr);
184}

◆ VisitObjectsUnsafe()

void dart::Page::VisitObjectsUnsafe ( ObjectVisitor visitor) const

Definition at line 186 of file page.cc.

186 {
187 uword obj_addr = object_start();
188 uword end_addr = object_end();
189 while (obj_addr < end_addr) {
190 ObjectPtr raw_obj = UntaggedObject::FromAddr(obj_addr);
191 visitor->VisitObject(raw_obj);
192 obj_addr += raw_obj->untag()->HeapSize();
193 }
194}

◆ VisitRememberedCards()

void dart::Page::VisitRememberedCards ( ObjectPointerVisitor visitor)

Definition at line 210 of file page.cc.

210 {
211 ASSERT(Thread::Current()->OwnsGCSafepoint() ||
212 (Thread::Current()->task_kind() == Thread::kScavengerTask));
213 NoSafepointScope no_safepoint;
214
215 if (card_table_ == nullptr) {
216 return;
217 }
218
219 ArrayPtr obj =
220 static_cast<ArrayPtr>(UntaggedObject::FromAddr(object_start()));
221 ASSERT(obj->IsArray() || obj->IsImmutableArray());
222 ASSERT(obj->untag()->IsCardRemembered());
223 CompressedObjectPtr* obj_from = obj->untag()->from();
224 CompressedObjectPtr* obj_to =
225 obj->untag()->to(Smi::Value(obj->untag()->length()));
226 uword heap_base = obj.heap_base();
227
228 const size_t size_in_bits = card_table_size();
229 const size_t size_in_words =
231 for (;;) {
232 const size_t word_offset = progress_bar_.fetch_add(1);
233 if (word_offset >= size_in_words) break;
234
235 uword cell = card_table_[word_offset];
236 if (cell == 0) continue;
237
238 for (intptr_t bit_offset = 0; bit_offset < kBitsPerWord; bit_offset++) {
239 const uword bit_mask = static_cast<uword>(1) << bit_offset;
240 if ((cell & bit_mask) == 0) continue;
241 const intptr_t i = (word_offset << kBitsPerWordLog2) + bit_offset;
242
243 CompressedObjectPtr* card_from =
244 reinterpret_cast<CompressedObjectPtr*>(this) +
245 (i << kSlotsPerCardLog2);
246 CompressedObjectPtr* card_to =
247 reinterpret_cast<CompressedObjectPtr*>(card_from) +
248 (1 << kSlotsPerCardLog2) - 1;
249 // Minus 1 because to is inclusive.
250
251 if (card_from < obj_from) {
252 // First card overlaps with header.
253 card_from = obj_from;
254 }
255 if (card_to > obj_to) {
256 // Last card(s) may extend past the object. Array truncation can make
257 // this happen for more than one card.
258 card_to = obj_to;
259 }
260
261 visitor->VisitCompressedPointers(heap_base, card_from, card_to);
262
263 bool has_new_target = false;
264 for (CompressedObjectPtr* slot = card_from; slot <= card_to; slot++) {
265 if ((*slot)->IsNewObjectMayBeSmi()) {
266 has_new_target = true;
267 break;
268 }
269 }
270 if (!has_new_target) {
271 cell ^= bit_mask;
272 }
273 }
274 card_table_[word_offset] = cell;
275 }
276}
UntaggedObject * untag() const
intptr_t card_table_size() const
Definition page.h:156
static constexpr intptr_t kSlotsPerCardLog2
Definition page.h:152
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
Definition atomic.h:35
intptr_t Value() const
Definition object.h:9969
@ kScavengerTask
Definition thread.h:352
uword heap_base() const
Definition raw_object.h:569
constexpr intptr_t kBitsPerWordLog2
Definition globals.h:513
constexpr intptr_t kBitsPerWord
Definition globals.h:514
ObjectPtr CompressedObjectPtr

◆ WriteProtect()

void dart::Page::WriteProtect ( bool  read_only)

Definition at line 282 of file page.cc.

282 {
283 ASSERT(!is_image());
284
286 if (read_only) {
287 if (is_executable()) {
289 } else {
291 }
292 } else {
294 }
295 memory_->Protect(prot);
296}
bool is_image() const
Definition page.h:78
bool is_executable() const
Definition page.h:76
static void Protect(void *address, intptr_t size, Protection mode)

Friends And Related Symbol Documentation

◆ CheckStoreBufferVisitor

friend class CheckStoreBufferVisitor
friend

Definition at line 319 of file page.h.

◆ GCCompactor

friend class GCCompactor
friend

Definition at line 320 of file page.h.

◆ PageSpace

friend class PageSpace
friend

Definition at line 321 of file page.h.

◆ ScavengerVisitorBase

template<bool >
friend class ScavengerVisitorBase
friend

Definition at line 323 of file page.h.

◆ SemiSpace

friend class SemiSpace
friend

Definition at line 324 of file page.h.

◆ UnwindingRecords

friend class UnwindingRecords
friend

Definition at line 325 of file page.h.

Member Data Documentation

◆ kBytesPerCardLog2

constexpr intptr_t dart::Page::kBytesPerCardLog2
staticconstexpr
Initial value:
=
static constexpr intptr_t kCompressedWordSizeLog2
Definition globals.h:43

Definition at line 153 of file page.h.

◆ kSlotsPerCardLog2

constexpr intptr_t dart::Page::kSlotsPerCardLog2 = 5
staticconstexpr

Definition at line 152 of file page.h.


The documentation for this class was generated from the following files: