Two throw exception problems

issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9JQBX

Signed-off-by: hecunmao <hecunmao@huawei.com>
Change-Id: I26868b091fbee5637c53ae2e073eee73c18ca1cc
This commit is contained in:
hecunmao 2024-04-25 22:25:33 +08:00
parent 9f0e4b48b4
commit f753765831
4 changed files with 53 additions and 1 deletions

View File

@ -280,6 +280,7 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeBind(EcmaRuntimeCallInfo *argv)
status = JSFunction::SetFunctionName(thread, JSHandle<JSFunctionBase>(boundFunction),
targetName, boundName);
}
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
// Assert: status is not an abrupt completion.
ASSERT_PRINT(status, "DefinePropertyOr failed");
}

View File

@ -1455,10 +1455,18 @@ void BuiltinsTypedArrayStubBuilder::Filter(GateRef glue, GateRef thisValue, Gate
i = Int32Add(*i, Int32(1));
LoopEnd(&loopHead);
Bind(&loopExit);
Label hasException2(env);
Label notHasException2(env);
NewObjectStubBuilder newBuilder(this);
newBuilder.SetParameters(glue, 0);
GateRef newArray = newBuilder.NewTypedArray(glue, thisValue, arrayType, TruncInt64ToInt32(*newArrayLen));
BRANCH(HasPendingException(glue), &hasException2, &notHasException2);
Bind(&hasException2);
{
result->WriteVariable(Exception());
Jump(exit);
}
Bind(&notHasException2);
i = Int32(0);
Label loopHead2(env);
Label loopEnd2(env);
@ -1519,6 +1527,8 @@ void BuiltinsTypedArrayStubBuilder::Slice(GateRef glue, GateRef thisValue, GateR
Label newTypedArray(env);
Label writeVariable(env);
Label copyBuffer(env);
Label hasException0(env);
Label notHasException0(env);
GateRef thisLen = ZExtInt32ToInt64(GetArrayLength(thisValue));
BRANCH(Int64GreaterThanOrEqual(IntPtr(0), numArgs), slowPath, &startTagExists);
Bind(&startTagExists);
@ -1558,6 +1568,13 @@ void BuiltinsTypedArrayStubBuilder::Slice(GateRef glue, GateRef thisValue, GateR
NewObjectStubBuilder newBuilder(this);
newBuilder.SetParameters(glue, 0);
GateRef newArray = newBuilder.NewTypedArray(glue, thisValue, arrayType, TruncInt64ToInt32(*newArrayLen));
BRANCH(HasPendingException(glue), &hasException0, &notHasException0);
Bind(&hasException0);
{
result->WriteVariable(Exception());
Jump(exit);
}
Bind(&notHasException0);
BRANCH(Int32Equal(TruncInt64ToInt32(*newArrayLen), Int32(0)), &writeVariable, &copyBuffer);
Bind(&copyBuffer);
{
@ -1685,6 +1702,15 @@ void BuiltinsTypedArrayStubBuilder::With(GateRef glue, GateRef thisValue, GateRe
NewObjectStubBuilder newBuilder(this);
newBuilder.SetParameters(glue, 0);
GateRef newArray = newBuilder.NewTypedArray(glue, thisValue, jsType, TruncInt64ToInt32(thisLen));
Label hasException0(env);
Label notHasException0(env);
BRANCH(HasPendingException(glue), &hasException0, &notHasException0);
Bind(&hasException0);
{
result->WriteVariable(Exception());
Jump(exit);
}
Bind(&notHasException0);
CallNGCRuntime(glue, RTSTUB_ID(CopyTypedArrayBuffer),
{thisValue, newArray, Int32(0), Int32(0), TruncInt64ToInt32(thisLen),
newBuilder.GetElementSizeFromType(glue, jsType)});

View File

@ -26,3 +26,27 @@ print(holey_array.slice(2, 3)[0]);
print(Object.getOwnPropertyDescriptor(narr, 0));
})();
// This use case takes a long time, but the corresponding bug is only repeated in the debug
let err = [];
err.length=100;
let err_len = 0;
function runNearStackLimit(f) {
function t() {
try {
t();
} catch (e) {
err[err_len++]=e;
f();
}
}; try {
t();
} catch (e) { }
}
const v7 = new Proxy(String, {});
function f0() {
v7.bind();
}
runNearStackLimit(f0);
print("runNearStackLimit test success!");

View File

@ -14,3 +14,4 @@
undefined
3
[object Object]
runNearStackLimit test success!