diff --git a/ecmascript/mem/sparse_space.cpp b/ecmascript/mem/sparse_space.cpp index d6b7029eb53b2176904469d9564bd003ad2ca118..fa453ae928b2f039c5c8998c2979648eacb60833 100644 --- a/ecmascript/mem/sparse_space.cpp +++ b/ecmascript/mem/sparse_space.cpp @@ -169,16 +169,17 @@ void SparseSpace::Sweep() bool SparseSpace::TryFillSweptRegion() { - if (sweptList_.empty()) { + Region *region = GetSweptRegionSafe(); + if (region == nullptr) { return false; } - Region *region = nullptr; - while ((region = GetSweptRegionSafe()) != nullptr) { + do { allocator_->CollectFreeObjectSet(region); region->ResetSwept(); region->MergeOldToNewRSetForCS(); region->MergeLocalToShareRSetForCS(); - } + region = GetSweptRegionSafe(); + } while (region != nullptr); return true; }