From 9e9b1429890f81c1ade024ed3e8c2ce69bd8eed0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 21 Aug 2025 11:22:32 +0800 Subject: [PATCH] Fix the ERROR after GC use case is enabled Fixed GC test case: Unified_GC_Test Issue: ICTZTK Signed-off-by: root Change-Id: I8f249420a3868ad5732ca39b97f84fa08ef5ab9c --- ecmascript/cross_vm/heap_hybrid.cpp | 1 + ecmascript/tests/BUILD.gn | 2 + ecmascript/tests/unified_gc_multi_vm_test.cpp | 37 ++----------------- ecmascript/tests/unified_gc_test.cpp | 14 +------ 4 files changed, 8 insertions(+), 46 deletions(-) diff --git a/ecmascript/cross_vm/heap_hybrid.cpp b/ecmascript/cross_vm/heap_hybrid.cpp index 3e9bd2e5bf..ad95756bab 100644 --- a/ecmascript/cross_vm/heap_hybrid.cpp +++ b/ecmascript/cross_vm/heap_hybrid.cpp @@ -19,6 +19,7 @@ #include "ecmascript/mem/heap.h" #include "ecmascript/mem/concurrent_sweeper.h" #include "ecmascript/mem/verification.h" +#include "ecmascript/cross_vm/heap_hybrid-inl.h" namespace panda::ecmascript { void SharedHeap::StartUnifiedGCMark([[maybe_unused]]TriggerGCType gcType, [[maybe_unused]]GCReason gcReason) diff --git a/ecmascript/tests/BUILD.gn b/ecmascript/tests/BUILD.gn index abe0135a8e..cb103dda05 100644 --- a/ecmascript/tests/BUILD.gn +++ b/ecmascript/tests/BUILD.gn @@ -3497,6 +3497,7 @@ group("unittest") { # deps file deps = [ + ":Unified_GC_Test", ":Builtins_Test", ":ECMA_StringAccessor_Test", ":ECMA_StringEquals_Test", @@ -3670,6 +3671,7 @@ group("host_unittest") { # deps file deps = [ + ":Unified_GC_TestAction", ":Builtins_TestAction", ":ECMA_StringAccessor_TestAction", ":ECMA_StringEquals_TestAction", diff --git a/ecmascript/tests/unified_gc_multi_vm_test.cpp b/ecmascript/tests/unified_gc_multi_vm_test.cpp index 9f2179d58a..c71cfb6956 100644 --- a/ecmascript/tests/unified_gc_multi_vm_test.cpp +++ b/ecmascript/tests/unified_gc_multi_vm_test.cpp @@ -14,7 +14,7 @@ */ #include - +#include "ecmascript/cross_vm/heap_hybrid-inl.h" #include "ecmascript/mem/concurrent_marker.h" #include "ecmascript/tests/unified_gc_test_helper.h" @@ -34,6 +34,7 @@ public: thread = instance->GetJSThread(); thread->ManagedCodeBegin(); scope = new EcmaHandleScope(thread); + JSNApi::InitHybridVMEnv(thread->GetEcmaVM()); } }; @@ -267,7 +268,7 @@ HWTEST_F_L0(UnifiedGCMultiVMTest, MultiVMUnifiedGCMarkTest1) barrier.PassStrongly(); barrier.Wait(); } - + void *ecmaVMInterface = nullptr; CrossVMOperator::DoHandshake(vm, stsVMInterface.get(), &ecmaVMInterface); CrossReferenceObjectBuilder CrossReferenceObject(vm, thread); @@ -476,37 +477,5 @@ HWTEST_F_L0(UnifiedGCMultiVMTest, MultiVMTriggerUnifiedGCFailTest) t2.join(); t3.join(); } - -HWTEST_F_L0(UnifiedGCMultiVMVerificationTest, VerifyMultiVMUnifiedGCMarkTest) -{ - SuspendBarrier barrier(INT_VALUE_4); - EcmaVM *vm = thread->GetEcmaVM(); - auto stsVMInterface = std::make_unique(); - - UnifiedGCMultiVMTestSuite testVM1(stsVMInterface.get(), &barrier); - UnifiedGCMultiVMTestSuite testVM2(stsVMInterface.get(), &barrier); - UnifiedGCMultiVMTestSuite testVM3(stsVMInterface.get(), &barrier); - std::thread t1(&UnifiedGCMultiVMTestSuite::HeapVerifyTest, testVM1); - std::thread t2(&UnifiedGCMultiVMTestSuite::HeapVerifyTest, testVM2); - std::thread t3(&UnifiedGCMultiVMTestSuite::HeapVerifyTest, testVM3); - { - ThreadSuspensionScope suspensionScope(thread); - barrier.PassStrongly(); - barrier.Wait(); - } - - void *ecmaVMInterface = nullptr; - CrossVMOperator::DoHandshake(vm, stsVMInterface.get(), &ecmaVMInterface); - CrossReferenceObjectBuilder CrossReferenceObject(vm, thread); - auto heap = vm->GetHeap(); - heap->GetConcurrentMarker()->Mark(); - SharedHeap::GetInstance()->TriggerUnifiedGCMark(thread); - while (!thread->HasSuspendRequest()) {} - thread->WaitSuspension(); - CrossReferenceObject.CheckResultAfterUnifiedGC(); - t1.join(); - t2.join(); - t3.join(); -} #endif // PANDA_JS_ETS_HYBRID_MODE } // namespace panda::test \ No newline at end of file diff --git a/ecmascript/tests/unified_gc_test.cpp b/ecmascript/tests/unified_gc_test.cpp index 2ac5010164..959b52da4c 100644 --- a/ecmascript/tests/unified_gc_test.cpp +++ b/ecmascript/tests/unified_gc_test.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "ecmascript/cross_vm/heap_hybrid-inl.h" #include "ecmascript/cross_vm/unified_gc/unified_gc_marker.h" #include "ecmascript/tests/unified_gc_test_helper.h" #include "ecmascript/mem/concurrent_marker.h" @@ -34,6 +35,7 @@ public: thread = instance->GetJSThread(); thread->ManagedCodeBegin(); scope = new EcmaHandleScope(thread); + JSNApi::InitHybridVMEnv(thread->GetEcmaVM()); } }; @@ -187,17 +189,5 @@ HWTEST_F_L0(UnifiedGCTest, TriggerUnifiedGCFailTest) CrossReferenceObject.CheckResultAfterUnifiedGCTriggerFail(); } -HWTEST_F_L0(UnifiedGCVerificationTest, VerifyUnifiedGCMarkTest) -{ - EcmaVM *vm = thread->GetEcmaVM(); - vm->SetEnableForceGC(false); - auto stsVMInterface = std::make_unique(); - void *ecmaVMInterface = nullptr; - CrossVMOperator::DoHandshake(vm, stsVMInterface.get(), &ecmaVMInterface); - SharedHeap::GetInstance()->TriggerUnifiedGCMark(thread); - while (!thread->HasSuspendRequest()) {} - thread->WaitSuspension(); - vm->SetEnableForceGC(true); -} #endif // PANDA_JS_ETS_HYBRID_MODE } // namespace panda::test \ No newline at end of file -- Gitee