Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::HeapIterationScope Class Reference

#include <heap.h>

Inheritance diagram for dart::HeapIterationScope:
dart::ThreadStackResource dart::StackResource

Public Member Functions

 HeapIterationScope (Thread *thread, bool writable=false)
 
 ~HeapIterationScope ()
 
void IterateObjects (ObjectVisitor *visitor) const
 
void IterateObjectsNoImagePages (ObjectVisitor *visitor) const
 
void IterateOldObjects (ObjectVisitor *visitor) const
 
void IterateOldObjectsNoImagePages (ObjectVisitor *visitor) const
 
void IterateVMIsolateObjects (ObjectVisitor *visitor) const
 
void IterateObjectPointers (ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
 
void IterateStackPointers (ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
 
- Public Member Functions inherited from dart::ThreadStackResource
 ThreadStackResource (Thread *T)
 
 ~ThreadStackResource ()
 
Threadthread () const
 
Isolateisolate () const
 
IsolateGroupisolate_group () const
 
- Public Member Functions inherited from dart::StackResource
 StackResource (ThreadState *thread)
 
virtual ~StackResource ()
 
ThreadStatethread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::StackResource
static void Unwind (ThreadState *thread)
 
static void UnwindAbove (ThreadState *thread, StackResource *new_top)
 

Detailed Description

Definition at line 395 of file heap.h.

Constructor & Destructor Documentation

◆ HeapIterationScope()

dart::HeapIterationScope::HeapIterationScope ( Thread thread,
bool  writable = false 
)
explicit

Definition at line 273 of file heap.cc.

275 heap_(isolate_group()->heap()),
276 old_space_(heap_->old_space()),
277 writable_(writable) {
278 isolate_group()->safepoint_handler()->SafepointThreads(thread,
280
281 {
282 // It's not safe to iterate over old space when concurrent marking or
283 // sweeping is in progress, or another thread is iterating the heap, so wait
284 // for any such task to complete first.
285 MonitorLocker ml(old_space_->tasks_lock());
286#if defined(DEBUG)
287 // We currently don't support nesting of HeapIterationScopes.
288 ASSERT(old_space_->iterating_thread_ != thread);
289#endif
290 while ((old_space_->tasks() > 0) ||
291 (old_space_->phase() != PageSpace::kDone)) {
292 old_space_->AssistTasks(&ml);
293 if (old_space_->phase() == PageSpace::kAwaitingFinalization) {
294 ml.Exit();
295 heap_->CollectOldSpaceGarbage(thread, GCType::kMarkSweep,
297 ml.Enter();
298 }
299 while (old_space_->tasks() > 0) {
300 ml.Wait();
301 }
302 }
303#if defined(DEBUG)
304 ASSERT(old_space_->iterating_thread_ == nullptr);
305 old_space_->iterating_thread_ = thread;
306#endif
307 old_space_->set_tasks(1);
308 }
309
310 if (writable_) {
311 heap_->WriteProtectCode(false);
312 }
313}
PageSpace * old_space()
Definition: heap.h:63
void WriteProtectCode(bool read_only)
Definition: heap.h:127
SafepointHandler * safepoint_handler()
Definition: isolate.h:334
intptr_t tasks() const
Definition: pages.h:315
void set_tasks(intptr_t val)
Definition: pages.h:316
@ kAwaitingFinalization
Definition: pages.h:133
void AssistTasks(MonitorLocker *ml)
Definition: pages.cc:917
Monitor * tasks_lock() const
Definition: pages.h:314
Phase phase() const
Definition: pages.h:341
IsolateGroup * isolate_group() const
#define ASSERT(E)
@ kGC
Definition: thread.h:291

◆ ~HeapIterationScope()

dart::HeapIterationScope::~HeapIterationScope ( )

Definition at line 315 of file heap.cc.

315 {
316 if (writable_) {
317 heap_->WriteProtectCode(true);
318 }
319
320 {
321 MonitorLocker ml(old_space_->tasks_lock());
322#if defined(DEBUG)
323 ASSERT(old_space_->iterating_thread_ == thread());
324 old_space_->iterating_thread_ = nullptr;
325#endif
326 ASSERT(old_space_->tasks() == 1);
327 old_space_->set_tasks(0);
328 ml.NotifyAll();
329 }
330
331 isolate_group()->safepoint_handler()->ResumeThreads(thread(),
333}

Member Function Documentation

◆ IterateObjectPointers()

void dart::HeapIterationScope::IterateObjectPointers ( ObjectPointerVisitor visitor,
ValidationPolicy  validate_frames 
)

Definition at line 358 of file heap.cc.

360 {
361 isolate_group()->VisitObjectPointers(visitor, validate_frames);
362}
void VisitObjectPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
Definition: isolate.cc:2912

◆ IterateObjects()

void dart::HeapIterationScope::IterateObjects ( ObjectVisitor visitor) const

Definition at line 335 of file heap.cc.

335 {
336 heap_->VisitObjects(visitor);
337}

◆ IterateObjectsNoImagePages()

void dart::HeapIterationScope::IterateObjectsNoImagePages ( ObjectVisitor visitor) const

Definition at line 339 of file heap.cc.

340 {
341 heap_->new_space()->VisitObjects(visitor);
342 heap_->old_space()->VisitObjectsNoImagePages(visitor);
343}
Scavenger * new_space()
Definition: heap.h:62
void VisitObjectsNoImagePages(ObjectVisitor *visitor) const
Definition: pages.cc:657
void VisitObjects(ObjectVisitor *visitor) const
Definition: scavenger.cc:1784

◆ IterateOldObjects()

void dart::HeapIterationScope::IterateOldObjects ( ObjectVisitor visitor) const

Definition at line 345 of file heap.cc.

345 {
346 old_space_->VisitObjects(visitor);
347}
void VisitObjects(ObjectVisitor *visitor) const
Definition: pages.cc:651

◆ IterateOldObjectsNoImagePages()

void dart::HeapIterationScope::IterateOldObjectsNoImagePages ( ObjectVisitor visitor) const

Definition at line 349 of file heap.cc.

350 {
351 old_space_->VisitObjectsNoImagePages(visitor);
352}

◆ IterateStackPointers()

void dart::HeapIterationScope::IterateStackPointers ( ObjectPointerVisitor visitor,
ValidationPolicy  validate_frames 
)

Definition at line 364 of file heap.cc.

366 {
367 isolate_group()->VisitStackPointers(visitor, validate_frames);
368}
void VisitStackPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
Definition: isolate.cc:2970

◆ IterateVMIsolateObjects()

void dart::HeapIterationScope::IterateVMIsolateObjects ( ObjectVisitor visitor) const

Definition at line 354 of file heap.cc.

354 {
355 Dart::vm_isolate_group()->heap()->VisitObjects(visitor);
356}
static IsolateGroup * vm_isolate_group()
Definition: dart.h:69
Heap * heap() const
Definition: isolate.h:296

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