Skip to content

Commit e1921b5

Browse files
committed
Function section's enlargement will be restricted to xtensa only
1 parent 6b51bc0 commit e1921b5

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

core/iwasm/compilation/aot_emit_aot_file.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ get_func_section_size(AOTCompContext *comp_ctx, AOTCompData *comp_data,
873873
const bool need_precheck = obj_data->comp_ctx->enable_stack_bound_check
874874
|| obj_data->comp_ctx->enable_stack_estimation;
875875
/* aot_func#xxx + aot_func_internal#xxx in XIP mode for xtensa */
876-
if (obj_data->comp_ctx->is_indirect_mode && need_precheck)
876+
if (obj_data->comp_ctx->is_indirect_mode && need_precheck
877+
&& !strncmp(obj_data->comp_ctx->target_arch, "xtensa", 6))
877878
size *= 2;
878879

879880
/* max_local_cell_nums */
@@ -2417,7 +2418,8 @@ aot_emit_init_data_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
24172418
offset = align_uint(offset, 4);
24182419
const bool need_precheck = obj_data->comp_ctx->enable_stack_bound_check
24192420
|| obj_data->comp_ctx->enable_stack_estimation;
2420-
if (obj_data->comp_ctx->is_indirect_mode && need_precheck)
2421+
if (obj_data->comp_ctx->is_indirect_mode && need_precheck
2422+
&& !strncmp(obj_data->comp_ctx->target_arch, "xtensa", 6))
24212423
EMIT_U32(comp_data->func_count * 2);
24222424
else
24232425
EMIT_U32(comp_data->func_count);
@@ -2607,7 +2609,8 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
26072609

26082610
const bool need_precheck = obj_data->comp_ctx->enable_stack_bound_check
26092611
|| obj_data->comp_ctx->enable_stack_estimation;
2610-
if (obj_data->comp_ctx->is_indirect_mode && need_precheck) {
2612+
if (obj_data->comp_ctx->is_indirect_mode && need_precheck
2613+
&& !strncmp(obj_data->comp_ctx->target_arch, "xtensa", 6)) {
26112614
/*
26122615
* Explicitly emit aot_func_internal#xxx for Xtensa XIP, therefore,
26132616
* for aot_func#xxx, func_indexes ranged from 0 ~ func_count,
@@ -2625,6 +2628,13 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
26252628
for (i = 0; i < comp_data->func_count; i++)
26262629
EMIT_U32(funcs[i]->func_type_index);
26272630

2631+
if (obj_data->comp_ctx->is_indirect_mode && need_precheck
2632+
&& !strncmp(obj_data->comp_ctx->target_arch, "xtensa", 6)) {
2633+
/* func_type_index for aot_func_internal#xxxx */
2634+
for (i = 0; i < comp_data->func_count; i++)
2635+
EMIT_U32(funcs[i]->func_type_index);
2636+
}
2637+
26282638
for (i = 0; i < comp_data->func_count; i++) {
26292639
uint32 max_local_cell_num =
26302640
funcs[i]->param_cell_num + funcs[i]->local_cell_num;
@@ -2688,12 +2698,6 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
26882698
}
26892699
#endif /* end of WASM_ENABLE_GC != 0 */
26902700

2691-
if (obj_data->comp_ctx->is_indirect_mode && need_precheck) {
2692-
/* func_type_index for aot_func_internal#xxxx */
2693-
for (i = 0; i < comp_data->func_count; i++)
2694-
EMIT_U32(funcs[i]->func_type_index);
2695-
}
2696-
26972701
if (offset - *p_offset != section_size + sizeof(uint32) * 2) {
26982702
aot_set_last_error("emit function section failed.");
26992703
return false;

core/iwasm/compilation/aot_llvm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ aot_build_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module,
544544
}
545545

546546
LLVMValueRef retval;
547-
if (comp_ctx->is_indirect_mode) {
547+
if (comp_ctx->is_indirect_mode
548+
&& !strncmp(comp_ctx->target_arch, "xtensa", 6)) {
548549
/* call wrapped_func indirectly */
549550
LLVMTypeRef func_ptr_type;
550551
LLVMValueRef wrapped_func_indirect;

0 commit comments

Comments
 (0)