diff --git a/common_components/heap/w_collector/w_collector.cpp b/common_components/heap/w_collector/w_collector.cpp index 52564dca8441bb6bfc68237f2afa4370e4fabb02..57cb81e5af81aa8ac3231df1c6f75484c35728c1 100755 --- a/common_components/heap/w_collector/w_collector.cpp +++ b/common_components/heap/w_collector/w_collector.cpp @@ -635,84 +635,18 @@ void WCollector::DoGarbageCollection() { const bool isNotYoungGC = gcReason_ != GCReason::GC_REASON_YOUNG; OHOS_HITRACE(HITRACE_LEVEL_COMMERCIAL, "CMCGC::DoGarbageCollection", ""); - if (gcMode_ == GCMode::STW) { // 2: stw-gc -#ifdef ENABLE_CMC_RB_DFX - WVerify::DisableReadBarrierDFX(*this); -#endif - - ScopedStopTheWorld stw("stw-gc"); - auto collectedRoots = EnumRoots(); - TraceHeap(collectedRoots); - TransitionToGCPhase(GCPhase::GC_PHASE_FINAL_MARK, true); - Remark(); - PostTrace(); - - Preforward(); - ConcurrentPreforward(); - // reclaim large objects should after preforward(may process weak ref) and - // before fix heap(may clear live bit) - if (isNotYoungGC) { - CollectLargeGarbage(); - } - SweepThreadLocalJitFort(); - - CopyFromSpace(); - WVerify::VerifyAfterForward(*this); - PrepareFix(); - FixHeap(); - if (isNotYoungGC) { - CollectPinnedGarbage(); - } - - TransitionToGCPhase(GCPhase::GC_PHASE_IDLE, true); - - ClearAllGCInfo(); - CollectSmallSpace(); - -#if defined(ENABLE_CMC_RB_DFX) - WVerify::EnableReadBarrierDFX(*this); -#endif - return; - } else if (gcMode_ == GCMode::CONCURRENT_MARK) { // 1: concurrent-mark - auto collectedRoots = EnumRoots(); - TraceHeap(collectedRoots); - { - ScopedStopTheWorld stw("final-mark", true, GCPhase::GC_PHASE_FINAL_MARK); - Remark(); - PostTrace(); - reinterpret_cast(theAllocator_).PrepareForward(); - Preforward(); - } - ConcurrentPreforward(); - // reclaim large objects should after preforward(may process weak ref) and - // before fix heap(may clear live bit) - if (isNotYoungGC) { - CollectLargeGarbage(); - } - SweepThreadLocalJitFort(); - - CopyFromSpace(); - WVerify::VerifyAfterForward(*this); - - PrepareFix(); - FixHeap(); - if (isNotYoungGC) { - CollectPinnedGarbage(); - } - - TransitionToGCPhase(GCPhase::GC_PHASE_IDLE, true); - ClearAllGCInfo(); - CollectSmallSpace(); - return; - } - - auto collectedRoots = EnumRoots(); + ScopedStopTheWorld stw("stw-gc"); + auto collectedRoots = EnumRoots(); TraceHeap(collectedRoots); - PreforwardFlip(); + TransitionToGCPhase(GCPhase::GC_PHASE_FINAL_MARK, true); + Remark(); + PostTrace(); + + Preforward(); ConcurrentPreforward(); - // reclaim large objects should after preforward(may process weak ref) - // and before fix heap(may clear live bit) + // reclaim large objects should after preforward(may process weak ref) and + // before fix heap(may clear live bit) if (isNotYoungGC) { CollectLargeGarbage(); } @@ -721,16 +655,14 @@ void WCollector::DoGarbageCollection() CopyFromSpace(); WVerify::VerifyAfterForward(*this); - { - ScopedStopTheWorld stw("wgc-preparefix"); - PrepareFix(); - } + PrepareFix(); FixHeap(); if (isNotYoungGC) { CollectPinnedGarbage(); } TransitionToGCPhase(GCPhase::GC_PHASE_IDLE, true); + ClearAllGCInfo(); CollectSmallSpace(); }