From 13fd8847377b68ba93d901b42f71bade2be8e1ba Mon Sep 17 00:00:00 2001 From: wuyan Date: Tue, 1 Jul 2025 17:52:16 +0800 Subject: [PATCH] opt idle barrier updateRSet Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICJ8W4 Change-Id: I7ecd8f9c40992fb5a821ae7b06d367e42b502112 Signed-off-by: wuyan --- common_components/heap/allocator/region_desc.h | 12 ++++++++++-- common_components/heap/collector/region_rset.h | 2 +- common_components/heap/w_collector/idle_barrier.cpp | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common_components/heap/allocator/region_desc.h b/common_components/heap/allocator/region_desc.h index 03dc5d1c01..b99932a61b 100755 --- a/common_components/heap/allocator/region_desc.h +++ b/common_components/heap/allocator/region_desc.h @@ -440,13 +440,13 @@ public: FREE_REGION, THREAD_LOCAL_REGION, - THREAD_LOCAL_OLD_REGION, RECENT_FULL_REGION, FROM_REGION, - LONE_FROM_REGION, EXEMPTED_FROM_REGION, + LONE_FROM_REGION, TO_REGION, OLD_REGION, + THREAD_LOCAL_OLD_REGION, // pinned object will not be forwarded by concurrent copying gc. FULL_PINNED_REGION, @@ -779,6 +779,14 @@ public: return type == RegionType::THREAD_LOCAL_REGION || type == RegionType::RECENT_FULL_REGION; } + bool IsInYoungSpaceForWB() const + { + RegionType type = GetRegionType(); + return type == RegionType::THREAD_LOCAL_REGION || + type == RegionType::RECENT_FULL_REGION || + type == RegionType::FROM_REGION; + } + bool IsInYoungSpace() const { RegionType type = GetRegionType(); diff --git a/common_components/heap/collector/region_rset.h b/common_components/heap/collector/region_rset.h index 2d31593573..4ce2fcaab2 100644 --- a/common_components/heap/collector/region_rset.h +++ b/common_components/heap/collector/region_rset.h @@ -63,7 +63,7 @@ public: size_t cardIdx = (offset / kMarkedBytesPerBit) / kBitsPerWord; size_t headMaskBitStart = (offset / kMarkedBytesPerBit) % kBitsPerWord; uint64_t headMaskBits = static_cast(1) << headMaskBitStart; - uint64_t card = cardTable[cardIdx].load(); + uint64_t card = cardTable[cardIdx].load(std::memory_order_relaxed); bool isMarked = ((card & headMaskBits) != 0); if (!isMarked) { card = cardTable[cardIdx].fetch_or(headMaskBits); diff --git a/common_components/heap/w_collector/idle_barrier.cpp b/common_components/heap/w_collector/idle_barrier.cpp index 4f23d406e8..ba0c569a4f 100755 --- a/common_components/heap/w_collector/idle_barrier.cpp +++ b/common_components/heap/w_collector/idle_barrier.cpp @@ -93,8 +93,7 @@ void IdleBarrier::UpdateRememberSet(BaseObject* object, BaseObject* ref) const ASSERT(object != nullptr); RegionDesc* objRegion = RegionDesc::GetRegionDescAt(reinterpret_cast((void*)object)); RegionDesc* refRegion = RegionDesc::GetRegionDescAt(reinterpret_cast((void*)ref)); - if ((!objRegion->IsInYoungSpace() && refRegion->IsInYoungSpace()) || - (objRegion->IsInFromSpace() && refRegion->IsInRecentSpace())) { + if (!objRegion->IsInYoungSpaceForWB() && refRegion->IsInYoungSpaceForWB()) { if (objRegion->MarkRSetCardTable(object)) { DLOG(BARRIER, "update point-out remember set of region %p, obj %p, ref: %p<%p>", objRegion, object, ref, ref->GetTypeInfo()); -- Gitee