From 307e37271d2f94d20a94f8319c6a0fcd4f2b65c3 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Wed, 9 Jul 2025 10:26:45 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!12625?= =?UTF-8?q?=20:=20Batch=20Barrier=20IR=20for=20CMC-GC'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecmascript/compiler/call_signature.cpp | 35 ---- ecmascript/compiler/call_signature.h | 2 - ecmascript/compiler/stub_builder.cpp | 260 +++++++------------------ ecmascript/compiler/stub_builder.h | 8 - ecmascript/mem/barriers.cpp | 45 ++--- ecmascript/mem/barriers.h | 2 +- ecmascript/stubs/runtime_stub_list.h | 4 +- ecmascript/stubs/runtime_stubs.cpp | 31 +-- ecmascript/stubs/runtime_stubs.h | 3 - 9 files changed, 101 insertions(+), 289 deletions(-) diff --git a/ecmascript/compiler/call_signature.cpp b/ecmascript/compiler/call_signature.cpp index b76f88af48..fa81207c41 100644 --- a/ecmascript/compiler/call_signature.cpp +++ b/ecmascript/compiler/call_signature.cpp @@ -3716,26 +3716,6 @@ DEF_CALL_SIGNATURE(ReverseBarrier) callSign->SetCallConv(CallSignature::CallConv::CCallConv);; } -DEF_CALL_SIGNATURE(CopyObjectPrimitive) -{ - constexpr size_t paramCount = 5; - // 5 : 5 input parameters - CallSignature ArrayCopy("CopyObjectPrimitive", 0, paramCount, - ArgumentsOrder::DEFAULT_ORDER, VariableType::VOID()); - *callSign = ArrayCopy; - // 5 : 5 input parameters - std::array params = { - VariableType::NATIVE_POINTER(), - VariableType::NATIVE_POINTER(), - VariableType::NATIVE_POINTER(), - VariableType::NATIVE_POINTER(), - VariableType::INT32() - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} - DEF_CALL_SIGNATURE(ObjectCopy) { constexpr size_t paramCount = 5; @@ -3943,19 +3923,4 @@ DEF_CALL_SIGNATURE(MarkInBuffer) callSign->SetGCLeafFunction(true); callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); } - -DEF_CALL_SIGNATURE(BatchMarkInBuffer) -{ - // 3 : 3 input parameters - CallSignature BatchMarkInBuffer("BatchMarkInBuffer", 0, 2, ArgumentsOrder::DEFAULT_ORDER, - VariableType::BOOL()); - *callSign = BatchMarkInBuffer; - std::array params = { // 2 : 2 input parameters - VariableType::NATIVE_POINTER(), - VariableType::INT32(), - }; - callSign->SetParameters(params.data()); - callSign->SetGCLeafFunction(true); - callSign->SetTargetKind(CallSignature::TargetKind::RUNTIME_STUB_NO_GC); -} } // namespace panda::ecmascript::kungfu diff --git a/ecmascript/compiler/call_signature.h b/ecmascript/compiler/call_signature.h index 15f0ea8197..520277f033 100644 --- a/ecmascript/compiler/call_signature.h +++ b/ecmascript/compiler/call_signature.h @@ -689,7 +689,6 @@ private: V(CreateLocalToShare) \ V(CreateOldToNew) \ V(BatchBarrier) \ - V(CopyObjectPrimitive) \ V(ObjectCopy) \ V(ArrayIteratorNext) \ V(GetIterator) \ @@ -711,7 +710,6 @@ private: V(CopyArgvArray) \ V(MarkRSetCardTable) \ V(MarkInBuffer) \ - V(BatchMarkInBuffer) \ V(CMCSetValueWithBarrier) #define DECL_CALL_SIGNATURE(name) \ diff --git a/ecmascript/compiler/stub_builder.cpp b/ecmascript/compiler/stub_builder.cpp index 2f92b62539..29171da987 100644 --- a/ecmascript/compiler/stub_builder.cpp +++ b/ecmascript/compiler/stub_builder.cpp @@ -1934,131 +1934,78 @@ GateRef StubBuilder::IsInYoungSpace(GateRef regionType) return ret; } -GateRef StubBuilder::IsOldToYoung(GateRef objRegionType, GateRef valueRegionType) -{ - auto env = GetEnvironment(); - GateRef isOldToYoung = LogicAndBuilder(env) - .And(BoolNot(IsInYoungSpace(objRegionType))) - .And(IsInYoungSpace(valueRegionType)).Done(); - return isOldToYoung; -} - -GateRef StubBuilder::GetGCPhase(GateRef glue) -{ - GateRef gcPhase = LoadPrimitive(VariableType::INT8(), glue, - Int64(JSThread::GlueData::GetSharedGCStateBitFieldOffset(false) + - JSThread::CMCGCPhaseBits::START_BIT / BITS_PER_BYTE)); - return gcPhase; -} - -GateRef StubBuilder::GetGCReason(GateRef glue) -{ - GateRef gcReason = LoadPrimitive(VariableType::INT32(), glue, - Int64(JSThread::GlueData::GetSharedGCStateBitFieldOffset(false) + - JSThread::CMCGCReasonBits::START_BIT / BITS_PER_BYTE)); - return gcReason; -} - -void StubBuilder::MarkRSetCardTable(GateRef obj, Label *exit) -{ - auto env = GetEnvironment(); - Label markBit(env); - GateRef regionBase = IntPtrAnd(TaggedCastToIntPtr(obj), - IntPtr(~static_cast(common::RegionDesc::DEFAULT_REGION_UNIT_MASK))); - GateRef objOffset = PtrSub(TaggedCastToIntPtr(obj), regionBase); - GateRef rset = GetCMCRegionRSet(obj); - GateRef cardIdx = IntPtrDiv(IntPtrDiv(objOffset, IntPtr(common::kMarkedBytesPerBit)), - IntPtr(common::kBitsPerWord)); - GateRef headMaskBitStart = IntPtrMod(IntPtrDiv(objOffset, IntPtr(common::kMarkedBytesPerBit)), - IntPtr(common::kBitsPerWord)); - GateRef headMaskBits = Int64LSL(Int64(1), headMaskBitStart); - GateRef cardOffset = PtrMul(cardIdx, IntPtr(common::kBytesPerWord)); - GateRef cardTable = LoadPrimitive(VariableType::NATIVE_POINTER(), rset, - IntPtr(common::RegionRSet::CARD_TABLE_OFFSET_IN_RSET)); - GateRef card = LoadPrimitive(VariableType::INT64(), cardTable, cardOffset); - GateRef isMarked = Int64NotEqual(Int64And(card, headMaskBits), Int64(0)); - BRANCH_NO_WEIGHT(isMarked, exit, &markBit); - Bind(&markBit); - { - Int64FetchOr(PtrAdd(cardTable, cardOffset), headMaskBits); - Jump(exit); - } -} - -GateRef StubBuilder::ShouldGetGCReason(GateRef gcPhase) -{ - auto env = GetEnvironment(); - GateRef shouldGetGCReason = LogicOrBuilder(env) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_ENUM))) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_MARK))) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_POST_MARK))) - .Done(); - return shouldGetGCReason; -} - -GateRef StubBuilder::ShouldProcessSATB(GateRef gcPhase) -{ - auto env = GetEnvironment(); - GateRef shouldProcessSATB = LogicOrBuilder(env) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_ENUM))) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_MARK))) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_FINAL_MARK))) - .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_REMARK_SATB))) - .Done(); - return shouldProcessSATB; -} - -GateRef StubBuilder::ShouldUpdateRememberSet(GateRef glue, GateRef gcPhase) +void StubBuilder::CMCSetValueWithBarrier(GateRef glue, GateRef obj, [[maybe_unused]]GateRef offset, GateRef value) { auto env = GetEnvironment(); Label entry(env); env->SubCfgEntry(&entry); - Label checkOldToYoung(env); Label exit(env); + + GateRef gcPhase = LoadPrimitive(VariableType::INT8(), glue, + Int64(JSThread::GlueData::GetSharedGCStateBitFieldOffset(false) + + JSThread::CMCGCPhaseBits::START_BIT / BITS_PER_BYTE)); + Label checkOldToYoung(env); + Label markRSet(env); Label notMarkRSet(env); Label notIdlePhase(env); - DEFVARIABLE(result, VariableType::BOOL(), True()); - BRANCH(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_IDLE)), &exit, ¬IdlePhase); + BRANCH(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_IDLE)), &checkOldToYoung, ¬IdlePhase); Bind(¬IdlePhase); - GateRef gcReason = GetGCReason(glue); + GateRef gcReason = LoadPrimitive(VariableType::INT32(), glue, + Int64(JSThread::GlueData::GetSharedGCStateBitFieldOffset(false) + + JSThread::CMCGCReasonBits::START_BIT / BITS_PER_BYTE)); Label reasonNotYoung(env); - BRANCH(Int32Equal(gcReason, Int32(common::GCReason::GC_REASON_YOUNG)), &exit, &reasonNotYoung); + BRANCH(Int32Equal(gcReason, Int32(common::GCReason::GC_REASON_YOUNG)), &checkOldToYoung, &reasonNotYoung); Bind(&reasonNotYoung); - GateRef shouldGetGCReason = ShouldGetGCReason(gcPhase); - BRANCH(BoolNot(shouldGetGCReason), &exit, ¬MarkRSet); - Bind(¬MarkRSet); - result = False(); - Jump(&exit); - Bind(&exit); - auto ret = *result; - env->SubCfgExit(); - return ret; -} - -void StubBuilder::CMCSetValueWithBarrier(GateRef glue, GateRef obj, [[maybe_unused]]GateRef offset, GateRef value) -{ - auto env = GetEnvironment(); - Label entry(env); - env->SubCfgEntry(&entry); - Label exit(env); - Label checkOldToYoung(env); - Label markRSet(env); - Label notMarkRSet(env); - GateRef gcPhase = GetGCPhase(glue); - BRANCH(ShouldUpdateRememberSet(glue, gcPhase), &checkOldToYoung, ¬MarkRSet); + GateRef needMarkPhase = LogicOrBuilder(env) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_COPY))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_FIX))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_PRECOPY))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_FINAL_MARK))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_REMARK_SATB))) + .Done(); + BRANCH(needMarkPhase, &checkOldToYoung, ¬MarkRSet); Bind(&checkOldToYoung); { GateRef objRegionType = GetCMCRegionType(obj); GateRef valueRegionType = GetCMCRegionType(value); - GateRef isOldToYoung = IsOldToYoung(objRegionType, valueRegionType); + GateRef isOldToYoung = LogicAndBuilder(env) + .And(BoolNot(IsInYoungSpace(objRegionType))) + .And(IsInYoungSpace(valueRegionType)).Done(); BRANCH_UNLIKELY(isOldToYoung, &markRSet, ¬MarkRSet); Bind(&markRSet); - MarkRSetCardTable(obj, ¬MarkRSet); + { + Label markBit(env); + GateRef regionBase = IntPtrAnd(TaggedCastToIntPtr(obj), + IntPtr(~static_cast(common::RegionDesc::DEFAULT_REGION_UNIT_MASK))); + GateRef objOffset = PtrSub(TaggedCastToIntPtr(obj), regionBase); + GateRef rset = GetCMCRegionRSet(obj); + GateRef cardIdx = IntPtrDiv(IntPtrDiv(objOffset, IntPtr(common::kMarkedBytesPerBit)), + IntPtr(common::kBitsPerWord)); + GateRef headMaskBitStart = IntPtrMod(IntPtrDiv(objOffset, IntPtr(common::kMarkedBytesPerBit)), + IntPtr(common::kBitsPerWord)); + GateRef headMaskBits = Int64LSL(Int64(1), headMaskBitStart); + GateRef cardOffset = PtrMul(cardIdx, IntPtr(common::kBytesPerWord)); + GateRef cardTable = LoadPrimitive(VariableType::NATIVE_POINTER(), rset, + IntPtr(common::RegionRSet::CARD_TABLE_OFFSET_IN_RSET)); + GateRef card = LoadPrimitive(VariableType::INT64(), cardTable, cardOffset); + GateRef isMarked = Int64NotEqual(Int64And(card, headMaskBits), Int64(0)); + BRANCH_NO_WEIGHT(isMarked, ¬MarkRSet, &markBit); + Bind(&markBit); + { + Int64FetchOr(PtrAdd(cardTable, cardOffset), headMaskBits); + Jump(¬MarkRSet); + } + } } Bind(¬MarkRSet); Label markInBuffer(env); - GateRef shouldProcessSATB = ShouldProcessSATB(gcPhase); - BRANCH_UNLIKELY(shouldProcessSATB, &markInBuffer, &exit); + GateRef needMarkInBuffer = LogicOrBuilder(env) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_ENUM))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_MARK))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_FINAL_MARK))) + .Or(Int8Equal(gcPhase, Int8(common::GCPhase::GC_PHASE_REMARK_SATB))) + .Done(); + BRANCH_UNLIKELY(needMarkInBuffer, &markInBuffer, &exit); Bind(&markInBuffer); { CallNGCRuntime(glue, RTSTUB_ID(MarkInBuffer), {value}); @@ -2068,52 +2015,6 @@ void StubBuilder::CMCSetValueWithBarrier(GateRef glue, GateRef obj, [[maybe_unus env->SubCfgExit(); } -void StubBuilder::CMCArrayCopyWriteBarrier(GateRef glue, GateRef dstObj, GateRef src, GateRef dst, GateRef count) -{ - auto env = GetEnvironment(); - Label entry(env); - env->SubCfgEntry(&entry); - Label exit(env); - Label iLessLength(env); - Label isTaggedObject(env); - Label loopHead(env); - Label loopEnd(env); - Label markRSet(env); - Label notMarkRSet(env); - GateRef objRegionType = GetCMCRegionType(dstObj); - DEFVARIABLE(i, VariableType::INT32(), Int32(0)); - GateRef gcPhase = GetGCPhase(glue); - Label checkOldToYoung(env); - BRANCH(ShouldUpdateRememberSet(glue, gcPhase), &checkOldToYoung, ¬MarkRSet); - Bind(&checkOldToYoung); - Jump(&loopHead); - LoopBegin(&loopHead); - { - BRANCH(Int32UnsignedLessThan(*i, count), &iLessLength, ¬MarkRSet); - Bind(&iLessLength); - GateRef offset = PtrMul(ZExtInt32ToPtr(*i), IntPtr(sizeof(uintptr_t))); - GateRef ref = LoadPrimitive(VariableType::JS_ANY(), src, offset); - BRANCH(TaggedIsHeapObject(ref), &isTaggedObject, &loopEnd); - Bind(&isTaggedObject); - GateRef isOldToYoung = IsOldToYoung(objRegionType, GetCMCRegionType(ref)); - BRANCH_UNLIKELY(isOldToYoung, &markRSet, &loopEnd); - Bind(&markRSet); - MarkRSetCardTable(dstObj, ¬MarkRSet); - Bind(&loopEnd); - i = Int32Add(*i, Int32(1)); - LoopEnd(&loopHead); - } - Bind(¬MarkRSet); - Label markInBuffer(env); - GateRef shouldProcessSATB = ShouldProcessSATB(gcPhase); - BRANCH_UNLIKELY(shouldProcessSATB, &markInBuffer, &exit); - Bind(&markInBuffer); - CallNGCRuntime(glue, RTSTUB_ID(BatchMarkInBuffer), {TaggedCastToIntPtr(src), count}); - Jump(&exit); - Bind(&exit); - env->SubCfgExit(); -} - void StubBuilder::SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, MemoryAttribute::ShareFlag share) { @@ -13117,43 +13018,32 @@ void StubBuilder::ArrayCopy(GateRef glue, GateRef srcObj, GateRef srcAddr, GateR Label entry(env); env->SubCfgEntry(&entry); Label exit(env); - Label isEnableCMCGC(env); - Label notCMCGC(env); + CallNGCRuntime(glue, RTSTUB_ID(ObjectCopy), + {glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), TaggedCastToIntPtr(srcAddr), taggedValueCount}); + Label checkNext(env); BRANCH_UNLIKELY(LoadPrimitive( VariableType::BOOL(), glue, IntPtr(JSThread::GlueData::GetIsEnableCMCGCOffset(env->Is32Bit()))), - &isEnableCMCGC, ¬CMCGC); - - Bind(&isEnableCMCGC); - { - CallNGCRuntime(glue, RTSTUB_ID(CopyObjectPrimitive), - {glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), TaggedCastToIntPtr(srcAddr), taggedValueCount}); - CMCArrayCopyWriteBarrier(glue, dstObj, dstAddr, srcAddr, taggedValueCount); - Jump(&exit); - } - Bind(¬CMCGC); + &exit, &checkNext); + Bind(&checkNext); + Label handleBarrier(env); + BRANCH_NO_WEIGHT(needBarrier, &handleBarrier, &exit); + Bind(&handleBarrier); { - CallNGCRuntime(glue, RTSTUB_ID(ObjectCopy), - {glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), TaggedCastToIntPtr(srcAddr), taggedValueCount}); - Label handleBarrier(env); - BRANCH_NO_WEIGHT(needBarrier, &handleBarrier, &exit); - Bind(&handleBarrier); - { - if (copyKind == SameArray) { - CallCommonStub(glue, CommonStubCSigns::MoveBarrierInRegion, - { - glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), taggedValueCount, - TaggedCastToIntPtr(srcAddr) - }); - } else { - ASSERT(copyKind == DifferentArray); - CallCommonStub(glue, CommonStubCSigns::MoveBarrierCrossRegion, - { - glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), taggedValueCount, - TaggedCastToIntPtr(srcAddr), TaggedCastToIntPtr(srcObj) - }); - } - Jump(&exit); + if (copyKind == SameArray) { + CallCommonStub(glue, CommonStubCSigns::MoveBarrierInRegion, + { + glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), taggedValueCount, + TaggedCastToIntPtr(srcAddr) + }); + } else { + ASSERT(copyKind == DifferentArray); + CallCommonStub(glue, CommonStubCSigns::MoveBarrierCrossRegion, + { + glue, TaggedCastToIntPtr(dstObj), TaggedCastToIntPtr(dstAddr), taggedValueCount, + TaggedCastToIntPtr(srcAddr), TaggedCastToIntPtr(srcObj) + }); } + Jump(&exit); } Bind(&exit); env->SubCfgExit(); diff --git a/ecmascript/compiler/stub_builder.h b/ecmascript/compiler/stub_builder.h index 07003e6903..a49084ccca 100644 --- a/ecmascript/compiler/stub_builder.h +++ b/ecmascript/compiler/stub_builder.h @@ -822,16 +822,8 @@ public: void VerifyBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value); GateRef GetCMCRegionRSet(GateRef obj); GateRef GetCMCRegionType(GateRef obj); - GateRef GetGCPhase(GateRef glue); - GateRef GetGCReason(GateRef glue); GateRef IsInYoungSpace(GateRef regionType); - GateRef IsOldToYoung(GateRef objRegionType, GateRef valueRegionType); - void MarkRSetCardTable(GateRef obj, Label *exit); - GateRef ShouldGetGCReason(GateRef gcPhase); - GateRef ShouldProcessSATB(GateRef gcPhase); - GateRef ShouldUpdateRememberSet(GateRef glue, GateRef gcPhase); void CMCSetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value); - void CMCArrayCopyWriteBarrier(GateRef glue, GateRef dstObj, GateRef src, GateRef dst, GateRef count); void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, MemoryAttribute::ShareFlag share = MemoryAttribute::UNKNOWN); GateRef GetValueWithBarrier(GateRef glue, GateRef addr); diff --git a/ecmascript/mem/barriers.cpp b/ecmascript/mem/barriers.cpp index d2f6cea992..fe0d1f6b41 100644 --- a/ecmascript/mem/barriers.cpp +++ b/ecmascript/mem/barriers.cpp @@ -156,12 +156,13 @@ bool Barriers::ShouldGetGCReason(common::GCPhase gcPhase) } } -bool Barriers::ShouldUpdateRememberSet(common::GCPhase gcPhase) +bool Barriers::ShouldUpdateRememberSet(BaseObject* ref, common::GCPhase gcPhase) { - if (common::Heap::GetHeap().GetGCReason() == common::GC_REASON_YOUNG || !ShouldGetGCReason(gcPhase)) { - return true; + if (!common::Heap::IsTaggedObject(reinterpret_cast(ref))) { + return false; } - return false; + ASSERT(common::Heap::IsHeapAddress(ref)); + return !ShouldGetGCReason(gcPhase) || common::Heap::GetHeap().GetGCReason() == common::GC_REASON_YOUNG; } void Barriers::CMCArrayCopyWriteBarrier(const JSThread *thread, const TaggedObject *dstObj, void* src, void* dst, @@ -171,28 +172,28 @@ void Barriers::CMCArrayCopyWriteBarrier(const JSThread *thread, const TaggedObje ASSERT(dstObj != nullptr); common::BaseObject* object = reinterpret_cast(const_cast(dstObj)); - common::RegionDesc::InlinedRegionMetaData *objMetaRegion = - common::RegionDesc::InlinedRegionMetaData::GetInlinedRegionMetaData(reinterpret_cast(object)); + common::RegionDesc* objRegion = + common::RegionDesc::GetRegionDescAt(reinterpret_cast(object)); uintptr_t *srcPtr = reinterpret_cast(src); common::GCPhase gcPhase = thread->GetCMCGCPhase(); + // 1. update Rememberset - if (ShouldUpdateRememberSet(gcPhase)) { - auto checkReference = [&](BaseObject* ref) { - common::RegionDesc::InlinedRegionMetaData *refMetaRegion = - common::RegionDesc::InlinedRegionMetaData::GetInlinedRegionMetaData(reinterpret_cast(ref)); - return (!objMetaRegion->IsInYoungSpaceForWB() && refMetaRegion->IsInYoungSpaceForWB()); - }; + auto checkReference = [&](BaseObject* ref) { + common::RegionDesc* refRegion = + common::RegionDesc::GetRegionDescAt(reinterpret_cast(ref)); + return (!objRegion->IsInYoungSpace() && refRegion->IsInYoungSpace()) || + (objRegion->IsInFromSpace() && refRegion->IsInRecentSpace()); + }; - for (size_t i = 0; i < count; i++) { - BaseObject* ref = reinterpret_cast(srcPtr[i]); - if (!common::Heap::IsTaggedObject(reinterpret_cast(ref))) { - continue; - } - ASSERT(common::Heap::IsHeapAddress(ref)); - if (checkReference(ref)) { - objMetaRegion->MarkRSetCardTable(object); - break; - } + for (size_t i = 0; i < count; i++) { + BaseObject* ref = reinterpret_cast(srcPtr[i]); + if (!ShouldUpdateRememberSet(ref, gcPhase)) { + continue; + } + + if (checkReference(ref)) { + objRegion->MarkRSetCardTable(object); + break; } } diff --git a/ecmascript/mem/barriers.h b/ecmascript/mem/barriers.h index 4b4164ef93..805e620ce0 100644 --- a/ecmascript/mem/barriers.h +++ b/ecmascript/mem/barriers.h @@ -117,7 +117,7 @@ public: void* src, void* dst, size_t count); static bool ShouldProcessSATB(common::GCPhase gcPhase); static bool ShouldGetGCReason(common::GCPhase gcPhase); - static bool ShouldUpdateRememberSet(common::GCPhase gcPhase); + static bool ShouldUpdateRememberSet(BaseObject* ref, common::GCPhase gcPhase); static void CMCArrayCopyReadBarrierForward(const JSThread *thread, JSTaggedValue* dst, const JSTaggedValue* src, size_t count); diff --git a/ecmascript/stubs/runtime_stub_list.h b/ecmascript/stubs/runtime_stub_list.h index 7ae2fc0fc5..3ac03e6eb0 100644 --- a/ecmascript/stubs/runtime_stub_list.h +++ b/ecmascript/stubs/runtime_stub_list.h @@ -214,7 +214,6 @@ namespace panda::ecmascript { V(ReverseTypedArray) \ V(CopyTypedArrayBuffer) \ V(IsFastRegExp) \ - V(CopyObjectPrimitive) \ V(CreateLocalToShare) \ V(CreateOldToNew) \ V(ObjectCopy) \ @@ -229,8 +228,7 @@ namespace panda::ecmascript { V(CopyCallTarget) \ V(CopyArgvArray) \ V(MarkRSetCardTable) \ - V(MarkInBuffer) \ - V(BatchMarkInBuffer) + V(MarkInBuffer) // When ASM enters C++ via CallNGCRuntime, if the C++ process requires GetGlobalEnv(), // the current globalenv in ASM must be set to glue before CallNGCRuntime! diff --git a/ecmascript/stubs/runtime_stubs.cpp b/ecmascript/stubs/runtime_stubs.cpp index 30ad89a993..b990eee6be 100644 --- a/ecmascript/stubs/runtime_stubs.cpp +++ b/ecmascript/stubs/runtime_stubs.cpp @@ -4919,23 +4919,8 @@ DEF_RUNTIME_STUBS(SlowSharedObjectStoreBarrier) return publishValue.GetTaggedValue().GetRawData(); } -void RuntimeStubs::CopyObjectPrimitive(uintptr_t argGlue, JSTaggedType *dstObj, - JSTaggedType *dst, JSTaggedType *src, uint32_t count) -{ - DISALLOW_GARBAGE_COLLECTION; - auto thread = JSThread::GlueToJSThread(argGlue); - // check CMC-GC phase inside - if (thread->NeedReadBarrier()) { - Barriers::CopyObjectPrimitive(thread, - reinterpret_cast(dst), reinterpret_cast(src), count); - } else { - Barriers::CopyObjectPrimitive(thread, - reinterpret_cast(dst), reinterpret_cast(src), count); - } -} - void RuntimeStubs::ObjectCopy(uintptr_t argGlue, JSTaggedType *dstObj, - JSTaggedType *dst, JSTaggedType *src, uint32_t count) + JSTaggedType *dst, JSTaggedType *src, uint32_t count) { DISALLOW_GARBAGE_COLLECTION; if (g_isEnableCMCGC) { @@ -5007,20 +4992,6 @@ void RuntimeStubs::MarkInBuffer(BaseObject* ref) mutator->RememberObjectInSatbBuffer(ref); } -void RuntimeStubs::BatchMarkInBuffer(void* src, size_t count) -{ - uintptr *srcPtr = reinterpret_cast(src); - common::Mutator* mutator = common::Mutator::GetMutator(); - for (size_t i = 0; i < count; i++) { - BaseObject* ref = reinterpret_cast(srcPtr[i]); - if (!common::Heap::IsTaggedObject(reinterpret_cast(ref))) { - continue; - } - ref = reinterpret_cast(reinterpret_cast(ref) & ~(common::Barrier::TAG_WEAK)); - mutator->RememberObjectInSatbBuffer(ref); - } -} - void RuntimeStubs::Initialize(JSThread *thread) { #define DEF_RUNTIME_STUB(name) kungfu::RuntimeStubCSigns::ID_##name diff --git a/ecmascript/stubs/runtime_stubs.h b/ecmascript/stubs/runtime_stubs.h index 20806f567e..36fd433439 100644 --- a/ecmascript/stubs/runtime_stubs.h +++ b/ecmascript/stubs/runtime_stubs.h @@ -170,8 +170,6 @@ public: uint64_t bytecodePos); static void ObjectCopy(uintptr_t argGlue, JSTaggedType *dstObj, JSTaggedType *dst, JSTaggedType *src, uint32_t count); - static void CopyObjectPrimitive(uintptr_t argGlue, JSTaggedType *dstObj, - JSTaggedType *dst, JSTaggedType *src, uint32_t count); static void FillObject(JSTaggedType *dst, JSTaggedType value, uint32_t count); static void ReverseArray(uintptr_t argGlue, JSTaggedType *dst, uint32_t length); @@ -182,7 +180,6 @@ public: static JSTaggedValue GetExternalModuleVar(uintptr_t argGlue, JSFunction *jsFunc, int32_t index); static bool MarkRSetCardTable(BaseObject* obj); static void MarkInBuffer(BaseObject* ref); - static void BatchMarkInBuffer(void* src, size_t count); private: static void DumpToStreamWithHint(std::ostream &out, std::string_view prompt, JSTaggedValue value); -- Gitee