mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 04:00:37 +00:00
commit
c4f04ac3b1
@ -1713,10 +1713,20 @@ GateRef BuiltinsStringStubBuilder::StringConcat(GateRef glue, GateRef leftString
|
||||
Label exit(env);
|
||||
Label equalZero(env);
|
||||
Label notEqualZero(env);
|
||||
Label lessThanMax(env);
|
||||
Label throwError(env);
|
||||
|
||||
GateRef leftLength = GetLengthFromString(leftString);
|
||||
GateRef rightLength = GetLengthFromString(rightString);
|
||||
GateRef newLength = Int32Add(leftLength, rightLength);
|
||||
Branch(Int32GreaterThanOrEqual(newLength, Int32(EcmaString::MAX_STRING_LENGTH)), &throwError, &lessThanMax);
|
||||
Bind(&throwError);
|
||||
{
|
||||
GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(InvalidStringLength));
|
||||
CallRuntime(glue, RTSTUB_ID(ThrowRangeError), { IntToTaggedInt(taggedId) });
|
||||
Jump(&exit);
|
||||
}
|
||||
Bind(&lessThanMax);
|
||||
Branch(Int32Equal(newLength, Int32(0)), &equalZero, ¬EqualZero);
|
||||
Bind(&equalZero);
|
||||
{
|
||||
|
@ -42,7 +42,8 @@ namespace panda::ecmascript {
|
||||
V(LenGreaterThanMax, "len is bigger than 2^32 - 1") \
|
||||
V(ElementTypeNoElementTypes, "CreateListFromArrayLike: not an element of elementTypes") \
|
||||
V(TargetIsDetachedBuffer, "Is Detached Buffer") \
|
||||
V(ThisBranchIsUnreachable, "this branch is unreachable")
|
||||
V(ThisBranchIsUnreachable, "this branch is unreachable") \
|
||||
V(InvalidStringLength, "Invalid string length")
|
||||
|
||||
#define DEBUG_CHECK_MESSAGE_STRING_LIST(V) \
|
||||
V(IsCallable) \
|
||||
|
@ -1532,6 +1532,16 @@ DEF_RUNTIME_STUBS(ThrowTypeError)
|
||||
THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), JSTaggedValue::Hole().GetRawData());
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(ThrowRangeError)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(ThrowRangeError);
|
||||
JSTaggedValue argMessageStringId = GetArg(argv, argc, 0);
|
||||
std::string message = MessageString::GetMessageString(argMessageStringId.GetInt());
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSObject> error = factory->GetJSError(ErrorType::RANGE_ERROR, message.c_str());
|
||||
THROW_NEW_ERROR_AND_RETURN_VALUE(thread, error.GetTaggedValue(), JSTaggedValue::Hole().GetRawData());
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(LoadMiss)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(LoadMiss);
|
||||
|
@ -341,7 +341,8 @@ using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, co
|
||||
V(HClassCloneWithAddProto) \
|
||||
V(LocaleCompareWithGc) \
|
||||
V(ArrayForEachContinue) \
|
||||
V(NumberDictionaryPut)
|
||||
V(NumberDictionaryPut) \
|
||||
V(ThrowRangeError)
|
||||
|
||||
#define RUNTIME_STUB_LIST(V) \
|
||||
RUNTIME_ASM_STUB_LIST(V) \
|
||||
|
@ -105,6 +105,7 @@ group("ark_js_moduletest") {
|
||||
"propertydetector",
|
||||
"protobuf",
|
||||
"proxy",
|
||||
"rangeerror",
|
||||
"regexpcallthrow",
|
||||
"regexpflagd",
|
||||
"require",
|
||||
@ -238,6 +239,7 @@ group("ark_asm_test") {
|
||||
"promise",
|
||||
"propertydetector",
|
||||
"proxy",
|
||||
"rangeerror",
|
||||
"regexpcallthrow",
|
||||
"regexpflagd",
|
||||
"setobjectwithproto",
|
||||
@ -355,6 +357,7 @@ group("ark_asm_single_step_test") {
|
||||
"promise",
|
||||
"propertydetector",
|
||||
"proxy",
|
||||
"rangeerror",
|
||||
"regexpcallthrow",
|
||||
"regexpflagd",
|
||||
"setobjectwithproto",
|
||||
|
18
test/moduletest/rangeerror/BUILD.gn
Normal file
18
test/moduletest/rangeerror/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 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("rangeerror") {
|
||||
deps = []
|
||||
}
|
14
test/moduletest/rangeerror/expect_output.txt
Normal file
14
test/moduletest/rangeerror/expect_output.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2023 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: Invalid string length
|
30
test/moduletest/rangeerror/rangeerror.js
Normal file
30
test/moduletest/rangeerror/rangeerror.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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:regexp
|
||||
* @tc.desc:test Regexp
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5NO8G
|
||||
*/
|
||||
try {
|
||||
var v0 = "";
|
||||
var v1 = "";
|
||||
for(var v2 = 0; v2 < 10000; ++v2) {
|
||||
v0 += v0 + v2 + v0 + v1 + v2 + "";
|
||||
}
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
Loading…
Reference in New Issue
Block a user