@@ -179,6 +179,16 @@ is_little_endian_binary(const AOTObjectData *obj_data)
179
179
return obj_data -> target_info .bin_type & 1 ? false : true;
180
180
}
181
181
182
+ static bool
183
+ need_call_wrapped_indirect (const AOTObjectData * obj_data )
184
+ {
185
+ const bool need_precheck = obj_data -> comp_ctx -> enable_stack_bound_check
186
+ || obj_data -> comp_ctx -> enable_stack_estimation ;
187
+
188
+ return obj_data -> comp_ctx -> is_indirect_mode && need_precheck
189
+ && !strncmp (obj_data -> comp_ctx -> target_arch , "xtensa" , 6 );
190
+ }
191
+
182
192
static bool
183
193
str_starts_with (const char * str , const char * prefix )
184
194
{
@@ -870,11 +880,8 @@ get_func_section_size(AOTCompContext *comp_ctx, AOTCompData *comp_data,
870
880
/* function type indexes */
871
881
size += (uint32 )sizeof (uint32 ) * comp_data -> func_count ;
872
882
873
- const bool need_precheck = obj_data -> comp_ctx -> enable_stack_bound_check
874
- || obj_data -> comp_ctx -> enable_stack_estimation ;
875
883
/* aot_func#xxx + aot_func_internal#xxx in XIP mode for xtensa */
876
- if (obj_data -> comp_ctx -> is_indirect_mode && need_precheck
877
- && !strncmp (obj_data -> comp_ctx -> target_arch , "xtensa" , 6 ))
884
+ if (need_call_wrapped_indirect (obj_data ))
878
885
size *= 2 ;
879
886
880
887
/* max_local_cell_nums */
@@ -2416,10 +2423,7 @@ aot_emit_init_data_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
2416
2423
return false;
2417
2424
2418
2425
offset = align_uint (offset , 4 );
2419
- const bool need_precheck = obj_data -> comp_ctx -> enable_stack_bound_check
2420
- || obj_data -> comp_ctx -> enable_stack_estimation ;
2421
- if (obj_data -> comp_ctx -> is_indirect_mode && need_precheck
2422
- && !strncmp (obj_data -> comp_ctx -> target_arch , "xtensa" , 6 ))
2426
+ if (need_call_wrapped_indirect (obj_data ))
2423
2427
EMIT_U32 (comp_data -> func_count * 2 );
2424
2428
else
2425
2429
EMIT_U32 (comp_data -> func_count );
@@ -2607,10 +2611,7 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
2607
2611
EMIT_U64 (func -> text_offset );
2608
2612
}
2609
2613
2610
- const bool need_precheck = obj_data -> comp_ctx -> enable_stack_bound_check
2611
- || obj_data -> comp_ctx -> enable_stack_estimation ;
2612
- if (obj_data -> comp_ctx -> is_indirect_mode && need_precheck
2613
- && !strncmp (obj_data -> comp_ctx -> target_arch , "xtensa" , 6 )) {
2614
+ if (need_call_wrapped_indirect (obj_data )) {
2614
2615
/*
2615
2616
* Explicitly emit aot_func_internal#xxx for Xtensa XIP, therefore,
2616
2617
* for aot_func#xxx, func_indexes ranged from 0 ~ func_count,
@@ -2628,8 +2629,7 @@ aot_emit_func_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
2628
2629
for (i = 0 ; i < comp_data -> func_count ; i ++ )
2629
2630
EMIT_U32 (funcs [i ]-> func_type_index );
2630
2631
2631
- if (obj_data -> comp_ctx -> is_indirect_mode && need_precheck
2632
- && !strncmp (obj_data -> comp_ctx -> target_arch , "xtensa" , 6 )) {
2632
+ if (need_call_wrapped_indirect (obj_data )) {
2633
2633
/* func_type_index for aot_func_internal#xxxx */
2634
2634
for (i = 0 ; i < comp_data -> func_count ; i ++ )
2635
2635
EMIT_U32 (funcs [i ]-> func_type_index );
0 commit comments