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

Public Member Functions

 EpilogueTask (ThreadBarrier *barrier, IsolateGroup *isolate_group, PageSpace *old_space, FreeList *freelist, EpilogueState *state)
 
void Run ()
 
void RunEnteredIsolateGroup ()
 
void Evacuate ()
 
void ForwardStoreBuffer (IncrementalForwardingVisitor *visitor)
 
void ForwardRememberedCards (IncrementalForwardingVisitor *visitor)
 
void ForwardNewSpace (IncrementalForwardingVisitor *visitor)
 
DART_NOINLINE intptr_t ForwardAndSweepNewPage (IncrementalForwardingVisitor *visitor, Page *page)
 
- 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 630 of file incremental_compactor.cc.

Constructor & Destructor Documentation

◆ EpilogueTask()

dart::EpilogueTask::EpilogueTask ( ThreadBarrier barrier,
IsolateGroup isolate_group,
PageSpace old_space,
FreeList freelist,
EpilogueState state 
)
inline

Definition at line 632 of file incremental_compactor.cc.

637 : barrier_(barrier),
638 isolate_group_(isolate_group),
639 old_space_(old_space),
640 freelist_(freelist),
641 state_(state) {}
AtkStateType state

Member Function Documentation

◆ Evacuate()

void dart::EpilogueTask::Evacuate ( )
inline

Definition at line 724 of file incremental_compactor.cc.

724 {
726
727 old_space_->AcquireLock(freelist_);
728
729 bool any_failed = false;
730 intptr_t bytes_evacuated = 0;
731 Page* page;
732 while (state_->NextEvacPage(&page)) {
733 ASSERT(page->is_evacuation_candidate());
734
735 bool page_failed = false;
736 uword start = page->object_start();
737 uword end = page->object_end();
738 uword current = start;
739 while (current < end) {
740 ObjectPtr obj = UntaggedObject::FromAddr(current);
741 intptr_t size = obj->untag()->HeapSize();
742
743 if (obj->untag()->IsMarked()) {
744 uword copied = old_space_->TryAllocatePromoLocked(freelist_, size);
745 if (copied == 0) {
746 obj->untag()->ClearIsEvacuationCandidateUnsynchronized();
747 page_failed = true;
748 any_failed = true;
749 } else {
750 ASSERT(!Page::Of(copied)->is_evacuation_candidate());
751 bytes_evacuated += size;
752 objcpy(reinterpret_cast<void*>(copied),
753 reinterpret_cast<const void*>(current), size);
754 ObjectPtr copied_obj = UntaggedObject::FromAddr(copied);
755
756 copied_obj->untag()->ClearIsEvacuationCandidateUnsynchronized();
757 if (IsTypedDataClassId(copied_obj->GetClassId())) {
758 static_cast<TypedDataPtr>(copied_obj)
759 ->untag()
760 ->RecomputeDataField();
761 }
762
764 ->set_target(copied_obj);
765 }
766 }
767
768 current += size;
769 }
770
771 if (page_failed) {
772 page->set_evacuation_candidate(false);
773 }
774 }
775
776 old_space_->ReleaseLock(freelist_);
777 old_space_->usage_.used_in_words -= (bytes_evacuated >> kWordSizeLog2);
778#if defined(SUPPORT_TIMELINE)
779 tbes.SetNumArguments(1);
780 tbes.FormatArgument(0, "bytes_evacuated", "%" Pd, bytes_evacuated);
781#endif
782
783 if (any_failed) {
784 OS::PrintErr("evacuation failed\n");
785 }
786 }
bool NextEvacPage(Page **page)
static ForwardingCorpse * AsForwarder(uword addr, intptr_t size)
Definition: become.cc:20
void set_target(ObjectPtr target)
Definition: become.h:28
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
DART_FORCE_INLINE uword TryAllocatePromoLocked(FreeList *freelist, intptr_t size)
Definition: pages.h:151
void AcquireLock(FreeList *freelist)
Definition: pages.cc:432
void ReleaseLock(FreeList *freelist)
Definition: pages.cc:436
static Page * Of(ObjectPtr obj)
Definition: page.h:162
RelaxedAtomic< intptr_t > used_in_words
Definition: spaces.h:21
static Thread * Current()
Definition: thread.h:362
static ObjectPtr FromAddr(uword addr)
Definition: raw_object.h:516
#define ASSERT(E)
glong glong end
bool IsTypedDataClassId(intptr_t index)
Definition: class_id.h:433
constexpr intptr_t kWordSizeLog2
Definition: globals.h:507
uintptr_t uword
Definition: globals.h:501
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558
static void objcpy(void *dst, const void *src, size_t size)
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 Pd
Definition: globals.h:408
#define TIMELINE_FUNCTION_GC_DURATION(thread, name)
Definition: timeline.h:41

◆ ForwardAndSweepNewPage()

DART_NOINLINE intptr_t dart::EpilogueTask::ForwardAndSweepNewPage ( IncrementalForwardingVisitor visitor,
Page page 
)
inline

Definition at line 822 of file incremental_compactor.cc.

823 {
824 ASSERT(!page->is_image());
825 ASSERT(!page->is_old());
826 ASSERT(!page->is_executable());
827
828 uword start = page->object_start();
829 uword end = page->object_end();
830 uword current = start;
831 intptr_t free = 0;
832 while (current < end) {
833 ObjectPtr raw_obj = UntaggedObject::FromAddr(current);
834 ASSERT(Page::Of(raw_obj) == page);
835 uword tags = raw_obj->untag()->tags();
836 intptr_t obj_size = raw_obj->untag()->HeapSize(tags);
837 if (UntaggedObject::IsMarked(tags)) {
838 raw_obj->untag()->ClearMarkBitUnsynchronized();
840 raw_obj->untag()->VisitPointers(visitor);
841 } else {
842 uword free_end = current + obj_size;
843 while (free_end < end) {
844 ObjectPtr next_obj = UntaggedObject::FromAddr(free_end);
845 tags = next_obj->untag()->tags();
846 if (UntaggedObject::IsMarked(tags)) {
847 // Reached the end of the free block.
848 break;
849 }
850 // Expand the free block by the size of this object.
851 free_end += next_obj->untag()->HeapSize(tags);
852 }
853 obj_size = free_end - current;
854#if defined(DEBUG)
855 memset(reinterpret_cast<void*>(current), Heap::kZapByte, obj_size);
856#endif // DEBUG
857 FreeListElement::AsElementNew(current, obj_size);
858 free += obj_size;
859 }
860 current += obj_size;
861 }
862 return free;
863 }
static FreeListElement * AsElementNew(uword addr, intptr_t size)
Definition: freelist.cc:43
static constexpr uint8_t kZapByte
Definition: heap.h:58
bool IsMarked() const
Definition: raw_object.h:304
bool IsAllocatableInNewSpace(intptr_t size)
Definition: spaces.h:57

◆ ForwardNewSpace()

void dart::EpilogueTask::ForwardNewSpace ( IncrementalForwardingVisitor visitor)
inline

Definition at line 812 of file incremental_compactor.cc.

812 {
814 Page* page;
815 while (state_->NextNewPage(&page)) {
816 intptr_t free = ForwardAndSweepNewPage(visitor, page);
817 state_->AddNewFreeSize(free);
818 }
819 }
bool NextNewPage(Page **page)
void AddNewFreeSize(intptr_t size)
DART_NOINLINE intptr_t ForwardAndSweepNewPage(IncrementalForwardingVisitor *visitor, Page *page)

◆ ForwardRememberedCards()

void dart::EpilogueTask::ForwardRememberedCards ( IncrementalForwardingVisitor visitor)
inline

Definition at line 804 of file incremental_compactor.cc.

804 {
805 TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "ForwardRememberedCards");
806 for (Page* page = old_space_->large_pages_; page != nullptr;
807 page = page->next()) {
808 page->VisitRememberedCards(visitor, /*only_marked*/ true);
809 }
810 }

◆ ForwardStoreBuffer()

void dart::EpilogueTask::ForwardStoreBuffer ( IncrementalForwardingVisitor visitor)
inline

Definition at line 788 of file incremental_compactor.cc.

788 {
789 TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "ForwardStoreBuffer");
790
791 StoreBufferForwardingVisitor store_visitor(isolate_group_, visitor);
792 StoreBuffer* store_buffer = isolate_group_->store_buffer();
793 StoreBufferBlock* block;
794 while (state_->NextBlock(&block)) {
795 // Generated code appends to store buffers; tell MemorySanitizer.
796 MSAN_UNPOISON(block, sizeof(*block));
797
798 block->VisitObjectPointers(&store_visitor);
799
800 store_buffer->PushBlock(block, StoreBuffer::kIgnoreThreshold);
801 }
802 }
bool NextBlock(StoreBufferBlock **block)
StoreBuffer * store_buffer() const
Definition: isolate.h:509
#define MSAN_UNPOISON(ptr, len)
StoreBuffer::Block StoreBufferBlock

◆ Run()

void dart::EpilogueTask::Run ( )
inlinevirtual

Implements dart::ThreadPool::Task.

Definition at line 643 of file incremental_compactor.cc.

643 {
645 isolate_group_, Thread::kIncrementalCompactorTask,
646 /*bypass_safepoint=*/true);
647 ASSERT(result);
648
650
651 Thread::ExitIsolateGroupAsHelper(/*bypass_safepoint=*/true);
652
653 barrier_->Sync();
654 barrier_->Release();
655 }
@ kIncrementalCompactorTask
Definition: thread.h:354
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
GAsyncResult * result

◆ RunEnteredIsolateGroup()

void dart::EpilogueTask::RunEnteredIsolateGroup ( )
inline

Definition at line 657 of file incremental_compactor.cc.

657 {
658 Thread* thread = Thread::Current();
659
660 Evacuate();
661
662 barrier_->Sync();
663
664 IncrementalForwardingVisitor visitor(thread);
665 if (state_->TakeOOM()) {
666 old_space_->VisitRoots(&visitor); // OOM reservation.
667 }
668 ForwardStoreBuffer(&visitor);
669 ForwardRememberedCards(&visitor);
670 ForwardNewSpace(&visitor);
671 if (state_->TakeWeakHandles()) {
672 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakPersistentHandles");
673 isolate_group_->VisitWeakPersistentHandles(&visitor);
674 }
675 if (state_->TakeWeakTables()) {
676 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakTables");
677 isolate_group_->heap()->ForwardWeakTables(&visitor);
678 }
679#ifndef PRODUCT
680 if (state_->TakeIdRing()) {
681 TIMELINE_FUNCTION_GC_DURATION(thread, "IdRing");
682 isolate_group_->ForEachIsolate(
683 [&](Isolate* isolate) {
684 ObjectIdRing* ring = isolate->object_id_ring();
685 if (ring != nullptr) {
686 ring->VisitPointers(&visitor);
687 }
688 },
689 /*at_safepoint=*/true);
690 }
691#endif // !PRODUCT
692
693 barrier_->Sync();
694
695 {
696 // After forwarding the heap because visits each view's underyling buffer.
697 TIMELINE_FUNCTION_GC_DURATION(thread, "Views");
698 visitor.UpdateViews();
699 }
700
701 if (state_->TakeRoots()) {
702 // After forwarding the heap because visiting the stack requires stackmaps
703 // to already be forwarded.
704 TIMELINE_FUNCTION_GC_DURATION(thread, "Roots");
705 isolate_group_->VisitObjectPointers(
707 }
708
709 barrier_->Sync();
710
711 {
712 // After processing the object store because of the dependency on
713 // canonicalized_stack_map_entries.
714 TIMELINE_FUNCTION_GC_DURATION(thread, "SuspendStates");
715 visitor.UpdateSuspendStates();
716 }
717
718 if (state_->TakeResetProgressBars()) {
719 // After ForwardRememberedCards.
720 old_space_->ResetProgressBars();
721 }
722 }
void ForwardStoreBuffer(IncrementalForwardingVisitor *visitor)
void ForwardRememberedCards(IncrementalForwardingVisitor *visitor)
void ForwardNewSpace(IncrementalForwardingVisitor *visitor)
void ForwardWeakTables(ObjectPointerVisitor *visitor)
Definition: heap.cc:965
void ForEachIsolate(std::function< void(Isolate *isolate)> function, bool at_safepoint=false)
Definition: isolate.cc:2841
Heap * heap() const
Definition: isolate.h:296
void VisitObjectPointers(ObjectPointerVisitor *visitor, ValidationPolicy validate_frames)
Definition: isolate.cc:2912
void VisitWeakPersistentHandles(HandleVisitor *visitor)
Definition: isolate.cc:2998
void ResetProgressBars() const
Definition: pages.cc:716
void VisitRoots(ObjectPointerVisitor *visitor)
Definition: pages.cc:962

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