Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::ParallelScavengerTask Class Reference
Inheritance diagram for dart::ParallelScavengerTask:
dart::ThreadPool::Task dart::IntrusiveDListEntry< Task >

Public Member Functions

 ParallelScavengerTask (IsolateGroup *isolate_group, ThreadBarrier *barrier, ParallelScavengerVisitor *visitor, RelaxedAtomic< uintptr_t > *num_busy)
 
virtual void Run ()
 
void RunEnteredIsolateGroup ()
 
- Public Member Functions inherited from dart::ThreadPool::Task
virtual ~Task ()
 
virtual void Run ()=0
 
- Public Member Functions inherited from dart::IntrusiveDListEntry< Task >
 IntrusiveDListEntry ()
 
 ~IntrusiveDListEntry ()
 

Additional Inherited Members

- Protected Member Functions inherited from dart::ThreadPool::Task
 Task ()
 

Detailed Description

Definition at line 672 of file scavenger.cc.

Constructor & Destructor Documentation

◆ ParallelScavengerTask()

dart::ParallelScavengerTask::ParallelScavengerTask ( IsolateGroup isolate_group,
ThreadBarrier barrier,
ParallelScavengerVisitor visitor,
RelaxedAtomic< uintptr_t > *  num_busy 
)
inline

Definition at line 674 of file scavenger.cc.

678 : isolate_group_(isolate_group),
679 barrier_(barrier),
680 visitor_(visitor),
681 num_busy_(num_busy) {}

Member Function Documentation

◆ Run()

virtual void dart::ParallelScavengerTask::Run ( )
inlinevirtual

Implements dart::ThreadPool::Task.

Definition at line 683 of file scavenger.cc.

683 {
684 if (!barrier_->TryEnter()) {
685 barrier_->Release();
686 return;
687 }
688
690 isolate_group_, Thread::kScavengerTask, /*bypass_safepoint=*/true);
691 ASSERT(result);
692
694
695 Thread::ExitIsolateGroupAsHelper(/*bypass_safepoint=*/true);
696
697 barrier_->Sync();
698 barrier_->Release();
699 }
@ kScavengerTask
Definition: thread.h:352
static void ExitIsolateGroupAsHelper(bool bypass_safepoint)
Definition: thread.cc:499
static bool EnterIsolateGroupAsHelper(IsolateGroup *isolate_group, TaskKind kind, bool bypass_safepoint)
Definition: thread.cc:481
#define ASSERT(E)
GAsyncResult * result

◆ RunEnteredIsolateGroup()

void dart::ParallelScavengerTask::RunEnteredIsolateGroup ( )
inline

Definition at line 701 of file scavenger.cc.

701 {
702 TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "ParallelScavenge");
703
704 num_busy_->fetch_add(1u);
705 visitor_->ProcessRoots();
706
707 // Phase 1: Copying.
708 bool more_to_scavenge = false;
709 do {
710 do {
711 visitor_->ProcessSurvivors();
712 } while (visitor_->WaitForWork(num_busy_));
713 // Wait for all scavengers to stop.
714 barrier_->Sync();
715#if defined(DEBUG)
716 ASSERT(num_busy_->load() == 0);
717 // Caveat: must not allow any marker to continue past the barrier
718 // before we checked num_busy, otherwise one of them might rush
719 // ahead and increment it.
720 barrier_->Sync();
721#endif
722 // Check if we have any pending properties with marked keys.
723 // Those might have been marked by another marker.
724 visitor_->ProcessWeakProperties();
725 more_to_scavenge = visitor_->HasWork();
726 if (more_to_scavenge) {
727 // We have more work to do. Notify others.
728 num_busy_->fetch_add(1u);
729 }
730
731 // Wait for all other scavengers to finish processing their pending
732 // weak properties and decide if they need to continue marking.
733 // Caveat: we need two barriers here to make this decision in lock step
734 // between all scavengers and the main thread.
735 barrier_->Sync();
736 if (!more_to_scavenge && (num_busy_->load() > 0)) {
737 // All scavengers continue to mark as long as any single marker has
738 // some work to do.
739 num_busy_->fetch_add(1u);
740 more_to_scavenge = true;
741 }
742 barrier_->Sync();
743 } while (more_to_scavenge);
744
745 ASSERT(!visitor_->HasWork());
746
747 // Phase 2: Weak processing, statistics.
748 visitor_->ProcessWeak();
749 }
T load(std::memory_order order=std::memory_order_relaxed) const
Definition: atomic.h:21
T fetch_add(T arg, std::memory_order order=std::memory_order_relaxed)
Definition: atomic.h:35
bool WaitForWork(RelaxedAtomic< uintptr_t > *num_busy)
Definition: scavenger.cc:335
static Thread * Current()
Definition: thread.h:362
#define TIMELINE_FUNCTION_GC_DURATION(thread, name)
Definition: timeline.h:41

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