From ed5a945c5c2331c454c93ad6f0364c647a8841bd Mon Sep 17 00:00:00 2001 From: zhangyukun8 Date: Fri, 12 Sep 2025 18:23:38 +0800 Subject: [PATCH] Fix builtins proto class Issue: https://gitcode.com/openharmony/arkcompiler_ets_runtime/issues/11650 Signed-off-by: zhangyukun8 Change-Id: I80541fcfd8e0a77e56b79c04ca7deeb37a038643 --- ecmascript/pgo_profiler/pgo_profiler.cpp | 7 ++++++- test/aottest/BUILD.gn | 1 + test/aottest/builtins_proto/BUILD.gn | 21 +++++++++++++++++++ test/aottest/builtins_proto/builtins_proto.ts | 20 ++++++++++++++++++ test/aottest/builtins_proto/expect_output.txt | 13 ++++++++++++ .../builtins_proto/pgo_expect_output.txt | 13 ++++++++++++ 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 test/aottest/builtins_proto/BUILD.gn create mode 100644 test/aottest/builtins_proto/builtins_proto.ts create mode 100644 test/aottest/builtins_proto/expect_output.txt create mode 100644 test/aottest/builtins_proto/pgo_expect_output.txt diff --git a/ecmascript/pgo_profiler/pgo_profiler.cpp b/ecmascript/pgo_profiler/pgo_profiler.cpp index ba68c4b4f6..6d5c576871 100644 --- a/ecmascript/pgo_profiler/pgo_profiler.cpp +++ b/ecmascript/pgo_profiler/pgo_profiler.cpp @@ -1313,8 +1313,13 @@ void PGOProfiler::DumpDefineClass(ApEntityId abcId, const CString &recordName, E if (IsSkippableObjectTypeSafe(localType)) { return; } - PGODefineOpType objDefType(localType); auto protoOrHClass = ctorFunction->GetProtoOrHClass(thread); + if (protoOrHClass.IsJSHClass() && + !JSHClass::Cast(protoOrHClass.GetTaggedObject())->IsOnlyJSObject()) { + return; + } + + PGODefineOpType objDefType(localType); if (protoOrHClass.IsJSHClass()) { auto ihc = JSHClass::Cast(protoOrHClass.GetTaggedObject()); SetRootProfileType(ihc, ctorAbcId, ctorMethodId, ProfileType::Kind::ClassId); diff --git a/test/aottest/BUILD.gn b/test/aottest/BUILD.gn index 156ce3dc17..e82408d6f6 100644 --- a/test/aottest/BUILD.gn +++ b/test/aottest/BUILD.gn @@ -389,6 +389,7 @@ group("ark_aot_ts_test") { "builtins_number", "builtins_number2", "builtins_parseint", + "builtins_proto", "constructor", "proxy_fast_call", "realm", diff --git a/test/aottest/builtins_proto/BUILD.gn b/test/aottest/builtins_proto/BUILD.gn new file mode 100644 index 0000000000..301ebbb7ec --- /dev/null +++ b/test/aottest/builtins_proto/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_aot_test_action("builtins_proto") { + deps = [] + is_only_typed_path = true + is_enable_pgo = true + log_option = " --log-info=trace" +} diff --git a/test/aottest/builtins_proto/builtins_proto.ts b/test/aottest/builtins_proto/builtins_proto.ts new file mode 100644 index 0000000000..866f52b332 --- /dev/null +++ b/test/aottest/builtins_proto/builtins_proto.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class A extends Promise {} +const v1 = new A(A) +const v2 = v1.catch() +v2.finally(Date) +A.__proto__ = Map \ No newline at end of file diff --git a/test/aottest/builtins_proto/expect_output.txt b/test/aottest/builtins_proto/expect_output.txt new file mode 100644 index 0000000000..13c57e2b67 --- /dev/null +++ b/test/aottest/builtins_proto/expect_output.txt @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/test/aottest/builtins_proto/pgo_expect_output.txt b/test/aottest/builtins_proto/pgo_expect_output.txt new file mode 100644 index 0000000000..13c57e2b67 --- /dev/null +++ b/test/aottest/builtins_proto/pgo_expect_output.txt @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + -- Gitee