From 9169af22edd7868f8bba0baab7d04aadcc0ae976 Mon Sep 17 00:00:00 2001 From: xwcai98 Date: Fri, 11 Jul 2025 16:18:15 +0800 Subject: [PATCH 1/2] Add safepoint Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICNTMY Signed-off-by: xwcai98 Change-Id: If374409587519d1d02ec73a79e05576ac875dcbe --- ecmascript/base/json_parser.cpp | 18 +++++++++++++++--- ecmascript/base/json_parser.h | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ecmascript/base/json_parser.cpp b/ecmascript/base/json_parser.cpp index 388dc51500..185105f423 100644 --- a/ecmascript/base/json_parser.cpp +++ b/ecmascript/base/json_parser.cpp @@ -47,12 +47,13 @@ JSHandle JsonParser::Launch(Text begin, Text end) initialJSObjectClass_ = JSHandle(thread_, JSFunction::GetOrCreateInitialJSHClass(thread_, objectFunc)); - JSTaggedValue result = ParseJSONText(); + JSTaggedValue result = g_isEnableCMCGC ? ParseJSONText() : ParseJSONText(); RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread_); return JSHandle(thread_, result); } template +template JSTaggedValue JsonParser::ParseJSONText() { JSHandle parseValue; @@ -225,9 +226,9 @@ JSTaggedValue JsonParser::ParseJSONText() break; } if (UNLIKELY(transformType_ == TransformType::SENDABLE)) { - parseValue = CreateSJsonObject(continuation, propertyList); + parseValue = CreateSJsonObject(continuation, propertyList); } else { - parseValue = CreateJsonObject(continuation, propertyList); + parseValue = CreateJsonObject(continuation, propertyList); } if (UNLIKELY(*current_ != '}')) { THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Object in JSON", @@ -276,6 +277,9 @@ JSTaggedValue JsonParser::ParseJSONText() } break; } + if constexpr (isEnableCMCGC) { + thread_->CheckSafepointIfSuspended(); + } } } @@ -307,6 +311,7 @@ JSHandle JsonParser::CreateSJsonArray([[maybe_unused]] JsonCon } template +template JSHandle JsonParser::CreateJsonObject(JsonContinuation continuation, std::vector> &propertyList) { @@ -323,11 +328,15 @@ JSHandle JsonParser::CreateJsonObject(JsonContinuation continu JSTaggedValue::SetProperty(thread_, obj, keyHandle, valueHandle, true); RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread_); } + if constexpr (isEnableCMCGC) { + thread_->CheckSafepointIfSuspended(); + } } return obj; } template +template JSHandle JsonParser::CreateSJsonObject(JsonContinuation continuation, std::vector> &propertyList) { @@ -355,6 +364,9 @@ JSHandle JsonParser::CreateSJsonObject(JsonContinuation contin } propertyArray->Set(thread_, i, newKey); propertyArray->Set(thread_, i + 1, JSTaggedValue(int(FieldType::NONE))); + if constexpr (isEnableCMCGC) { + thread_->CheckSafepointIfSuspended(); + } } hclass = factory_->NewSEcmaHClass(JSSharedObject::SIZE, fieldNum, JSType::JS_SHARED_OBJECT, JSHandle(jsonPrototype), JSHandle(layout)); diff --git a/ecmascript/base/json_parser.h b/ecmascript/base/json_parser.h index 3a17cec311..9c9099691d 100644 --- a/ecmascript/base/json_parser.h +++ b/ecmascript/base/json_parser.h @@ -122,6 +122,7 @@ protected: return proto; } + template JSTaggedValue ParseJSONText(); JSHandle CreateJsonArray(JsonContinuation continuation, @@ -130,9 +131,11 @@ protected: JSHandle CreateSJsonArray([[maybe_unused]] JsonContinuation continuation, [[maybe_unused]] std::vector> &elementsList); + template JSHandle CreateJsonObject(JsonContinuation continuation, std::vector> &propertyList); + template JSHandle CreateSJsonObject(JsonContinuation continuation, std::vector> &propertyList); -- Gitee From 54bec23d97855bb70584dcf402987bd0b3cb06c2 Mon Sep 17 00:00:00 2001 From: "houyunlong5@huawei.com" Date: Tue, 22 Jul 2025 12:17:01 +0800 Subject: [PATCH 2/2] TicketNo: Description: Team: Feature or Bugfix:Bugfix Binary Source: PrivateCode(Yes/No):No --- common_components/heap/collector/trace_collector.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/common_components/heap/collector/trace_collector.cpp b/common_components/heap/collector/trace_collector.cpp index 21f1e9b69b..7a3b1f905b 100755 --- a/common_components/heap/collector/trace_collector.cpp +++ b/common_components/heap/collector/trace_collector.cpp @@ -579,6 +579,7 @@ void TraceCollector::PreGarbageCollection(bool isConcurrent) gcStats.collectedBytes = 0; gcStats.smallGarbageSize = 0; gcStats.pinnedGarbageSize = 0; + gcStats.largeGarbageSize = 0; gcStats.gcStartTime = TimeUtil::NanoSeconds(); gcStats.totalSTWTime = 0; gcStats.maxSTWTime = 0; -- Gitee