Compare commits

...

4 Commits

Author SHA1 Message Date
Lukas Döllerer
fbb5e21e98 Fix free(NULL) calls 2025-07-10 17:38:57 +02:00
Lukas Döllerer
f1dbe4a450 Remove branch hint flags since they are not required 2025-07-10 17:36:49 +02:00
Lukas Döllerer
8845a2cfaf Formatting 2025-07-10 17:34:53 +02:00
Lukas Döllerer
d13a52f04a Fixes from first review 2025-07-10 17:32:53 +02:00
16 changed files with 69 additions and 98 deletions

View File

@ -119,11 +119,6 @@ if (NOT DEFINED WAMR_BUILD_REF_TYPES)
set (WAMR_BUILD_REF_TYPES 1) set (WAMR_BUILD_REF_TYPES 1)
endif () endif ()
if (NOT DEFINED WAMR_BUILD_BRANCH_HINTS)
# Enable branch hints by default
set (WAMR_BUILD_BRANCH_HINTS 1)
endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

View File

@ -128,10 +128,6 @@ if GetDepend(['WAMR_BUILD_REF_TYPES']):
CPPDEFINES += ['WASM_ENABLE_REF_TYPES=1'] CPPDEFINES += ['WASM_ENABLE_REF_TYPES=1']
print('[WAMR] enable ref types') print('[WAMR] enable ref types')
if GetDepend(['WAMR_BUILD_BRANCH_HINTS']):
CPPDEFINES += ['WASM_ENABLE_BRANCH_HINTS=1']
print('[WAMR] enable branch hints')
CPPDEFINES += ['BH_MALLOC=wasm_runtime_malloc'] CPPDEFINES += ['BH_MALLOC=wasm_runtime_malloc']
CPPDEFINES += ['BH_FREE=wasm_runtime_free'] CPPDEFINES += ['BH_FREE=wasm_runtime_free']

View File

@ -215,10 +215,6 @@ if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
set (WAMR_BUILD_EXTENDED_CONST_EXPR 0) set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
endif () endif ()
if (NOT DEFINED WAMR_BUILD_BRANCH_HINTS)
set (WAMR_BUILD_BRANCH_HINTS 1)
endif ()
######################################## ########################################
# Compilation options to marco # Compilation options to marco
######################################## ########################################
@ -423,12 +419,6 @@ endif ()
if (WAMR_BUILD_REF_TYPES EQUAL 1) if (WAMR_BUILD_REF_TYPES EQUAL 1)
add_definitions (-DWASM_ENABLE_REF_TYPES=1) add_definitions (-DWASM_ENABLE_REF_TYPES=1)
endif () endif ()
if (WAMR_BUILD_BRANCH_HINTS EQUAL 1)
add_definitions (-DWASM_ENABLE_BRANCH_HINTS=1)
message (" branch hints enabled")
else ()
message (" branch hints disabled")
endif ()
if (WAMR_BUILD_GC EQUAL 1) if (WAMR_BUILD_GC EQUAL 1)
if (WAMR_TEST_GC EQUAL 1) if (WAMR_TEST_GC EQUAL 1)
message(" GC testing enabled") message(" GC testing enabled")
@ -718,7 +708,6 @@ message (
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n" " \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n" " \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n" " \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" \"Branch Hinting\" via WAMR_BUILD_BRANCH_HINTS: ${WAMR_BUILD_BRANCH_HINTS}\n"
" Unsupported (>= Phase4):\n" " Unsupported (>= Phase4):\n"
" \"Custom Annotation Syntax in the Text Format\"\n" " \"Custom Annotation Syntax in the Text Format\"\n"
" \"Exception handling\"\n" " \"Exception handling\"\n"

View File

@ -505,13 +505,6 @@ check_feature_flags(char *error_buf, uint32 error_buf_size,
} }
#endif #endif
#if WASM_ENABLE_BRANCH_HINTS == 0
if (feature_flags & WASM_ENABLE_BRANCH_HINTS) {
LOG_WARNING(
"branch hints not enabled, but wasm file contains branch hints");
}
#endif
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
if (feature_flags & WASM_FEATURE_GARBAGE_COLLECTION) { if (feature_flags & WASM_FEATURE_GARBAGE_COLLECTION) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,

View File

@ -35,7 +35,6 @@ extern "C" {
* and not at the beginning of each function call */ * and not at the beginning of each function call */
#define WASM_FEATURE_FRAME_PER_FUNCTION (1 << 12) #define WASM_FEATURE_FRAME_PER_FUNCTION (1 << 12)
#define WASM_FEATURE_FRAME_NO_FUNC_IDX (1 << 13) #define WASM_FEATURE_FRAME_NO_FUNC_IDX (1 << 13)
#define WASM_FEATURE_BRANCH_HINTS (1 << 14)
typedef enum AOTSectionType { typedef enum AOTSectionType {
AOT_SECTION_TYPE_TARGET_INFO = 0, AOT_SECTION_TYPE_TARGET_INFO = 0,
@ -58,7 +57,6 @@ typedef enum AOTCustomSectionType {
AOT_CUSTOM_SECTION_ACCESS_CONTROL = 2, AOT_CUSTOM_SECTION_ACCESS_CONTROL = 2,
AOT_CUSTOM_SECTION_NAME = 3, AOT_CUSTOM_SECTION_NAME = 3,
AOT_CUSTOM_SECTION_STRING_LITERAL = 4, AOT_CUSTOM_SECTION_STRING_LITERAL = 4,
AOT_CUSTOM_SECTION_CODE_METADATA = 5,
} AOTCustomSectionType; } AOTCustomSectionType;
typedef struct AOTObjectDataSection { typedef struct AOTObjectDataSection {

View File

@ -392,7 +392,6 @@ aot_create_funcs(const WASMModule *module, uint32 pointer_size)
memset(aot_func, 0, sizeof(AOTFunc)); memset(aot_func, 0, sizeof(AOTFunc));
func_type = aot_func->func_type = func->func_type; func_type = aot_func->func_type = func->func_type;
aot_func->func_index = i + module->import_function_count;
/* Resolve function type index */ /* Resolve function type index */
for (j = 0; j < module->type_count; j++) { for (j = 0; j < module->type_count; j++) {

View File

@ -207,7 +207,6 @@ typedef struct AOTImportFunc {
typedef struct AOTFunc { typedef struct AOTFunc {
AOTFuncType *func_type; AOTFuncType *func_type;
uint32 func_type_index; uint32 func_type_index;
uint32 func_index;
uint32 local_count; uint32 local_count;
uint8 *local_types_wp; uint8 *local_types_wp;
uint16 param_cell_num; uint16 param_cell_num;

View File

@ -1158,16 +1158,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
case WASM_OP_BR_IF: case WASM_OP_BR_IF:
{ {
// ip is advanced by one byte for the opcode if (!aot_compile_op_br_if(comp_ctx, func_ctx, &frame_ip))
#if WASM_ENABLE_BRANCH_HINTS != 0
uint32 instr_offset =
(frame_ip - 0x1) - (func_ctx->aot_func->code_body_begin);
#else
uint32 instr_offset = 0;
#endif
read_leb_uint32(frame_ip, frame_ip_end, br_depth);
if (!aot_compile_op_br_if(comp_ctx, func_ctx, br_depth,
&frame_ip, instr_offset))
return false; return false;
break; break;
} }

View File

@ -1905,7 +1905,7 @@ aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
{ {
WASMArrayType *array_type = NULL; WASMArrayType *array_type = NULL;
bh_assert(expr->u.array_new_default.type_index bh_assert(expr->u.unary.v.array_new_default.type_index
< module->type_count); < module->type_count);
array_type = array_type =
(WASMArrayType *) (WASMArrayType *)
@ -4501,9 +4501,6 @@ aot_obj_data_create(AOTCompContext *comp_ctx)
if (comp_ctx->enable_ref_types) { if (comp_ctx->enable_ref_types) {
obj_data->target_info.feature_flags |= WASM_FEATURE_REF_TYPES; obj_data->target_info.feature_flags |= WASM_FEATURE_REF_TYPES;
} }
if (comp_ctx->enable_branch_hints) {
obj_data->target_info.feature_flags |= WASM_FEATURE_BRANCH_HINTS;
}
if (comp_ctx->enable_gc) { if (comp_ctx->enable_gc) {
obj_data->target_info.feature_flags |= WASM_FEATURE_GARBAGE_COLLECTION; obj_data->target_info.feature_flags |= WASM_FEATURE_GARBAGE_COLLECTION;
} }

View File

@ -12,6 +12,7 @@
#endif #endif
#include "../aot/aot_runtime.h" #include "../aot/aot_runtime.h"
#include "../interpreter/wasm_loader.h" #include "../interpreter/wasm_loader.h"
#include "../common/wasm_loader_common.h"
#if WASM_ENABLE_DEBUG_AOT != 0 #if WASM_ENABLE_DEBUG_AOT != 0
#include "debug/dwarf_extractor.h" #include "debug/dwarf_extractor.h"
@ -87,14 +88,13 @@ format_block_name(char *name, uint32 name_size, uint32 block_index,
} \ } \
} while (0) } while (0)
#define BUILD_COND_BR_V(value_if, block_then, block_else, instr) \ #define BUILD_COND_BR_V(value_if, block_then, block_else, instr) \
do { \ do { \
if (instr = LLVMBuildCondBr(comp_ctx->builder, value_if, block_then, \ if (!(instr = LLVMBuildCondBr(comp_ctx->builder, value_if, block_then, \
block_else), \ block_else))) { \
!instr) { \ aot_set_last_error("llvm build cond br failed."); \
aot_set_last_error("llvm build cond br failed."); \ goto fail; \
goto fail; \ } \
} \
} while (0) } while (0)
#define SET_BUILDER_POS(llvm_block) \ #define SET_BUILDER_POS(llvm_block) \
@ -267,34 +267,30 @@ restore_frame_sp_for_op_end(AOTBlock *block, AOTCompFrame *aot_frame)
#if WASM_ENABLE_BRANCH_HINTS != 0 #if WASM_ENABLE_BRANCH_HINTS != 0
static void static void
aot_emit_branch_hint(LLVMContextRef ctxt, AOTFuncContext *func_ctx, aot_emit_branch_hint(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 offset, LLVMValueRef br_if_instr) uint32 offset, LLVMValueRef br_if_instr)
{ {
struct WASMCompilationHintBranchHint *hint = struct WASMCompilationHint *hint = func_ctx->function_hints;
(struct WASMCompilationHintBranchHint *)func_ctx->function_hints;
while (hint != NULL) { while (hint != NULL) {
if (hint->type == WASM_COMPILATION_BRANCH_HINT if (hint->type == WASM_COMPILATION_BRANCH_HINT
&& hint->offset == offset) { && ((struct WASMCompilationHintBranchHint *)hint)->offset
== offset) {
break; break;
} }
hint = hint->next; hint = hint->next;
} }
if (hint != NULL) { if (hint != NULL) {
LLVMMetadataRef header = LLVMMDStringInContext2(
ctxt, "branch_weights", 14 /* strlen("branch_hint") */);
// same weight llvm MDBuilder::createLikelyBranchWeights assigns // same weight llvm MDBuilder::createLikelyBranchWeights assigns
const uint32_t likely_weight = (1U << 20) - 1; const uint32_t likely_weight = (1U << 20) - 1;
const uint32_t unlikely_weight = 1; const uint32_t unlikely_weight = 1;
LLVMMetadataRef true_w = LLVMValueAsMetadata(LLVMConstInt( aot_set_cond_br_weights(
LLVMInt32TypeInContext(ctxt), comp_ctx, br_if_instr,
hint->is_likely ? likely_weight : unlikely_weight, false)); ((struct WASMCompilationHintBranchHint *)hint)->is_likely
LLVMMetadataRef false_w = LLVMValueAsMetadata(LLVMConstInt( ? likely_weight
LLVMInt32TypeInContext(ctxt), : unlikely_weight,
hint->is_likely ? unlikely_weight : likely_weight, false)); ((struct WASMCompilationHintBranchHint *)hint)->is_likely
LLVMMetadataRef mds[] = { header, true_w, false_w }; ? unlikely_weight
LLVMMetadataRef md = LLVMMDNodeInContext2(ctxt, mds, 3); : likely_weight);
LLVMValueRef md_val = LLVMMetadataAsValue(ctxt, md);
LLVMSetMetadata(br_if_instr, LLVMGetMDKindID("prof", 4), md_val);
} }
} }
#endif #endif
@ -723,8 +719,7 @@ aot_compile_op_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
block->llvm_else_block, br_if_val); block->llvm_else_block, br_if_val);
const uint32 off = const uint32 off =
*p_frame_ip - func_ctx->aot_func->code_body_begin; *p_frame_ip - func_ctx->aot_func->code_body_begin;
aot_emit_branch_hint(comp_ctx->context, func_ctx, off, aot_emit_branch_hint(comp_ctx, func_ctx, off, br_if_val);
br_if_val);
#else #else
BUILD_COND_BR(value, block->llvm_entry_block, BUILD_COND_BR(value, block->llvm_entry_block,
block->llvm_else_block); block->llvm_else_block);
@ -738,8 +733,7 @@ aot_compile_op_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
block->llvm_end_block, br_if_val); block->llvm_end_block, br_if_val);
const uint32 off = const uint32 off =
*p_frame_ip - func_ctx->aot_func->code_body_begin; *p_frame_ip - func_ctx->aot_func->code_body_begin;
aot_emit_branch_hint(comp_ctx->context, func_ctx, off, aot_emit_branch_hint(comp_ctx, func_ctx, off, br_if_val);
br_if_val);
#else #else
BUILD_COND_BR(value, block->llvm_entry_block, BUILD_COND_BR(value, block->llvm_entry_block,
block->llvm_end_block); block->llvm_end_block);
@ -1090,8 +1084,7 @@ fail:
static bool static bool
aot_compile_conditional_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_compile_conditional_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 br_depth, LLVMValueRef value_cmp, LLVMValueRef value_cmp, uint8 **p_frame_ip)
uint8 **p_frame_ip, uint32 off)
{ {
AOTBlock *block_dst; AOTBlock *block_dst;
LLVMValueRef value, *values = NULL; LLVMValueRef value, *values = NULL;
@ -1100,6 +1093,17 @@ aot_compile_conditional_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 i, param_index, result_index; uint32 i, param_index, result_index;
uint64 size; uint64 size;
// ip is advanced by one byte for the opcode
#if WASM_ENABLE_BRANCH_HINTS != 0
uint32 instr_offset =
(*p_frame_ip - 0x1) - (func_ctx->aot_func->code_body_begin);
#else
uint32 instr_offset = 0;
#endif
uint64 br_depth;
if (!read_leb(p_frame_ip, *p_frame_ip + 5, 32, false, &br_depth, NULL, 0))
return false;
if (!(block_dst = get_target_block(func_ctx, br_depth))) { if (!(block_dst = get_target_block(func_ctx, br_depth))) {
return false; return false;
} }
@ -1176,7 +1180,7 @@ aot_compile_conditional_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef br_if_val = NULL; LLVMValueRef br_if_val = NULL;
BUILD_COND_BR_V(value_cmp, block_dst->llvm_entry_block, BUILD_COND_BR_V(value_cmp, block_dst->llvm_entry_block,
llvm_else_block, br_if_val); llvm_else_block, br_if_val);
aot_emit_branch_hint(comp_ctx->context, func_ctx, off, br_if_val); aot_emit_branch_hint(comp_ctx, func_ctx, instr_offset, br_if_val);
#else #else
BUILD_COND_BR(value_cmp, block_dst->llvm_entry_block, BUILD_COND_BR(value_cmp, block_dst->llvm_entry_block,
llvm_else_block); llvm_else_block);
@ -1227,7 +1231,7 @@ aot_compile_conditional_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef br_if_val = NULL; LLVMValueRef br_if_val = NULL;
BUILD_COND_BR_V(value_cmp, block_dst->llvm_end_block, BUILD_COND_BR_V(value_cmp, block_dst->llvm_end_block,
llvm_else_block, br_if_val); llvm_else_block, br_if_val);
aot_emit_branch_hint(comp_ctx->context, func_ctx, off, br_if_val); aot_emit_branch_hint(comp_ctx, func_ctx, instr_offset, br_if_val);
#else #else
BUILD_COND_BR(value_cmp, block_dst->llvm_end_block, BUILD_COND_BR(value_cmp, block_dst->llvm_end_block,
llvm_else_block); llvm_else_block);
@ -1255,14 +1259,14 @@ fail:
bool bool
aot_compile_op_br_if(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_compile_op_br_if(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 br_depth, uint8 **p_frame_ip, uint32 off) uint8 **p_frame_ip)
{ {
LLVMValueRef value_cmp; LLVMValueRef value_cmp;
POP_COND(value_cmp); POP_COND(value_cmp);
return aot_compile_conditional_br(comp_ctx, func_ctx, br_depth, value_cmp, return aot_compile_conditional_br(comp_ctx, func_ctx, value_cmp,
p_frame_ip, off); p_frame_ip);
fail: fail:
return false; return false;
} }

View File

@ -32,7 +32,7 @@ aot_compile_op_br(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
bool bool
aot_compile_op_br_if(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_compile_op_br_if(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 br_depth, uint8 **p_frame_ip, uint32 offset); uint8 **p_frame_ip);
bool bool
aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,

View File

@ -2740,9 +2740,6 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (option->enable_ref_types) if (option->enable_ref_types)
comp_ctx->enable_ref_types = true; comp_ctx->enable_ref_types = true;
if (option->enable_branch_hints)
comp_ctx->enable_branch_hints = true;
comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type; comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type;
comp_ctx->call_stack_features = option->call_stack_features; comp_ctx->call_stack_features = option->call_stack_features;

View File

@ -452,9 +452,6 @@ typedef struct AOTCompContext {
/* Reference Types */ /* Reference Types */
bool enable_ref_types; bool enable_ref_types;
/* Branch Hinting */
bool enable_branch_hints;
/* Disable LLVM built-in intrinsics */ /* Disable LLVM built-in intrinsics */
bool disable_llvm_intrinsics; bool disable_llvm_intrinsics;

View File

@ -66,7 +66,6 @@ typedef struct AOTCompOption {
bool enable_tail_call; bool enable_tail_call;
bool enable_simd; bool enable_simd;
bool enable_ref_types; bool enable_ref_types;
bool enable_branch_hints;
bool enable_gc; bool enable_gc;
bool enable_aux_stack_check; bool enable_aux_stack_check;
bool enable_extended_const; bool enable_extended_const;

View File

@ -775,7 +775,7 @@ struct WASMCompilationHint {
enum WASMCompilationHintType type; enum WASMCompilationHintType type;
}; };
struct WASMCompilationHintBranchHint { struct WASMCompilationHintBranchHint {
void *next; struct WASMCompilationHint *next;
enum WASMCompilationHintType type; enum WASMCompilationHintType type;
uint32 offset; uint32 offset;
bool is_likely; bool is_likely;

View File

@ -5544,8 +5544,8 @@ handle_branch_hint_section(const uint8 *buf, const uint8 *buf_end,
goto fail; goto fail;
} }
struct WASMCompilationHintBranchHint *current_hint = struct WASMCompilationHint *current_hint =
(struct WASMCompilationHintBranchHint *)&module (struct WASMCompilationHint *)&module
->function_hints[func_idx - module->import_function_count]; ->function_hints[func_idx - module->import_function_count];
while (current_hint->next != NULL) { while (current_hint->next != NULL) {
current_hint = current_hint->next; current_hint = current_hint->next;
@ -5553,10 +5553,11 @@ handle_branch_hint_section(const uint8 *buf, const uint8 *buf_end,
uint32 num_hints; uint32 num_hints;
read_leb_uint32(buf, buf_end, num_hints); read_leb_uint32(buf, buf_end, num_hints);
struct WASMCompilationHintBranchHint *new_hints = loader_malloc(
sizeof(struct WASMCompilationHintBranchHint) * num_hints, error_buf,
error_buf_size);
for (uint32 j = 0; j < num_hints; ++j) { for (uint32 j = 0; j < num_hints; ++j) {
struct WASMCompilationHintBranchHint *new_hint = struct WASMCompilationHintBranchHint *new_hint = &new_hints[j];
loader_malloc(sizeof(struct WASMCompilationHintBranchHint),
error_buf, error_buf_size);
new_hint->next = NULL; new_hint->next = NULL;
new_hint->type = WASM_COMPILATION_BRANCH_HINT; new_hint->type = WASM_COMPILATION_BRANCH_HINT;
read_leb_uint32(buf, buf_end, new_hint->offset); read_leb_uint32(buf, buf_end, new_hint->offset);
@ -5584,8 +5585,8 @@ handle_branch_hint_section(const uint8 *buf, const uint8 *buf_end,
goto fail; goto fail;
} }
current_hint->next = new_hint; current_hint->next = (struct WASMCompilationHint *)new_hint;
current_hint = new_hint; current_hint = (struct WASMCompilationHint *)new_hint;
} }
} }
if (buf != buf_end) { if (buf != buf_end) {
@ -5649,7 +5650,8 @@ load_user_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
#endif #endif
#if WASM_ENABLE_BRANCH_HINTS != 0 #if WASM_ENABLE_BRANCH_HINTS != 0
if (name_len == 25 && memcmp(p, "metadata.code.branch_hint", 25) == 0) { if (name_len == 25
&& strncmp((const char *)p, "metadata.code.branch_hint", 25) == 0) {
p += name_len; p += name_len;
if (!handle_branch_hint_section(p, p_end, module, error_buf, if (!handle_branch_hint_section(p, p_end, module, error_buf,
error_buf_size)) { error_buf_size)) {
@ -5657,6 +5659,12 @@ load_user_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
} }
LOG_VERBOSE("Load branch hint section success."); LOG_VERBOSE("Load branch hint section success.");
} }
#else
if (name_len == 25
&& strncmp((const char *)p, "metadata.code.branch_hint", 25) == 0) {
LOG_VERBOSE("Found branch hint section, but branch hints are disabled "
"in this build, skipping.");
}
#endif #endif
#if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 #if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0
@ -7446,7 +7454,16 @@ wasm_loader_unload(WASMModule *module)
} }
#endif #endif
#endif #endif
#if WASM_ENABLE_BRANCH_HINTS != 0
for (size_t i = 0; i < module->function_count; i++) {
// be carefull when adding more hints. This only works as long as
// the hint structs have been allocated all at once as an array.
// With only branch-hints at the moment, this is the case.
if (module->function_hints[i] != NULL)
wasm_runtime_free(module->function_hints[i]);
}
wasm_runtime_free(module->function_hints);
#endif
wasm_runtime_free(module); wasm_runtime_free(module);
} }