diff --git a/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp b/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp index 2404124e5e30fe631a2e419773de93d419762793..20171c30a4298b45b6096d41662b2c19acdad442 100644 --- a/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp +++ b/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp @@ -346,8 +346,15 @@ GateRef LinkedHashTableStubBuilder:: Label loopEnd(env); Label next(env); Label loopExit(env); + Label noNumberOfDeletedElements(env); + + Branch(Int32Equal(GetNumberOfDeletedElements(linkedTable), Int32(-1)), &noNumberOfDeletedElements, &loopHead); + Bind(&noNumberOfDeletedElements); + { + res = entry; + Jump(&exit); + } - Jump(&loopHead); LoopBegin(&loopHead); { Branch(Int32GreaterThanOrEqual(*currentEntry, Int32(0)), &next, &loopExit); diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index d3c11c2baadf8ca4660f38b6eacbbeab27b008a4..c77eb056f5c3f230e8e0d4c1910322b34f5e8a59 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -1319,6 +1319,7 @@ DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8) Label ctorIsConstructor(env); Label threadCheck(env); Label isException(env); + Label noException(env); Branch(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath); Bind(&ctorIsHeapObject); @@ -1337,6 +1338,8 @@ DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8) Bind(&ctorNotBase); GateRef argvLen = Load(VariableType::INT32(), array, IntPtr(JSArray::LENGTH_OFFSET)); GateRef srcElements = GetCallSpreadArgs(glue, array, callback); + Branch(TaggedIsException(srcElements), &isException, &noException); + Bind(&noException); GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM8_V8)); METHOD_ENTRY_ENV_DEFINED(superCtor); GateRef elementsPtr = PtrAdd(srcElements, IntPtr(TaggedArray::DATA_OFFSET)); diff --git a/ecmascript/compiler/stub_builder.cpp b/ecmascript/compiler/stub_builder.cpp index 16db546c8ae3e96b943e181c0871f9fc3a78c8fb..c9a4bca9e05d9c96783aa3f0f57659fc74092ff0 100644 --- a/ecmascript/compiler/stub_builder.cpp +++ b/ecmascript/compiler/stub_builder.cpp @@ -6666,6 +6666,7 @@ GateRef StubBuilder::GetIterator(GateRef glue, GateRef obj, ProfileOperation cal Label noPendingException(env); Label isHeapObject(env); Label objIsCallable(env); + Label throwError(env); GateRef glueGlobalEnvOffset = IntPtr(JSThread::GlueData::GetGlueGlobalEnvOffset(env->Is32Bit())); GateRef glueGlobalEnv = Load(VariableType::NATIVE_POINTER(), glue, glueGlobalEnvOffset); @@ -6686,6 +6687,14 @@ GateRef StubBuilder::GetIterator(GateRef glue, GateRef obj, ProfileOperation cal { result = JSCallDispatch(glue, *result, Int32(0), 0, Circuit::NullGate(), JSCallMode::CALL_GETTER, { obj }, ProfileOperation()); + Branch(TaggedIsHeapObject(*result), &exit, &throwError); + } + + Bind(&throwError); + { + GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(IterNotObject)); + CallRuntime(glue, RTSTUB_ID(ThrowTypeError), { IntToTaggedInt(taggedId) }); + result = Exception(); Jump(&exit); } @@ -7973,8 +7982,17 @@ GateRef StubBuilder::GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOpera Label fastPath(env); Label noCopyPath(env); Label exit(env); + Label noException(env); + Label isException(env); GateRef itor = GetIterator(glue, array, callBack); + Branch(TaggedIsException(itor), &isException, &noException); + Bind(&isException); + { + result = Exception(); + Jump(&exit); + } + Bind(&noException); GateRef iterHClass = LoadHClass(itor); GateRef isJSArrayIter = Int32Equal(GetObjectType(iterHClass), Int32(static_cast(JSType::JS_ARRAY_ITERATOR))); diff --git a/ecmascript/js_date_time_format.cpp b/ecmascript/js_date_time_format.cpp index 4c4eb0e3e3cadb1960bf4b43c5ce7b97c69925c9..e15e703e363c31c4f44ecceb4a9214d9ccca984d 100644 --- a/ecmascript/js_date_time_format.cpp +++ b/ecmascript/js_date_time_format.cpp @@ -1521,31 +1521,23 @@ std::string JSDateTimeFormat::ToTitleCaseFunction(const std::string &input) return result; } -bool JSDateTimeFormat::IsValidTimeZoneInput(const std::string &input) -{ - std::regex r("[a-zA-Z_\\-/]*"); - bool isValid = regex_match(input, r); - return isValid; -} - std::string JSDateTimeFormat::ToTitleCaseTimezonePosition(const std::string &input) { - if (!IsValidTimeZoneInput(input)) { - return std::string(); - } std::vector titleEntry; std::vector charEntry; - int32_t leftPosition = 0; - int32_t titleLength = 0; - for (int32_t i = 0; i < static_cast(input.length()); i++) { + uint32_t leftPosition = 0; + uint32_t titleLength = 0; + for (size_t i = 0; i < input.length(); i++) { if (input[i] == '_' || input[i] == '-' || input[i] == '/') { std::string s(1, input[i]); charEntry.emplace_back(s); titleLength = i - leftPosition; titleEntry.emplace_back(input.substr(leftPosition, titleLength)); leftPosition = i + 1; - } else { + } else if (JSLocale::IsAsciiAlpha(input[i]) || input[i] == '\\') { continue; + } else { + return std::string(); } } titleEntry.emplace_back(input.substr(leftPosition, input.length() - leftPosition)); diff --git a/ecmascript/js_date_time_format.h b/ecmascript/js_date_time_format.h index 08aedfc43a1040dba4ea4ee125574f7505d3bd7f..48a41543a8ffa17657432d81c6a7ab02c97b7693 100644 --- a/ecmascript/js_date_time_format.h +++ b/ecmascript/js_date_time_format.h @@ -209,8 +209,6 @@ private: static std::string ToTitleCaseFunction(const std::string &input); - static bool IsValidTimeZoneInput(const std::string &input); - static JSHandle ToValueString(JSThread *thread, Value value); static icu::FormattedDateInterval ConstructDTFRange(JSThread *thread, const JSHandle &dtf, diff --git a/ecmascript/js_for_in_iterator.cpp b/ecmascript/js_for_in_iterator.cpp index 8cc70aa4b574010f1059dc808bbdc042abeb5813..6d8a1bc44b5139b012ad35c6cf5b3609d69499b6 100644 --- a/ecmascript/js_for_in_iterator.cpp +++ b/ecmascript/js_for_in_iterator.cpp @@ -120,6 +120,7 @@ JSTaggedValue JSForInIterator::NextInternalSlowpath(JSThread *thread, const JSHa break; } has = HasProperty(thread, receiverHandle, keyHandle); + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (has) { break; } diff --git a/ecmascript/message_string.h b/ecmascript/message_string.h index bc42677bf1b693597637facee56cdd8d97a73f18..ff1b4322fa71ef83e6ad0d73ccae23cf4b37e128 100644 --- a/ecmascript/message_string.h +++ b/ecmascript/message_string.h @@ -55,7 +55,8 @@ namespace panda::ecmascript { V(CanNotConvertUnknowObject, "Cannot convert a Unknown object value to a JSObject") \ V(CanNotConvertNotValidObject, "Obj is not a valid object") \ V(CanNotConvertContainerObject, "Can not delete property in Container Object") \ - V(InvalidStringLength, "Invalid string length") + V(InvalidStringLength, "Invalid string length") \ + V(IterNotObject, "JSIterator::GetIterator: iter is not object") #define DEBUG_CHECK_MESSAGE_STRING_LIST(V) \ V(IsCallable) \ diff --git a/ecmascript/stubs/runtime_stubs-inl.h b/ecmascript/stubs/runtime_stubs-inl.h index 7e2a4aec045654b1c84f9e53f3aa2149a516536a..1a5132746ffb431bcaa0db288dd44f6e54e3d16f 100644 --- a/ecmascript/stubs/runtime_stubs-inl.h +++ b/ecmascript/stubs/runtime_stubs-inl.h @@ -2619,6 +2619,7 @@ JSTaggedValue RuntimeStubs::RuntimeOptConstructProxy(JSThread *thread, JSHandle< JSHandle newTgt, JSHandle preArgs, JSHandle args) { + STACK_LIMIT_CHECK(thread, JSTaggedValue::Exception()); // step 1 ~ 4 get ProxyHandler and ProxyTarget JSHandle handler(thread, ctor->GetHandler()); if (handler->IsNull()) { diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 84e50ff1c38edff8849fc9537eff5ca697718de2..1c2dffc6f1ed8724607826cf8adad1c6d0520abb 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -84,6 +84,7 @@ group("ark_js_moduletest") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getpropertybyindex", "getunmappedargs", "global", @@ -110,6 +111,7 @@ group("ark_js_moduletest") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "objectcloneproperties", "objectdefineproperties", "objectgetownproperty", @@ -171,6 +173,7 @@ group("ark_js_moduletest") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] @@ -189,6 +192,7 @@ group("ark_js_moduletest") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { @@ -265,6 +269,7 @@ group("ark_asm_test") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getunmappedargs", "global", "globalaccessor", @@ -285,6 +290,7 @@ group("ark_asm_test") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "number", "objectcloneproperties", "objecthasownproperty", @@ -326,6 +332,7 @@ group("ark_asm_test") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] @@ -345,6 +352,7 @@ group("ark_asm_test") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { @@ -406,6 +414,7 @@ group("ark_asm_single_step_test") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getunmappedargs", "global", "globalaccessor", @@ -423,6 +432,7 @@ group("ark_asm_single_step_test") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "objectcloneproperties", "objecthasownproperty", "objectkeys", @@ -458,6 +468,7 @@ group("ark_asm_single_step_test") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] @@ -476,6 +487,7 @@ group("ark_asm_single_step_test") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { diff --git a/test/moduletest/datetimezone/datetimezone.js b/test/moduletest/datetimezone/datetimezone.js index 85223757b11a0f52db19222e2adfd9c4ac92a454..e589c66e01539617cae11492fc70d9966c71c54b 100755 --- a/test/moduletest/datetimezone/datetimezone.js +++ b/test/moduletest/datetimezone/datetimezone.js @@ -16,4 +16,11 @@ try { new Intl.DateTimeFormat("en" , { timeZone: "US/Alaska0" }); } catch (e) { print(e instanceof RangeError); -} \ No newline at end of file +} + +// This case aims to check stack overflow while timeZone is a long string +try { + new Intl.DateTimeFormat("en", {timeZone: Array(0x8000).join("a")}); +} catch (e) { + print(e); +} diff --git a/test/moduletest/datetimezone/expect_output.txt b/test/moduletest/datetimezone/expect_output.txt index ce415d321ab7b920f7a85495b54d7f2a762720f0..355befa0227b877cbcd268a4017d692fcdf049b0 100755 --- a/test/moduletest/datetimezone/expect_output.txt +++ b/test/moduletest/datetimezone/expect_output.txt @@ -12,3 +12,4 @@ # limitations under the License. true +RangeError: invalid timeZone diff --git a/test/moduletest/getdeletedelementsat/BUILD.gn b/test/moduletest/getdeletedelementsat/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1e8c7000a94df462140c530d8bf88225df08a524 --- /dev/null +++ b/test/moduletest/getdeletedelementsat/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("getdeletedelementsat") { + deps = [] +} diff --git a/test/moduletest/getdeletedelementsat/expect_output.txt b/test/moduletest/getdeletedelementsat/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..48c2f6e60af0cb8c678bcf17de0f7d2be063ca8a --- /dev/null +++ b/test/moduletest/getdeletedelementsat/expect_output.txt @@ -0,0 +1,14 @@ +# 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. + +Test runs successfully! diff --git a/test/moduletest/getdeletedelementsat/getdeletedelementsat.js b/test/moduletest/getdeletedelementsat/getdeletedelementsat.js new file mode 100644 index 0000000000000000000000000000000000000000..bdbfed988cce40fed3cb60da16a02e144e96ed29 --- /dev/null +++ b/test/moduletest/getdeletedelementsat/getdeletedelementsat.js @@ -0,0 +1,33 @@ +/* + * 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. + */ + +/* + * @tc.name:getdeletedelementsat + * @tc.desc:test GetDeletedElementsAt + * @tc.type: FUNC + * @tc.require: issueIBFP2E + */ + +// This case aims to check return value of GetDeletedElementsAt +{ + let map1 = new Map(); + map1.set(0, 1); + map1.set(1, 2); + map1.set(2, 3); + map1.set(3, 4); + map1.delete(0); + map1.forEach(function () { map1.clear() }); + print("Test runs successfully!"); +} diff --git a/test/moduletest/getiterator/BUILD.gn b/test/moduletest/getiterator/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c6073310882f1b0941b6ea1ec542e4b92c2881ba --- /dev/null +++ b/test/moduletest/getiterator/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("getiterator") { + deps = [] +} diff --git a/test/moduletest/getiterator/expect_output.txt b/test/moduletest/getiterator/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..65a51cc345138b4712174f1f129e353692a880dd --- /dev/null +++ b/test/moduletest/getiterator/expect_output.txt @@ -0,0 +1,14 @@ +# 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. + +TypeError: JSIterator::GetIterator: iter is not object diff --git a/test/moduletest/getiterator/getiterator.js b/test/moduletest/getiterator/getiterator.js new file mode 100644 index 0000000000000000000000000000000000000000..8b625d6ef95013d6777f6adc26347436c2d9ec20 --- /dev/null +++ b/test/moduletest/getiterator/getiterator.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +/* + * @tc.name:getiterator + * @tc.desc:test StubBuilder::GetIterator + * @tc.type: FUNC + * @tc.require: issueIBDZ1R + */ + +// This case aims to test the logic which check the undefined result of GetIterator. +{ + class c2 extends Object {} + Array.prototype[Symbol.iterator] = function () {}; + try { + let myC2 = new c2(); + } catch (error) { + print(error); + } +} diff --git a/test/moduletest/nextinternalslowpath/BUILD.gn b/test/moduletest/nextinternalslowpath/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a3b9aeceef38c30e037285df18efd5064251ad4c --- /dev/null +++ b/test/moduletest/nextinternalslowpath/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("nextinternalslowpath") { + deps = [] +} diff --git a/test/moduletest/nextinternalslowpath/expect_output.txt b/test/moduletest/nextinternalslowpath/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..52a34023e7e1d06d0099ee52c9ddf044b50156ec --- /dev/null +++ b/test/moduletest/nextinternalslowpath/expect_output.txt @@ -0,0 +1,14 @@ +# 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. + +TypeError: Cannot define property diff --git a/test/moduletest/nextinternalslowpath/nextinternalslowpath.js b/test/moduletest/nextinternalslowpath/nextinternalslowpath.js new file mode 100644 index 0000000000000000000000000000000000000000..d77958c34b6fb4d1f815e0936331d7fad1364674 --- /dev/null +++ b/test/moduletest/nextinternalslowpath/nextinternalslowpath.js @@ -0,0 +1,41 @@ +/* + * 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. + */ + +/* + * @tc.name:nextinternalslowpath + * @tc.desc:test JSForInIterator::NextInternalSlowpath + * @tc.type: FUNC + * @tc.require: issueIBJL5S + */ + +// This case aims to test if JSForInIterator::NextInternalSlowpath could return exception. +{ + function test_func() {} + function f0() {} + let v12 = new Proxy(Object.create(null, {x: {enumerable: true}}), { + getOwnPropertyDescriptor(v13, v14) { + if (v13 != null && typeof v13 == "object") { + Object.defineProperty(v13, test_func(), {get: function () {}}); + } + return Reflect.getOwnPropertyDescriptor(v13, v14); + } + }); + try { + for (let v15 in v12) {} + f0([1]); + } catch (e) { + print(e); + } +} diff --git a/test/moduletest/proxyrelease/BUILD.gn b/test/moduletest/proxyrelease/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c7c0016caf7ffa65cb69f02fbc85ef5b57ba1fdd --- /dev/null +++ b/test/moduletest/proxyrelease/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2024 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("proxyrelease") { + deps = [] +} diff --git a/test/moduletest/proxyrelease/expect_output.txt b/test/moduletest/proxyrelease/expect_output.txt new file mode 100644 index 0000000000000000000000000000000000000000..afc93c05cfdea7f7f912d04fb8674df6e633a5b2 --- /dev/null +++ b/test/moduletest/proxyrelease/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2024 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. + +RangeError: Stack overflow! diff --git a/test/moduletest/proxyrelease/proxyrelease.js b/test/moduletest/proxyrelease/proxyrelease.js new file mode 100644 index 0000000000000000000000000000000000000000..e59a33292a97955e0e961c3d5d55c72c070ba871 --- /dev/null +++ b/test/moduletest/proxyrelease/proxyrelease.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 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. + */ + +/* + * @tc.name:proxy + * @tc.desc:test proxy + * @tc.type: FUNC + * @tc.require: issueIBCUJM + */ + +// This case aims to test if there's stack-overflow checking in RuntimeOptConstructProxy +{ + let v0 = new Proxy(function () {}, {}); + for (let v1 = 0; v1 < 10000; v1++) { + v0 = new Proxy(v0, {}); + } + try { + new v0(0); + } catch (error) { + print(error); + } +}