aot compiler: Allow to control stack boundary check when boundary check is enabled (#3754)
In the AOT compiler, allow the user to control stack boundary check when the boundary
check is enabled (e.g. `wamrc --bounds-checks=1`). Now the code logic is:
1. When `--stack-bounds-checks` is not set, it will be the same value as `--bounds-checks`.
2. When `--stack-bounds-checks` is set, it will be the option value no matter what the
status of `--bounds-checks` is.
This commit is contained in:
@ -2969,12 +2969,12 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||||||
sizeof(comp_ctx->target_arch));
|
sizeof(comp_ctx->target_arch));
|
||||||
|
|
||||||
if (option->bounds_checks == 1 || option->bounds_checks == 0) {
|
if (option->bounds_checks == 1 || option->bounds_checks == 0) {
|
||||||
/* Set by user */
|
/* Set by the user */
|
||||||
comp_ctx->enable_bound_check =
|
comp_ctx->enable_bound_check =
|
||||||
(option->bounds_checks == 1) ? true : false;
|
(option->bounds_checks == 1) ? true : false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Unset by user, use default value */
|
/* Unset by the user, use the default value */
|
||||||
if (strstr(comp_ctx->target_arch, "64")
|
if (strstr(comp_ctx->target_arch, "64")
|
||||||
&& !option->is_sgx_platform) {
|
&& !option->is_sgx_platform) {
|
||||||
comp_ctx->enable_bound_check = false;
|
comp_ctx->enable_bound_check = false;
|
||||||
@ -2984,17 +2984,17 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comp_ctx->enable_bound_check) {
|
if (option->stack_bounds_checks == 1
|
||||||
/* Always enable stack boundary check if `bounds-checks`
|
|| option->stack_bounds_checks == 0) {
|
||||||
is enabled */
|
/* Set by the user */
|
||||||
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 =
|
comp_ctx->enable_stack_bound_check =
|
||||||
(option->stack_bounds_checks == 1) ? true : false;
|
(option->stack_bounds_checks == 1) ? true : false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* Unset by the user, use the default value, it will be the same
|
||||||
|
* value as the bound check */
|
||||||
|
comp_ctx->enable_stack_bound_check = comp_ctx->enable_bound_check;
|
||||||
|
}
|
||||||
|
|
||||||
if ((comp_ctx->enable_stack_bound_check
|
if ((comp_ctx->enable_stack_bound_check
|
||||||
|| comp_ctx->enable_stack_estimation)
|
|| comp_ctx->enable_stack_estimation)
|
||||||
|
|||||||
@ -5739,6 +5739,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||||||
/* use memmove when memory64 is enabled since len
|
/* use memmove when memory64 is enabled since len
|
||||||
may be larger than UINT32_MAX */
|
may be larger than UINT32_MAX */
|
||||||
memmove(mdst, msrc, len);
|
memmove(mdst, msrc, len);
|
||||||
|
(void)dlen;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,9 +142,7 @@ print_help()
|
|||||||
printf(" with a runtime without the hardware bounds checks.\n");
|
printf(" with a runtime without the hardware bounds checks.\n");
|
||||||
printf(" --stack-bounds-checks=1/0 Enable or disable the bounds checks for native stack:\n");
|
printf(" --stack-bounds-checks=1/0 Enable or disable the bounds checks for native stack:\n");
|
||||||
printf(" if the option isn't set, the status is same as `--bounds-check`,\n");
|
printf(" if the option isn't set, the status is same as `--bounds-check`,\n");
|
||||||
printf(" if the option is set:\n");
|
printf(" if the option is set, the status is same as the option value\n");
|
||||||
printf(" (1) it is always enabled when `--bounds-checks` is enabled,\n");
|
|
||||||
printf(" (2) else it is enabled/disabled according to the option value\n");
|
|
||||||
printf(" --stack-usage=<file> Generate a stack-usage file.\n");
|
printf(" --stack-usage=<file> Generate a stack-usage file.\n");
|
||||||
printf(" Similarly to `clang -fstack-usage`.\n");
|
printf(" Similarly to `clang -fstack-usage`.\n");
|
||||||
printf(" --format=<format> Specifies the format of the output file\n");
|
printf(" --format=<format> Specifies the format of the output file\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user