diff --git a/ecmascript/js_hclass.cpp b/ecmascript/js_hclass.cpp index 4a8248213ecd04e57b39a7e8bc20d0f549c66b1a..8c99cc3aaf6cb7b350caabdb11ae06caac3efdaa 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 516ce7b36b22b2a455538e9cf361746fc6c90cc0..98c758cd7dbadf2c484b8f0fb61792e122ac82c9 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 0000000000000000000000000000000000000000..90f5da99ce48c387971045bf6de08b731019426a --- /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 0000000000000000000000000000000000000000..f0e3d76d860d7dac02d403c4e9a4e23c52af53a5 --- /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 0000000000000000000000000000000000000000..f6f89a09aed5ac2bdaf2a02fa4b7d511152e7b0c --- /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.