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

Public Member Functions

 ParallelMarkTask (GCMarker *marker, IsolateGroup *isolate_group, MarkingStack *marking_stack, ThreadBarrier *barrier, SyncMarkingVisitor *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 890 of file marker.cc.

Constructor & Destructor Documentation

◆ ParallelMarkTask()

dart::ParallelMarkTask::ParallelMarkTask ( GCMarker marker,
IsolateGroup isolate_group,
MarkingStack marking_stack,
ThreadBarrier barrier,
SyncMarkingVisitor visitor,
RelaxedAtomic< uintptr_t > *  num_busy 
)
inline

Definition at line 892 of file marker.cc.

898 : marker_(marker),
899 isolate_group_(isolate_group),
900 marking_stack_(marking_stack),
901 barrier_(barrier),
902 visitor_(visitor),
903 num_busy_(num_busy) {}
static const char marker[]

Member Function Documentation

◆ Run()

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

Implements dart::ThreadPool::Task.

Definition at line 905 of file marker.cc.

905 {
906 if (!barrier_->TryEnter()) {
907 barrier_->Release();
908 return;
909 }
910
912 isolate_group_, Thread::kMarkerTask, /*bypass_safepoint=*/true);
913 ASSERT(result);
914
916
917 Thread::ExitIsolateGroupAsHelper(/*bypass_safepoint=*/true);
918
919 barrier_->Sync();
920 barrier_->Release();
921 }
void RunEnteredIsolateGroup()
Definition: marker.cc:923
@ kMarkerTask
Definition: thread.h:349
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::ParallelMarkTask::RunEnteredIsolateGroup ( )
inline

Definition at line 923 of file marker.cc.

923 {
924 {
925 Thread* thread = Thread::Current();
926 TIMELINE_FUNCTION_GC_DURATION(thread, "ParallelMark");
928
929 // Phase 1: Iterate over roots and drain marking stack in tasks.
930 num_busy_->fetch_add(1u);
931 visitor_->set_concurrent(false);
932 marker_->IterateRoots(visitor_);
933 visitor_->FinishedRoots();
934
935 visitor_->ProcessDeferredMarking();
936
937 bool more_to_mark = false;
938 do {
939 do {
940 visitor_->DrainMarkingStack();
941 } while (visitor_->WaitForWork(num_busy_));
942 // Wait for all markers to stop.
943 barrier_->Sync();
944#if defined(DEBUG)
945 ASSERT(num_busy_->load() == 0);
946 // Caveat: must not allow any marker to continue past the barrier
947 // before we checked num_busy, otherwise one of them might rush
948 // ahead and increment it.
949 barrier_->Sync();
950#endif
951 // Check if we have any pending properties with marked keys.
952 // Those might have been marked by another marker.
953 more_to_mark = visitor_->ProcessPendingWeakProperties();
954 if (more_to_mark) {
955 // We have more work to do. Notify others.
956 num_busy_->fetch_add(1u);
957 }
958
959 // Wait for all other markers to finish processing their pending
960 // weak properties and decide if they need to continue marking.
961 // Caveat: we need two barriers here to make this decision in lock step
962 // between all markers and the main thread.
963 barrier_->Sync();
964 if (!more_to_mark && (num_busy_->load() > 0)) {
965 // All markers continue to mark as long as any single marker has
966 // some work to do.
967 num_busy_->fetch_add(1u);
968 more_to_mark = true;
969 }
970 barrier_->Sync();
971 } while (more_to_mark);
972
973 // Phase 2: deferred marking.
974 visitor_->ProcessDeferredMarking();
975 barrier_->Sync();
976
977 // Phase 3: Weak processing and statistics.
978 visitor_->MournWeakProperties();
979 visitor_->MournWeakReferences();
980 visitor_->MournWeakArrays();
981 // Don't MournFinalizerEntries here, do it on main thread, so that we
982 // don't have to coordinate workers.
983
984 thread->ReleaseStoreBuffer(); // Ahead of IterateWeak
985 barrier_->Sync();
986 marker_->IterateWeakRoots(thread);
987 int64_t stop = OS::GetCurrentMonotonicMicros();
988 visitor_->AddMicros(stop - start);
989 if (FLAG_log_marker_tasks) {
990 THR_Print("Task marked %" Pd " bytes in %" Pd64 " micros.\n",
991 visitor_->marked_bytes(), visitor_->marked_micros());
992 }
993 }
994 }
void AddMicros(int64_t micros)
Definition: marker.cc:50
uintptr_t marked_bytes() const
Definition: marker.cc:48
void ProcessDeferredMarking()
Definition: marker.cc:459
int64_t marked_micros() const
Definition: marker.cc:49
void set_concurrent(bool value)
Definition: marker.cc:51
bool ProcessPendingWeakProperties()
Definition: marker.cc:67
bool WaitForWork(RelaxedAtomic< uintptr_t > *num_busy)
Definition: marker.cc:588
static int64_t GetCurrentMonotonicMicros()
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
static Thread * Current()
Definition: thread.h:362
#define THR_Print(format,...)
Definition: log.h:20
#define Pd64
Definition: globals.h:416
#define Pd
Definition: globals.h:408
#define TIMELINE_FUNCTION_GC_DURATION(thread, name)
Definition: timeline.h:41

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