mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-26 19:50:55 +00:00
!9670 Fix error uncaught exception in AOT mode
Merge pull request !9670 from xuan0126/master
This commit is contained in:
commit
97a63e1f3a
@ -1547,7 +1547,7 @@ void NativeInlineLowering::TryInlineArrayForEach(GateRef gate, size_t argc, Buil
|
||||
} else {
|
||||
ret = builder_.ArrayForEach(thisValue, callBackFn, acc_.GetValueIn(gate, 2), pcOffset); // 2:provide using This
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArrayFindOrFindIndex(GateRef gate,
|
||||
@ -1588,7 +1588,7 @@ void NativeInlineLowering::TryInlineArrayFindOrFindIndex(GateRef gate,
|
||||
ret = builder_.ArrayFindOrFindIndex(
|
||||
thisValue, callBackFn, acc_.GetValueIn(gate, 2), callIDRef, pcOffset); // 2:provide using This
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArrayFilter(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
|
||||
@ -1624,7 +1624,7 @@ void NativeInlineLowering::TryInlineArrayFilter(GateRef gate, size_t argc, Built
|
||||
ret = builder_.ArrayFilter(
|
||||
thisValue, callBackFn, acc_.GetValueIn(gate, 2), frameState, pcOffset); //2: provide usingThis
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArrayMap(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
|
||||
@ -1660,7 +1660,7 @@ void NativeInlineLowering::TryInlineArrayMap(GateRef gate, size_t argc, Builtins
|
||||
ret = builder_.ArrayMap(
|
||||
thisValue, callBackFn, acc_.GetValueIn(gate, 2), frameState, pcOffset); //2: provide usingThis
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArraySome(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
|
||||
@ -1694,7 +1694,7 @@ void NativeInlineLowering::TryInlineArraySome(GateRef gate, size_t argc, Builtin
|
||||
} else {
|
||||
ret = builder_.ArraySome(thisValue, callBackFn, acc_.GetValueIn(gate, 2), pcOffset); //2: provide usingThis
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArrayEvery(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
|
||||
@ -1728,7 +1728,7 @@ void NativeInlineLowering::TryInlineArrayEvery(GateRef gate, size_t argc, Builti
|
||||
} else {
|
||||
ret = builder_.ArrayEvery(thisValue, callBackFn, acc_.GetValueIn(gate, 2), pcOffset); //2: provide usingThis
|
||||
}
|
||||
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), ret);
|
||||
}
|
||||
|
||||
void NativeInlineLowering::TryInlineArrayPop(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
|
||||
|
@ -3371,9 +3371,7 @@ void SlowPathLowering::LowerCallInternal(GateRef gate)
|
||||
DEFVALUE(res, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
|
||||
LowerFastCall(gate, glue_, func, argc, args, argsFastCall, &res, &exit, false);
|
||||
builder_.Bind(&exit);
|
||||
GateRef stateInGate = builder_.GetState();
|
||||
GateRef depend = builder_.GetDepend();
|
||||
ReplaceHirWithPendingException(gate, stateInGate, depend, *res);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *res);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerCallNew(GateRef gate)
|
||||
|
@ -3150,6 +3150,21 @@ IterationKind TypedNativeInlineLowering::GetArrayIterKindFromBuilin(BuiltinsStub
|
||||
}
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::ReplaceGateWithPendingException(
|
||||
GateRef gate, GateRef glue, GateRef state, GateRef depend, GateRef value)
|
||||
{
|
||||
GateRef condition = builder_.HasPendingException(glue);
|
||||
auto ifBranch = builder_.Branch(state, condition, 1, BranchWeight::DEOPT_WEIGHT, "checkException");
|
||||
GateRef ifTrue = builder_.IfTrue(ifBranch);
|
||||
GateRef ifFalse = builder_.IfFalse(ifBranch);
|
||||
GateRef eDepend = builder_.DependRelay(ifTrue, depend);
|
||||
GateRef sDepend = builder_.DependRelay(ifFalse, depend);
|
||||
StateDepend success(ifFalse, sDepend);
|
||||
StateDepend exception(ifTrue, eDepend);
|
||||
acc_.ReplaceHirWithIfBranch(gate, success, exception, value);
|
||||
}
|
||||
|
||||
|
||||
void TypedNativeInlineLowering::LowerArrayForEach(GateRef gate)
|
||||
{
|
||||
Environment env(gate, circuit_, &builder_);
|
||||
@ -3161,16 +3176,16 @@ void TypedNativeInlineLowering::LowerArrayForEach(GateRef gate)
|
||||
Label loopHead(&builder_);
|
||||
Label loopEnd(&builder_);
|
||||
Label exit(&builder_);
|
||||
Label NotHole(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
Label merge(&builder_);
|
||||
DEFVALUE(i, (&builder_), VariableType::INT32(), builder_.Int32(0));
|
||||
DEFVALUE(propKey, (&builder_), VariableType::JS_ANY(), builder_.ToTaggedIntPtr(builder_.SExtInt32ToInt64(*i)));
|
||||
DEFVALUE(value, (&builder_), VariableType::JS_ANY(), builder_.Hole());
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopHead, &exit);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
GateRef element = builder_.LoadConstOffset(VariableType::JS_POINTER(), thisValue, JSObject::ELEMENTS_OFFSET);
|
||||
value = builder_.GetValueFromTaggedArray(element, *i);
|
||||
{
|
||||
GateRef element = builder_.LoadConstOffset(VariableType::JS_POINTER(), thisValue, JSObject::ELEMENTS_OFFSET);
|
||||
value = builder_.GetValueFromTaggedArray(element, *i);
|
||||
GateRef nativeCall = builder_.CallInternal(gate,
|
||||
{glue,
|
||||
builder_.Int64(6),
|
||||
@ -3183,17 +3198,19 @@ void TypedNativeInlineLowering::LowerArrayForEach(GateRef gate)
|
||||
thisValue},
|
||||
acc_.TryGetPcOffset(gate));
|
||||
builder_.SetDepend(nativeCall);
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
propKey = builder_.ToTaggedIntPtr(builder_.SExtInt32ToInt64(*i));
|
||||
builder_.Jump(&merge);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &exit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
propKey = builder_.ToTaggedIntPtr(builder_.SExtInt32ToInt64(*i));
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
}
|
||||
builder_.Bind(&merge);
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopEnd, &exit);
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
|
||||
builder_.Bind(&exit);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), builder_.UndefineConstant());
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), builder_.UndefineConstant());
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::LowerArrayFindOrFindIndex(GateRef gate)
|
||||
@ -3210,20 +3227,21 @@ void TypedNativeInlineLowering::LowerArrayFindOrFindIndex(GateRef gate)
|
||||
Label loopHead(&builder_);
|
||||
Label loopEnd(&builder_);
|
||||
Label exit(&builder_);
|
||||
Label afterLoop(&builder_);
|
||||
Label noFindElement(&builder_);
|
||||
Label findElement(&builder_);
|
||||
Label returnNotFind(&builder_);
|
||||
Label returnFind(&builder_);
|
||||
Label quit(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
DEFVALUE(i, (&builder_), VariableType::INT32(), builder_.Int32(0));
|
||||
DEFVALUE(value, (&builder_), VariableType::JS_ANY(), builder_.Hole());
|
||||
DEFVALUE(res, (&builder_), VariableType::INT32(), builder_.Int32(-1));
|
||||
DEFVALUE(findRes, (&builder_), VariableType::JS_ANY(), builder_.UndefineConstant());
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopHead, &exit);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
GateRef element = builder_.LoadConstOffset(VariableType::JS_POINTER(), thisValue, JSObject::ELEMENTS_OFFSET);
|
||||
value = builder_.GetValueFromTaggedArray(element, *i);
|
||||
{
|
||||
GateRef element = builder_.LoadConstOffset(VariableType::JS_POINTER(), thisValue, JSObject::ELEMENTS_OFFSET);
|
||||
value = builder_.GetValueFromTaggedArray(element, *i);
|
||||
GateRef nativeCall = builder_.CallInternal(gate,
|
||||
{glue,
|
||||
builder_.Int64(6),
|
||||
@ -3236,13 +3254,20 @@ void TypedNativeInlineLowering::LowerArrayFindOrFindIndex(GateRef gate)
|
||||
thisValue},
|
||||
acc_.TryGetPcOffset(gate));
|
||||
builder_.SetDepend(nativeCall);
|
||||
BRANCH_CIR(builder_.TaggedIsTrue(builder_.FastToBoolean(nativeCall)), &findElement, &afterLoop);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &exit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
BRANCH_CIR(builder_.TaggedIsTrue(builder_.FastToBoolean(nativeCall)), &findElement, &noFindElement);
|
||||
builder_.Bind(&noFindElement);
|
||||
{
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
i = builder_.Int32Add(*i, builder_.Int32(1));
|
||||
BRANCH_CIR(builder_.Int32LessThan(*i, length), &loopEnd, &exit);
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
|
||||
builder_.Bind(&findElement);
|
||||
{
|
||||
res = *i;
|
||||
@ -3251,9 +3276,9 @@ void TypedNativeInlineLowering::LowerArrayFindOrFindIndex(GateRef gate)
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
if (builtinsID == BuiltinsStubCSigns::ID::ArrayFind) {
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *findRes);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *findRes);
|
||||
} else {
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *res);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3280,6 +3305,7 @@ void TypedNativeInlineLowering::LowerArrayFilter(GateRef gate)
|
||||
Label exit(&builder_);
|
||||
Label needTrim(&builder_);
|
||||
Label quit(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
|
||||
DEFVALUE(i, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
DEFVALUE(toIndex, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
@ -3300,8 +3326,8 @@ void TypedNativeInlineLowering::LowerArrayFilter(GateRef gate)
|
||||
GateRef newArrayEles = builder_.GetElementsArray(newArray);
|
||||
builder_.Jump(&loopHead);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
kValue = builtinsArrayStubBuilder.GetTaggedValueWithElementsKind(thisValue, *i);
|
||||
{
|
||||
kValue = builtinsArrayStubBuilder.GetTaggedValueWithElementsKind(thisValue, *i);
|
||||
GateRef callJs = builder_.CallInternal(gate,
|
||||
{glue,
|
||||
builder_.Int64(6),
|
||||
@ -3314,25 +3340,29 @@ void TypedNativeInlineLowering::LowerArrayFilter(GateRef gate)
|
||||
thisValue},
|
||||
pcOffset);
|
||||
builder_.SetDepend(callJs);
|
||||
BRANCH_CIR(builder_.TaggedIsTrue(builder_.FastToBoolean(callJs)), &returnTrue, &afterLoop);
|
||||
builder_.Bind(&returnTrue);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &quit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
builtinsArrayStubBuilder.SetValueWithElementsKind(
|
||||
glue,
|
||||
newArray,
|
||||
*kValue,
|
||||
*toIndex,
|
||||
builder_.Boolean(true),
|
||||
builder_.Int32(static_cast<uint32_t>(ElementsKind::NONE)));
|
||||
toIndex = builder_.Int64Add(*toIndex, builder_.Int64(1));
|
||||
builder_.Jump(&afterLoop);
|
||||
BRANCH_CIR(builder_.TaggedIsTrue(builder_.FastToBoolean(callJs)), &returnTrue, &afterLoop);
|
||||
builder_.Bind(&returnTrue);
|
||||
{
|
||||
builtinsArrayStubBuilder.SetValueWithElementsKind(
|
||||
glue,
|
||||
newArray,
|
||||
*kValue,
|
||||
*toIndex,
|
||||
builder_.Boolean(true),
|
||||
builder_.Int32(static_cast<uint32_t>(ElementsKind::NONE)));
|
||||
toIndex = builder_.Int64Add(*toIndex, builder_.Int64(1));
|
||||
builder_.Jump(&afterLoop);
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
@ -3350,7 +3380,7 @@ void TypedNativeInlineLowering::LowerArrayFilter(GateRef gate)
|
||||
builder_.Jump(&quit);
|
||||
}
|
||||
builder_.Bind(&quit);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
@ -3370,11 +3400,11 @@ void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
Label notHole(&builder_);
|
||||
Label loopHead(&builder_);
|
||||
Label loopEnd(&builder_);
|
||||
Label afterLoop(&builder_);
|
||||
Label returnTrue(&builder_);
|
||||
Label exit(&builder_);
|
||||
Label needTrim(&builder_);
|
||||
Label finish(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
|
||||
DEFVALUE(i, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
DEFVALUE(toIndex, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
@ -3394,8 +3424,8 @@ void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
GateRef newArray = builtinsArrayStubBuilder.NewArray(glue, length);
|
||||
builder_.Jump(&loopHead);
|
||||
builder_.LoopBegin(&loopHead);
|
||||
kValue = builtinsArrayStubBuilder.GetTaggedValueWithElementsKind(thisValue, *i);
|
||||
{
|
||||
kValue = builtinsArrayStubBuilder.GetTaggedValueWithElementsKind(thisValue, *i);
|
||||
GateRef callJs = builder_.CallInternal(gate,
|
||||
{glue,
|
||||
builder_.Int64(6),
|
||||
@ -3408,6 +3438,8 @@ void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
thisValue},
|
||||
pcOffset);
|
||||
builder_.SetDepend(callJs);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &exit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
builtinsArrayStubBuilder.SetValueWithElementsKind(
|
||||
glue,
|
||||
@ -3417,15 +3449,12 @@ void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
builder_.Boolean(true),
|
||||
builder_.Int32(static_cast<uint32_t>(ElementsKind::NONE)));
|
||||
toIndex = builder_.Int64Add(*toIndex, builder_.Int64(1));
|
||||
builder_.Jump(&afterLoop);
|
||||
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &finish);
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &finish);
|
||||
}
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
|
||||
@ -3435,7 +3464,7 @@ void TypedNativeInlineLowering::LowerArrayMap(GateRef gate)
|
||||
builder_.Jump(&exit);
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::LowerArraySome(GateRef gate)
|
||||
@ -3457,6 +3486,7 @@ void TypedNativeInlineLowering::LowerArraySome(GateRef gate)
|
||||
Label afterLoop(&builder_);
|
||||
Label exit(&builder_);
|
||||
Label findElement(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.TaggedFalse());
|
||||
DEFVALUE(i, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
DEFVALUE(propKey, (&builder_), VariableType::JS_ANY(), builder_.ToTaggedIntPtr(*i));
|
||||
@ -3483,16 +3513,18 @@ void TypedNativeInlineLowering::LowerArraySome(GateRef gate)
|
||||
thisValue},
|
||||
pcOffset);
|
||||
builder_.SetDepend(callJs);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &exit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
BRANCH_CIR(builder_.TaggedIsTrue(builder_.FastToBoolean(callJs)), &findElement, &afterLoop);
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
|
||||
@ -3502,7 +3534,7 @@ void TypedNativeInlineLowering::LowerArraySome(GateRef gate)
|
||||
builder_.Jump(&exit);
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::LowerArrayEvery(GateRef gate)
|
||||
@ -3524,6 +3556,7 @@ void TypedNativeInlineLowering::LowerArrayEvery(GateRef gate)
|
||||
Label afterLoop(&builder_);
|
||||
Label exit(&builder_);
|
||||
Label callResultNotTrue(&builder_);
|
||||
Label noPendingException(&builder_);
|
||||
DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.TaggedTrue());
|
||||
DEFVALUE(i, (&builder_), VariableType::INT64(), builder_.Int64(0));
|
||||
DEFVALUE(propKey, (&builder_), VariableType::JS_ANY(), builder_.ToTaggedIntPtr(*i));
|
||||
@ -3550,16 +3583,18 @@ void TypedNativeInlineLowering::LowerArrayEvery(GateRef gate)
|
||||
thisValue},
|
||||
pcOffset);
|
||||
builder_.SetDepend(callJs);
|
||||
BRANCH_CIR(builder_.HasPendingException(glue), &exit, &noPendingException);
|
||||
builder_.Bind(&noPendingException);
|
||||
{
|
||||
BRANCH_CIR(builder_.TaggedIsFalse(builder_.FastToBoolean(callJs)), &callResultNotTrue, &afterLoop);
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
builder_.Bind(&afterLoop);
|
||||
{
|
||||
i = builder_.Int64Add(*i, builder_.Int64(1));
|
||||
propKey = builder_.ToTaggedIntPtr(*i);
|
||||
BRANCH_CIR(builder_.Int64LessThan(*i, length), &loopEnd, &exit);
|
||||
}
|
||||
builder_.Bind(&loopEnd);
|
||||
builder_.LoopEnd(&loopHead);
|
||||
|
||||
@ -3569,7 +3604,7 @@ void TypedNativeInlineLowering::LowerArrayEvery(GateRef gate)
|
||||
builder_.Jump(&exit);
|
||||
}
|
||||
builder_.Bind(&exit);
|
||||
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
ReplaceGateWithPendingException(gate, glue, builder_.GetState(), builder_.GetDepend(), *result);
|
||||
}
|
||||
|
||||
void TypedNativeInlineLowering::LowerArrayPop(GateRef gate)
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
return ((kind == TARDOU_ARRNUM || kind == NONE) && callID == BuiltinsStubCSigns::ID::ArrayIncludes);
|
||||
}
|
||||
|
||||
void ReplaceGateWithPendingException(GateRef gate, GateRef glue, GateRef state, GateRef depend, GateRef value);
|
||||
void LowerGeneralUnaryMath(GateRef gate, RuntimeStubCSigns::ID stubId);
|
||||
void LowerMathAtan2(GateRef gate);
|
||||
void LowerTrunc(GateRef gate);
|
||||
|
@ -62,6 +62,7 @@ group("ark_aot_ts_test") {
|
||||
"add",
|
||||
"array",
|
||||
"array_foreach_inline",
|
||||
"array_inline_exception",
|
||||
"ashr",
|
||||
"asyncgenerator",
|
||||
"asyncgeneratormultiloop",
|
||||
|
20
test/aottest/array_inline_exception/BUILD.gn
Normal file
20
test/aottest/array_inline_exception/BUILD.gn
Normal file
@ -0,0 +1,20 @@
|
||||
# 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_aot_test_action("array_inline_exception") {
|
||||
deps = []
|
||||
is_enable_opt_inlining = true
|
||||
is_enable_native_inline = true
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare interface ArkTools {
|
||||
isAOTCompiled(args: any): boolean;
|
||||
}
|
||||
declare function print(arg:any):string;
|
||||
|
||||
let arr = [1, 2, 3]
|
||||
|
||||
function arrayInlineException() {
|
||||
try {
|
||||
arr.forEach(() => {throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayForEach exception catched success")
|
||||
}
|
||||
try {
|
||||
arr.find(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayFind exception catched success")
|
||||
}
|
||||
try {
|
||||
arr.findIndex(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayFindIndex exception catched success")
|
||||
}
|
||||
|
||||
try {
|
||||
arr.filter(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayFilter exception catched success")
|
||||
}
|
||||
|
||||
try {
|
||||
arr.map(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayMap exception catched success")
|
||||
}
|
||||
|
||||
try {
|
||||
arr.some(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arraySome exception catched success")
|
||||
}
|
||||
|
||||
try {
|
||||
arr.every(() => { throw new Error('exception')})
|
||||
} catch(e){
|
||||
print("arrayEvery exception catched success")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
arrayInlineException()
|
||||
print("isAOTCompiled: " + ArkTools.isAOTCompiled(arrayInlineException))
|
21
test/aottest/array_inline_exception/expect_output.txt
Normal file
21
test/aottest/array_inline_exception/expect_output.txt
Normal file
@ -0,0 +1,21 @@
|
||||
# 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.
|
||||
|
||||
arrayForEach exception catched success
|
||||
arrayFind exception catched success
|
||||
arrayFindIndex exception catched success
|
||||
arrayFilter exception catched success
|
||||
arrayMap exception catched success
|
||||
arraySome exception catched success
|
||||
arrayEvery exception catched success
|
||||
isAOTCompiled: true
|
Loading…
Reference in New Issue
Block a user