Add control for the native stack check with hardware trap (#1682)
Add a new options to control the native stack hw bound check feature: - Besides the original option `cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1/0`, add a new option `cmake -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1/0` - When the linear memory hw bound check is disabled, the stack hw bound check will be disabled automatically, no matter what the input option is - When the linear memory hw bound check is enabled, the stack hw bound check is enabled/disabled according to the value of input option - Besides the original option `--bounds-checks=1/0`, add a new option `--stack-bounds-checks=1/0` for wamrc Refer to: https://github.com/bytecodealliance/wasm-micro-runtime/issues/1677
This commit is contained in:
@ -1555,8 +1555,22 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
|
||||
|
||||
#ifndef OS_ENABLE_HW_BOUND_CHECK
|
||||
comp_ctx->enable_bound_check = true;
|
||||
/* Always enable stack boundary check if `bounds-checks`
|
||||
is enabled */
|
||||
comp_ctx->enable_stack_bound_check = true;
|
||||
#else
|
||||
comp_ctx->enable_bound_check = false;
|
||||
/* When `bounds-checks` is disabled, we set stack boundary
|
||||
check status according to the compilation option */
|
||||
#if WASM_DISABLE_STACK_HW_BOUND_CHECK != 0
|
||||
/* Native stack overflow check with hardware trap is disabled,
|
||||
we need to enable the check by LLVM JITed/AOTed code */
|
||||
comp_ctx->enable_stack_bound_check = true;
|
||||
#else
|
||||
/* Native stack overflow check with hardware trap is enabled,
|
||||
no need to enable the check by LLVM JITed/AOTed code */
|
||||
comp_ctx->enable_stack_bound_check = false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@ -1868,6 +1882,18 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
|
||||
}
|
||||
}
|
||||
|
||||
if (comp_ctx->enable_bound_check) {
|
||||
/* Always enable stack boundary check if `bounds-checks`
|
||||
is enabled */
|
||||
comp_ctx->enable_stack_bound_check = true;
|
||||
}
|
||||
else {
|
||||
/* When `bounds-checks` is disabled, we set stack boundary
|
||||
check status according to the input option */
|
||||
comp_ctx->enable_stack_bound_check =
|
||||
(option->stack_bounds_checks == 1) ? true : false;
|
||||
}
|
||||
|
||||
os_printf("Create AoT compiler with:\n");
|
||||
os_printf(" target: %s\n", comp_ctx->target_arch);
|
||||
os_printf(" target cpu: %s\n", cpu);
|
||||
|
||||
Reference in New Issue
Block a user