From bd054908020973df3ed54f2b26c4c8153022e6ec Mon Sep 17 00:00:00 2001 From: sunzibo Date: Mon, 1 Sep 2025 14:21:44 +0800 Subject: [PATCH] test Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICWSYR Signed-off-by: sunzibo Change-Id: I17fd970122db0a859a0ad144fce84e16e39f59ae --- .../heap/allocator/tests/region_manager_test.cpp | 3 ++- .../heap/collector/collector_resources.cpp | 14 +++++++++----- ecmascript/ecma_vm.cpp | 7 +++++-- test/ut/ignore-ut-debug-x64-ets_runtime.txt | 3 --- test/ut/ignore-ut-release-qemu-ets_runtime.txt | 2 -- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common_components/heap/allocator/tests/region_manager_test.cpp b/common_components/heap/allocator/tests/region_manager_test.cpp index be0b4b2eae..7e7b02b775 100755 --- a/common_components/heap/allocator/tests/region_manager_test.cpp +++ b/common_components/heap/allocator/tests/region_manager_test.cpp @@ -62,7 +62,7 @@ protected: mutator_ = Mutator::NewMutator(); ASSERT_NE(mutator_, nullptr); mutator_->InitTid(); - ThreadLocal::GetThreadLocalData()->mutator = mutator_; + ThreadLocal::SetMutator(mutator_); } void TearDown() override @@ -70,6 +70,7 @@ protected: if (mutator_) { delete mutator_; mutator_ = nullptr; + ThreadLocal::SetMutator(mutator_); } if (regionMemory_) { free(regionMemory_); diff --git a/common_components/heap/collector/collector_resources.cpp b/common_components/heap/collector/collector_resources.cpp index e73d163b71..28c4a6da3d 100755 --- a/common_components/heap/collector/collector_resources.cpp +++ b/common_components/heap/collector/collector_resources.cpp @@ -38,7 +38,7 @@ void* CollectorResources::GCMainThreadEntry(void* arg) LOGE_IF(UNLIKELY_CC(ret != 0)) << "pthread setname in CollectorResources::StartGCThreads() return " << ret << " rather than 0"; #endif - + ASSERT_LOGF(arg != nullptr, "GCMainThreadEntry arg=nullptr"); // set current thread as a gc thread. ThreadLocal::SetThreadType(ThreadType::GC_THREAD); @@ -119,8 +119,12 @@ void CollectorResources::StopGCThreads() LOG_COMMON(FATAL) << "[GC] CollectorResources Thread not begin."; UNREACHABLE(); } - int ret = ::pthread_join(gcMainThread_, nullptr); - LOGE_IF(UNLIKELY_CC(ret != 0)) << "::pthread_join() in StopGCThreads() return " << ret; + { + // Enter saferegion to avoid blocking gc stw + ScopedEnterSaferegion enterSaferegion(true); + int ret = ::pthread_join(gcMainThread_, nullptr); + LOGE_IF(UNLIKELY_CC(ret != 0)) << "::pthread_join() in StopGCThreads() return " << ret; + } // wait the thread pool stopped. if (gcThreadPool_ != nullptr) { gcThreadPool_->Destroy(0); @@ -221,13 +225,13 @@ void CollectorResources::NotifyGCFinished(uint64_t gcIndex) void CollectorResources::MarkGCStart() { std::unique_lock lock(gcFinishedCondMutex_); - + // Wait for any existing GC to finish - inline the wait logic std::function pred = [this] { return !IsGcStarted(); }; gcFinishedCondVar_.wait(lock, pred); - + // Now claim GC ownership SetGcStarted(true); } diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index b8fa05a65b..3b14e6b4d0 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -343,7 +343,7 @@ bool EcmaVM::Initialize() if (Runtime::GetInstance()->IsHybridVm()) { crossVMOperator_ = new CrossVMOperator(this); } - + #endif // PANDA_JS_ETS_HYBRID_MODE gcStats_ = chunk_.New(heap_, options_.GetLongPauseTime()); gcKeyStats_ = chunk_.New(heap_, gcStats_); @@ -416,7 +416,10 @@ EcmaVM::~EcmaVM() factory_ = nullptr; } stringTable_ = nullptr; - thread_ = nullptr; + if (thread_ != nullptr) { + delete thread_; + thread_ = nullptr; + } if (g_isEnableCMCGC) { common::BaseRuntime::ExitGCCriticalSection(); } diff --git a/test/ut/ignore-ut-debug-x64-ets_runtime.txt b/test/ut/ignore-ut-debug-x64-ets_runtime.txt index 6838b8630f..38486af15a 100644 --- a/test/ut/ignore-ut-debug-x64-ets_runtime.txt +++ b/test/ut/ignore-ut-debug-x64-ets_runtime.txt @@ -22,9 +22,6 @@ obj/arkcompiler/ets_runtime/test/jittest/icnotfound/icnotfound #23099 obj/arkcompiler/ets_runtime/ecmascript/pgo_profiler/tests/PGOProfilerTestOne -#27690 -obj/arkcompiler/ets_runtime/test/jittest/throw_error/throw_error - #27862 obj/arkcompiler/ets_runtime/test/moduletest/stringreplace/stringreplaceAsmAssert diff --git a/test/ut/ignore-ut-release-qemu-ets_runtime.txt b/test/ut/ignore-ut-release-qemu-ets_runtime.txt index 21ddc18cae..b27ba1314a 100644 --- a/test/ut/ignore-ut-release-qemu-ets_runtime.txt +++ b/test/ut/ignore-ut-release-qemu-ets_runtime.txt @@ -261,8 +261,6 @@ obj/arkcompiler/ets_runtime/ecmascript/builtins/tests/Builtins_Array_TestWithQem obj/arkcompiler/ets_runtime/test/moduletest/throwerrorrelease/throwerrorreleaseAsm obj/arkcompiler/ets_runtime/test/moduletest/throwerrorrelease/throwerrorreleaseAsmContext -#28747 -obj/arkcompiler/ets_runtime/test/jittest/throw_error/throw_error #29435 obj/arkcompiler/ets_runtime/ecmascript/napi/test/Jsnapi_003_TestWithQemu -- Gitee