@@ -1527,60 +1527,87 @@ create_memory_info(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
15271527 func_ctx->aot_inst, &offset, 1, \
15281528 #field "_p"))) { \
15291529 aot_set_last_error("llvm build inbounds gep failed"); \
1530- return false; \
1530+ goto fail; \
15311531 } \
15321532 if (!(load_val = \
15331533 LLVMBuildLoad2(comp_ctx->builder, type, field_p, #field))) { \
15341534 aot_set_last_error("llvm build load failed"); \
1535- return false; \
1535+ goto fail; \
15361536 } \
15371537 if (!(func_ctx->field = \
15381538 LLVMBuildAlloca(comp_ctx->builder, type, #field))) { \
15391539 aot_set_last_error("llvm build alloca failed"); \
1540- return false; \
1540+ goto fail; \
15411541 } \
15421542 if (!LLVMBuildStore(comp_ctx->builder, load_val, func_ctx->field)) { \
15431543 aot_set_last_error("llvm build store failed"); \
1544- return false; \
1545- } \
1546- } while (0)
1547-
1548- #define LOAD_MODULE_EXTRA_FIELD (field , type ) \
1549- do { \
1550- get_module_extra_field_offset(field); \
1551- offset = I32_CONST(offset_u32); \
1552- CHECK_LLVM_CONST(offset); \
1553- if (!(field_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, \
1554- func_ctx->aot_inst, &offset, 1, \
1555- #field "_p"))) { \
1556- aot_set_last_error("llvm build inbounds gep failed"); \
1557- return false; \
1558- } \
1559- if (!(func_ctx->field = \
1560- LLVMBuildLoad2(comp_ctx->builder, type, field_p, #field))) { \
1561- aot_set_last_error("llvm build load failed"); \
1562- return false; \
1544+ goto fail; \
15631545 } \
15641546 } while (0)
15651547
15661548static bool
15671549create_shared_heap_info (AOTCompContext * comp_ctx , AOTFuncContext * func_ctx )
15681550{
1569- LLVMValueRef offset , field_p , load_val ;
1551+ LLVMValueRef offset , field_p , load_val , shared_heap_head_p ,
1552+ shared_heap_head ;
1553+ LLVMTypeRef shared_heap_offset_type ;
15701554 uint32 offset_u32 ;
1555+ #if WASM_ENABLE_MEMORY64 == 0
1556+ bool is_memory64 = false;
1557+ #else
1558+ bool is_memory64 = IS_MEMORY64 ;
1559+ #endif
15711560
1572- /* shared_heap_base_addr_adj, shared_heap_start_off, and shared_heap_end_off
1573- * can be updated later, use local variable to represent them */
1561+ shared_heap_offset_type =
1562+ comp_ctx -> pointer_size == sizeof (uint64 ) ? I64_TYPE : I32_TYPE ;
1563+
1564+ /* shared_heap_base_addr_adj, shared_heap_start_off, and
1565+ * shared_heap_end_off can be updated later, use local variable to
1566+ * represent them */
15741567 LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA (shared_heap_base_addr_adj ,
15751568 INT8_PTR_TYPE );
1576- LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA (
1577- shared_heap_start_off ,
1578- comp_ctx -> pointer_size == sizeof (uint64 ) ? I64_TYPE : I32_TYPE );
1579- LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA (
1580- shared_heap_end_off ,
1581- comp_ctx -> pointer_size == sizeof (uint64 ) ? I64_TYPE : I32_TYPE );
1582- /* Shared Heap won't be updated, no need to alloca */
1583- LOAD_MODULE_EXTRA_FIELD (shared_heap , INT8_PTR_TYPE );
1569+ LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA (shared_heap_start_off ,
1570+ shared_heap_offset_type );
1571+ LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA (shared_heap_end_off ,
1572+ shared_heap_offset_type );
1573+
1574+ /* Shared Heap head start off won't be updated, no need to alloca */
1575+ get_module_extra_field_offset (shared_heap );
1576+ offset = I32_CONST (offset_u32 );
1577+ CHECK_LLVM_CONST (offset );
1578+ if (!(shared_heap_head_p = LLVMBuildInBoundsGEP2 (
1579+ comp_ctx -> builder , INT8_TYPE , func_ctx -> aot_inst , & offset , 1 ,
1580+ "shared_heap_head_p" ))) {
1581+ aot_set_last_error ("llvm build inbounds gep failed" );
1582+ goto fail ;
1583+ }
1584+ if (!(shared_heap_head =
1585+ LLVMBuildLoad2 (comp_ctx -> builder , INT8_PTR_TYPE ,
1586+ shared_heap_head_p , "shared_heap_head" ))) {
1587+ aot_set_last_error ("llvm build load failed" );
1588+ goto fail ;
1589+ }
1590+
1591+ if (is_memory64 ) {
1592+ offset_u32 = offsetof(WASMSharedHeap , start_off_mem64 );
1593+ }
1594+ else {
1595+ offset_u32 = offsetof(WASMSharedHeap , start_off_mem32 );
1596+ }
1597+ offset = I32_CONST (offset_u32 );
1598+ CHECK_LLVM_CONST (offset );
1599+ if (!(field_p = LLVMBuildInBoundsGEP2 (comp_ctx -> builder , INT8_TYPE ,
1600+ shared_heap_head , & offset , 1 ,
1601+ "head_start_off_p" ))) {
1602+ aot_set_last_error ("llvm build inbounds gep failed" );
1603+ goto fail ;
1604+ }
1605+ if (!(func_ctx -> shared_heap_head_start_off =
1606+ LLVMBuildLoad2 (comp_ctx -> builder , shared_heap_offset_type ,
1607+ field_p , "shared_heap_head_start_off" ))) {
1608+ aot_set_last_error ("llvm build load failed" );
1609+ goto fail ;
1610+ }
15841611
15851612 return true;
15861613fail :
@@ -2439,7 +2466,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen,
24392466 stack_consumption_to_call_wrapped_func =
24402467 musttail ? 0
24412468 : aot_estimate_stack_usage_for_function_call (
2442- comp_ctx , func_ctx -> aot_func -> func_type );
2469+ comp_ctx , func_ctx -> aot_func -> func_type );
24432470 LOG_VERBOSE ("func %.*s stack %u + %zu + %u" , (int )namelen , name ,
24442471 stack_consumption_to_call_wrapped_func , stack_size , call_size );
24452472
0 commit comments