Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 ()
 
- 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 765 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 767 of file marker.cc.

773 : marker_(marker),
774 isolate_group_(isolate_group),
775 marking_stack_(marking_stack),
776 barrier_(barrier),
777 visitor_(visitor),
778 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 780 of file marker.cc.

780 {
781 if (!barrier_->TryEnter()) {
782 barrier_->Release();
783 return;
784 }
785
787 isolate_group_, Thread::kMarkerTask, /*bypass_safepoint=*/true);
788 ASSERT(result);
789
791
792 Thread::ExitIsolateGroupAsHelper(/*bypass_safepoint=*/true);
793
794 barrier_->Sync();
795 barrier_->Release();
796 }
void RunEnteredIsolateGroup()
Definition marker.cc:798
static void ExitIsolateGroupAsHelper(bool bypass_safepoint)
Definition thread.cc:494
static bool EnterIsolateGroupAsHelper(IsolateGroup *isolate_group, TaskKind kind, bool bypass_safepoint)
Definition thread.cc:476
#define ASSERT(E)
GAsyncResult * result

◆ RunEnteredIsolateGroup()

void dart::ParallelMarkTask::RunEnteredIsolateGroup ( )
inline

Definition at line 798 of file marker.cc.

798 {
799 {
800 Thread* thread = Thread::Current();
801 TIMELINE_FUNCTION_GC_DURATION(thread, "ParallelMark");
803
804 // Phase 1: Iterate over roots and drain marking stack in tasks.
805 num_busy_->fetch_add(1u);
806 visitor_->set_concurrent(false);
807 marker_->IterateRoots(visitor_);
808
809 visitor_->ProcessDeferredMarking();
810
811 bool more_to_mark = false;
812 do {
813 do {
814 visitor_->DrainMarkingStack();
815 } while (visitor_->WaitForWork(num_busy_));
816 // Wait for all markers to stop.
817 barrier_->Sync();
818#if defined(DEBUG)
819 ASSERT(num_busy_->load() == 0);
820 // Caveat: must not allow any marker to continue past the barrier
821 // before we checked num_busy, otherwise one of them might rush
822 // ahead and increment it.
823 barrier_->Sync();
824#endif
825 // Check if we have any pending properties with marked keys.
826 // Those might have been marked by another marker.
827 more_to_mark = visitor_->ProcessPendingWeakProperties();
828 if (more_to_mark) {
829 // We have more work to do. Notify others.
830 num_busy_->fetch_add(1u);
831 }
832
833 // Wait for all other markers to finish processing their pending
834 // weak properties and decide if they need to continue marking.
835 // Caveat: we need two barriers here to make this decision in lock step
836 // between all markers and the main thread.
837 barrier_->Sync();
838 if (!more_to_mark && (num_busy_->load() > 0)) {
839 // All markers continue to mark as long as any single marker has
840 // some work to do.
841 num_busy_->fetch_add(1u);
842 more_to_mark = true;
843 }
844 barrier_->Sync();
845 } while (more_to_mark);
846
847 // Phase 2: deferred marking.
848 visitor_->ProcessDeferredMarking();
849 barrier_->Sync();
850
851 // Phase 3: Weak processing and statistics.
852 visitor_->MournWeakProperties();
853 visitor_->MournWeakReferences();
854 visitor_->MournWeakArrays();
855 // Don't MournFinalizerEntries here, do it on main thread, so that we
856 // don't have to coordinate workers.
857
858 marker_->IterateWeakRoots(thread);
859 int64_t stop = OS::GetCurrentMonotonicMicros();
860 visitor_->AddMicros(stop - start);
861 if (FLAG_log_marker_tasks) {
862 THR_Print("Task marked %" Pd " bytes in %" Pd64 " micros.\n",
863 visitor_->marked_bytes(), visitor_->marked_micros());
864 }
865 }
866 }
void AddMicros(int64_t micros)
Definition marker.cc:47
uintptr_t marked_bytes() const
Definition marker.cc:45
int64_t marked_micros() const
Definition marker.cc:46
void set_concurrent(bool value)
Definition marker.cc:48
bool ProcessPendingWeakProperties()
Definition marker.cc:59
bool WaitForWork(RelaxedAtomic< uintptr_t > *num_busy)
Definition marker.cc:434
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:361
#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: