From d57a2a3b7ce99026ec5690e4c2ae25a9dfa3b210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=BA=91=E9=A3=9E?= Date: Mon, 18 Aug 2025 14:44:28 +0800 Subject: [PATCH] [Bug]: cherry pick !12864 to 5.0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICTFY2?from=project-issue Signed-off-by: 杨云飞 --- ecmascript/js_hclass.cpp | 8 ++---- test/moduletest/BUILD.gn | 1 + test/moduletest/changelistener2/BUILD.gn | 18 +++++++++++++ .../changelistener2/changelistener2.js | 26 +++++++++++++++++++ .../changelistener2/expect_output.txt | 12 +++++++++ 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 test/moduletest/changelistener2/BUILD.gn create mode 100644 test/moduletest/changelistener2/changelistener2.js create mode 100644 test/moduletest/changelistener2/expect_output.txt diff --git a/ecmascript/js_hclass.cpp b/ecmascript/js_hclass.cpp index 4a8248213e..8c99cc3aaf 100644 --- a/ecmascript/js_hclass.cpp +++ b/ecmascript/js_hclass.cpp @@ -1093,13 +1093,9 @@ void JSHClass::RefreshUsers(const JSThread *thread, const JSHandle &ol ASSERT(newHclass->IsPrototype()); bool onceRegistered = UnregisterOnProtoChain(thread, oldHclass); - // oldHclass is already marked. Only update newHclass.protoChangeDetails if it doesn't exist for further use. - if (!newHclass->GetProtoChangeDetails().IsProtoChangeDetails()) { - newHclass->SetProtoChangeDetails(thread, oldHclass->GetProtoChangeDetails()); - } + newHclass->SetProtoChangeDetails(thread, oldHclass->GetProtoChangeDetails()); + oldHclass->SetProtoChangeDetails(thread, JSTaggedValue::Null()); if (onceRegistered) { - ProtoChangeDetails::Cast(oldHclass->GetProtoChangeDetails().GetTaggedObject()) - ->SetRegisterIndex(ProtoChangeDetails::UNREGISTERED); if (newHclass->GetProtoChangeDetails().IsProtoChangeDetails()) { ProtoChangeDetails::Cast(newHclass->GetProtoChangeDetails().GetTaggedObject()) ->SetRegisterIndex(ProtoChangeDetails::UNREGISTERED); diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 3cc9aa0f12..23bc21f685 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -49,6 +49,7 @@ group("ark_js_moduletest") { "callframe", "calltype", "changelistener", + "changelistener2", "class", "clampedarray", "compareobjecthclass", diff --git a/test/moduletest/changelistener2/BUILD.gn b/test/moduletest/changelistener2/BUILD.gn new file mode 100644 index 0000000000..90f5da99ce --- /dev/null +++ b/test/moduletest/changelistener2/BUILD.gn @@ -0,0 +1,18 @@ +# 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_moduletest_action("changelistener2") { + deps = [] +} diff --git a/test/moduletest/changelistener2/changelistener2.js b/test/moduletest/changelistener2/changelistener2.js new file mode 100644 index 0000000000..f0e3d76d86 --- /dev/null +++ b/test/moduletest/changelistener2/changelistener2.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +{ + var int_arr = new Int16Array(2); + for (let i = 0; i < 10000; i++) {} + var a = int_arr.findIndex; + var arr1 = new Array(1); + int_arr.__proto__ = arr1; + var arr = new Array(1); + Int16Array.prototype.__proto__ = arr; + arr.__proto__ = int_arr; + arr["a"] = 7; +} diff --git a/test/moduletest/changelistener2/expect_output.txt b/test/moduletest/changelistener2/expect_output.txt new file mode 100644 index 0000000000..f6f89a09ae --- /dev/null +++ b/test/moduletest/changelistener2/expect_output.txt @@ -0,0 +1,12 @@ +# 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