Refine AOT exception check when function return (#1752)
Refine AOT exception check in the caller when returning from callee function, remove the exception check instructions when hw bound check is enabled to improve the performance: create guard page to trigger signal handler when exception occurs.
This commit is contained in:
@ -35,7 +35,14 @@ create_func_return_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||
/* Create return IR */
|
||||
LLVMPositionBuilderAtEnd(comp_ctx->builder,
|
||||
func_ctx->func_return_block);
|
||||
if (!aot_build_zero_function_ret(comp_ctx, func_ctx, aot_func_type)) {
|
||||
if (!comp_ctx->enable_bound_check) {
|
||||
if (!aot_emit_exception(comp_ctx, func_ctx, EXCE_ALREADY_THROWN,
|
||||
false, NULL, NULL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!aot_build_zero_function_ret(comp_ctx, func_ctx,
|
||||
aot_func_type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -494,7 +501,8 @@ check_app_addr_and_convert(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
/* Check whether exception was thrown when executing the function */
|
||||
if (!check_call_return(comp_ctx, func_ctx, res)) {
|
||||
if (comp_ctx->enable_bound_check
|
||||
&& !check_call_return(comp_ctx, func_ctx, res)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -707,7 +715,8 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
goto fail;
|
||||
/* Check whether there was exception thrown when executing
|
||||
the function */
|
||||
if (!check_call_return(comp_ctx, func_ctx, res))
|
||||
if (comp_ctx->enable_bound_check
|
||||
&& !check_call_return(comp_ctx, func_ctx, res))
|
||||
goto fail;
|
||||
}
|
||||
else { /* call native func directly */
|
||||
@ -823,7 +832,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
|
||||
/* Check whether there was exception thrown when executing
|
||||
the function */
|
||||
if (!tail_call && !recursive_call
|
||||
if (!tail_call && !recursive_call && comp_ctx->enable_bound_check
|
||||
&& !check_exception_thrown(comp_ctx, func_ctx))
|
||||
goto fail;
|
||||
}
|
||||
@ -1395,7 +1404,8 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
goto fail;
|
||||
|
||||
/* Check whether exception was thrown when executing the function */
|
||||
if (!check_call_return(comp_ctx, func_ctx, res))
|
||||
if (comp_ctx->enable_bound_check
|
||||
&& !check_call_return(comp_ctx, func_ctx, res))
|
||||
goto fail;
|
||||
|
||||
block_curr = LLVMGetInsertBlock(comp_ctx->builder);
|
||||
@ -1454,7 +1464,8 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
|
||||
/* Check whether exception was thrown when executing the function */
|
||||
if (!check_exception_thrown(comp_ctx, func_ctx))
|
||||
if (comp_ctx->enable_bound_check
|
||||
&& !check_exception_thrown(comp_ctx, func_ctx))
|
||||
goto fail;
|
||||
|
||||
if (func_result_count > 0) {
|
||||
|
||||
Reference in New Issue
Block a user