Implement option for skipping function index in the callstack (#3785)

Also add a script that converts instruction pointers to function indexes (or function names).

https://github.com/bytecodealliance/wasm-micro-runtime/issues/3758
This commit is contained in:
Marcin Kolny
2024-09-11 09:08:37 +01:00
committed by GitHub
parent b882017674
commit 9c2083a27f
8 changed files with 229 additions and 34 deletions

View File

@ -4439,6 +4439,9 @@ aot_obj_data_create(AOTCompContext *comp_ctx)
if (comp_ctx->call_stack_features.frame_per_function) {
obj_data->target_info.feature_flags |= WASM_FEATURE_FRAME_PER_FUNCTION;
}
if (!comp_ctx->call_stack_features.func_idx) {
obj_data->target_info.feature_flags |= WASM_FEATURE_FRAME_NO_FUNC_IDX;
}
bh_print_time("Begin to resolve object file info");

View File

@ -885,25 +885,28 @@ alloc_frame_for_aot_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
}
if (!comp_ctx->is_jit_mode) {
/* aot mode: new_frame->func_idx = func_idx */
func_idx_val = comp_ctx->pointer_size == sizeof(uint64)
? I64_CONST(func_idx)
: I32_CONST(func_idx);
offset = I32_CONST(comp_ctx->pointer_size);
CHECK_LLVM_CONST(func_idx_val);
CHECK_LLVM_CONST(offset);
if (!(func_idx_ptr =
LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, new_frame,
&offset, 1, "func_idx_addr"))
|| !(func_idx_ptr =
LLVMBuildBitCast(comp_ctx->builder, func_idx_ptr,
INTPTR_T_PTR_TYPE, "func_idx_ptr"))) {
aot_set_last_error("llvm get func_idx_ptr failed");
return false;
}
if (!LLVMBuildStore(comp_ctx->builder, func_idx_val, func_idx_ptr)) {
aot_set_last_error("llvm build store failed");
return false;
if (comp_ctx->call_stack_features.func_idx) {
/* aot mode: new_frame->func_idx = func_idx */
func_idx_val = comp_ctx->pointer_size == sizeof(uint64)
? I64_CONST(func_idx)
: I32_CONST(func_idx);
offset = I32_CONST(comp_ctx->pointer_size);
CHECK_LLVM_CONST(func_idx_val);
CHECK_LLVM_CONST(offset);
if (!(func_idx_ptr = LLVMBuildInBoundsGEP2(
comp_ctx->builder, INT8_TYPE, new_frame, &offset, 1,
"func_idx_addr"))
|| !(func_idx_ptr =
LLVMBuildBitCast(comp_ctx->builder, func_idx_ptr,
INTPTR_T_PTR_TYPE, "func_idx_ptr"))) {
aot_set_last_error("llvm get func_idx_ptr failed");
return false;
}
if (!LLVMBuildStore(comp_ctx->builder, func_idx_val,
func_idx_ptr)) {
aot_set_last_error("llvm build store failed");
return false;
}
}
}
else {

View File

@ -70,7 +70,9 @@ aot_alloc_tiny_frame_for_aot_func(AOTCompContext *comp_ctx,
}
/* Save the func_idx on the top of the stack */
ADD_STORE(func_index, wasm_stack_top);
if (comp_ctx->call_stack_features.func_idx) {
ADD_STORE(func_index, wasm_stack_top);
}
/* increment the stack pointer */
INT_CONST(offset, sizeof(AOTTinyFrame), I32_TYPE, true);