diff --git a/common_components/heap/collector/trace_collector.cpp b/common_components/heap/collector/trace_collector.cpp index 21f1e9b69b5e0f8601336788ac5199a35046ece3..7a3b1f905bdc8095cc009773c061f7fa6e54ac89 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; diff --git a/ecmascript/base/json_parser.cpp b/ecmascript/base/json_parser.cpp index 388dc51500b4501eb84de5f38cd10bc5839dc804..185105f423c98b3f1c8514ea3958891ad7f70302 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 3a17cec311c77c9a7e7eee50903b423961e31663..9c9099691d0a98e6ed920629d711b042c17c275b 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);