diff --git a/ecmascript/dfx/hprof/heap_marker.cpp b/ecmascript/dfx/hprof/heap_marker.cpp index ce9bd66ff68543b89a7cded786a6cb74f13fe70b..450885efd810cf84fe4f5a3c2b7a2977a2db1602 100644 --- a/ecmascript/dfx/hprof/heap_marker.cpp +++ b/ecmascript/dfx/hprof/heap_marker.cpp @@ -64,6 +64,9 @@ bool HeapMarker::CMCMark(JSTaggedType addr) bool HeapMarker::IsMarked(JSTaggedType addr) { + if (g_isEnableCMCGC) { + return IsCMCMarked(addr); + } auto index = (addr & DEFAULT_REGION_MASK) >> TAGGED_TYPE_SIZE_LOG; Region *region = Region::ObjectAddressToRange(addr); auto bitsetIt = regionBitsetMap_.find(region); @@ -73,8 +76,23 @@ bool HeapMarker::IsMarked(JSTaggedType addr) return false; } +bool HeapMarker::IsCMCMarked(JSTaggedType addr) +{ + auto index = (addr & common::RegionDesc::DEFAULT_REGION_UNIT_MASK) >> TAGGED_TYPE_SIZE_LOG; + JSTaggedType region = + reinterpret_cast(common::RegionDesc::InlinedRegionMetaData::GetInlinedRegionMetaData(addr)); + auto bitsetIt = cmcRegionBitsetMap_.find(region); + if (bitsetIt != cmcRegionBitsetMap_.end() && bitsetIt->second.test(index)) { + return true; + } + return false; +} + void HeapMarker::Clear() { + if (g_isEnableCMCGC) { + cmcRegionBitsetMap_.clear(); + } regionBitsetMap_.clear(); } diff --git a/ecmascript/dfx/hprof/heap_marker.h b/ecmascript/dfx/hprof/heap_marker.h index e015adbbc139aecbeca92ed8a5c4760736fecbef..3c48aea5e2f56db5504ffc9f293a162809436740 100644 --- a/ecmascript/dfx/hprof/heap_marker.h +++ b/ecmascript/dfx/hprof/heap_marker.h @@ -34,6 +34,7 @@ public: bool Mark(JSTaggedType addr); bool CMCMark(JSTaggedType addr); bool IsMarked(JSTaggedType addr); + bool IsCMCMarked(JSTaggedType addr); void Clear(); void IterateMarked(const std::function &cb); void IterateCMCMarked(const std::function &cb);