Re-org memory allocation interfaces, add --stack-size and --heap-size option (#193)

This commit is contained in:
wenyongh
2020-03-10 19:54:44 +08:00
committed by GitHub
parent 381859d530
commit 0fdd49ea31
110 changed files with 1264 additions and 2125 deletions

View File

@ -4,7 +4,6 @@
*/
#include "aot.h"
#include "bh_memory.h"
static char aot_error[128];
@ -30,8 +29,8 @@ aot_destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count)
uint32 i;
for (i = 0; i < count; i++)
if (data_list[i])
wasm_free(data_list[i]);
wasm_free(data_list);
wasm_runtime_free(data_list[i]);
wasm_runtime_free(data_list);
}
static AOTMemInitData **
@ -44,7 +43,7 @@ aot_create_mem_init_data_list(const WASMModule *module)
/* Allocate memory */
size = sizeof(AOTMemInitData *) * (uint64)module->data_seg_count;
if (size >= UINT32_MAX
|| !(data_list = wasm_malloc((uint32)size))) {
|| !(data_list = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -56,7 +55,7 @@ aot_create_mem_init_data_list(const WASMModule *module)
size = offsetof(AOTMemInitData, bytes) +
(uint64)module->data_segments[i]->data_length;
if (size >= UINT32_MAX
|| !(data_list[i] = wasm_malloc((uint32)size))) {
|| !(data_list[i] = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
@ -80,8 +79,8 @@ aot_destroy_table_init_data_list(AOTTableInitData **data_list, uint32 count)
uint32 i;
for (i = 0; i < count; i++)
if (data_list[i])
wasm_free(data_list[i]);
wasm_free(data_list);
wasm_runtime_free(data_list[i]);
wasm_runtime_free(data_list);
}
static AOTTableInitData **
@ -94,7 +93,7 @@ aot_create_table_init_data_list(const WASMModule *module)
/* Allocate memory */
size = sizeof(AOTTableInitData *) * (uint64)module->table_seg_count;
if (size >= UINT32_MAX
|| !(data_list = wasm_malloc((uint32)size))) {
|| !(data_list = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -106,7 +105,7 @@ aot_create_table_init_data_list(const WASMModule *module)
size = offsetof(AOTTableInitData, func_indexes) +
sizeof(uint32) * (uint64)module->table_segments[i].function_count;
if (size >= UINT32_MAX
|| !(data_list[i] = wasm_malloc((uint32)size))) {
|| !(data_list[i] = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
@ -135,7 +134,7 @@ aot_create_import_globals(const WASMModule *module,
/* Allocate memory */
size = sizeof(AOTImportGlobal) * (uint64)module->import_global_count;
if (size >= UINT32_MAX
|| !(import_globals = wasm_malloc((uint32)size))) {
|| !(import_globals = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -172,7 +171,7 @@ aot_create_globals(const WASMModule *module,
/* Allocate memory */
size = sizeof(AOTGlobal) * (uint64)module->global_count;
if (size >= UINT32_MAX
|| !(globals = wasm_malloc((uint32)size))) {
|| !(globals = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -202,8 +201,8 @@ aot_destroy_func_types(AOTFuncType **func_types, uint32 count)
uint32 i;
for (i = 0; i < count; i++)
if (func_types[i])
wasm_free(func_types[i]);
wasm_free(func_types);
wasm_runtime_free(func_types[i]);
wasm_runtime_free(func_types);
}
static AOTFuncType **
@ -216,7 +215,7 @@ aot_create_func_types(const WASMModule *module)
/* Allocate memory */
size = sizeof(AOTFuncType*) * (uint64)module->type_count;
if (size >= UINT32_MAX
|| !(func_types = wasm_malloc((uint32)size))) {
|| !(func_types = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -229,7 +228,7 @@ aot_create_func_types(const WASMModule *module)
(uint64)module->types[i]->param_count +
(uint64)module->types[i]->result_count;
if (size >= UINT32_MAX
|| !(func_types[i] = wasm_malloc((uint32)size))) {
|| !(func_types[i] = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
@ -253,7 +252,7 @@ aot_create_import_funcs(const WASMModule *module)
/* Allocate memory */
size = sizeof(AOTImportFunc) * (uint64)module->import_function_count;
if (size >= UINT32_MAX
|| !(import_funcs = wasm_malloc((uint32)size))) {
|| !(import_funcs = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -284,8 +283,8 @@ aot_destroy_funcs(AOTFunc **funcs, uint32 count)
for (i = 0; i < count; i++)
if (funcs[i])
wasm_free(funcs[i]);
wasm_free(funcs);
wasm_runtime_free(funcs[i]);
wasm_runtime_free(funcs);
}
static AOTFunc **
@ -298,7 +297,7 @@ aot_create_funcs(const WASMModule *module)
/* Allocate memory */
size = sizeof(AOTFunc*) * (uint64)module->function_count;
if (size >= UINT32_MAX
|| !(funcs = wasm_malloc((uint32)size))) {
|| !(funcs = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -309,7 +308,7 @@ aot_create_funcs(const WASMModule *module)
for (i = 0; i < module->function_count; i++) {
WASMFunction *func = module->functions[i];
size = sizeof (AOTFunc);
if (!(funcs[i] = wasm_malloc((uint32)size))) {
if (!(funcs[i] = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
@ -348,7 +347,7 @@ aot_create_export_funcs(const WASMModule *module,
/* Allocate memory */
size = sizeof(AOTExportFunc) * (uint64)export_func_count;
if (size >= UINT32_MAX
|| !(export_funcs = wasm_malloc((uint32)size))) {
|| !(export_funcs = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -376,7 +375,7 @@ aot_create_comp_data(WASMModule *module)
uint32 import_global_data_size = 0, global_data_size = 0, i;
/* Allocate memory */
if (!(comp_data = wasm_malloc(sizeof(AOTCompData)))) {
if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) {
aot_set_last_error("create compile data failed.\n");
return NULL;
}
@ -492,24 +491,24 @@ aot_destroy_comp_data(AOTCompData *comp_data)
comp_data->table_init_data_count);
if (comp_data->import_globals)
wasm_free(comp_data->import_globals);
wasm_runtime_free(comp_data->import_globals);
if (comp_data->globals)
wasm_free(comp_data->globals);
wasm_runtime_free(comp_data->globals);
if (comp_data->func_types)
aot_destroy_func_types(comp_data->func_types,
comp_data->func_type_count);
if (comp_data->import_funcs)
wasm_free(comp_data->import_funcs);
wasm_runtime_free(comp_data->import_funcs);
if (comp_data->funcs)
aot_destroy_funcs(comp_data->funcs, comp_data->func_count);
if (comp_data->export_funcs)
wasm_free(comp_data->export_funcs);
wasm_runtime_free(comp_data->export_funcs);
wasm_free(comp_data);
wasm_runtime_free(comp_data);
}

View File

@ -14,7 +14,6 @@
#include "aot_emit_control.h"
#include "aot_emit_function.h"
#include "aot_emit_parametric.h"
#include "bh_memory.h"
#include "../aot/aot_runtime.h"
#include "../interpreter/wasm_opcode.h"
#include <errno.h>
@ -152,7 +151,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
case WASM_OP_BR_TABLE:
read_leb_uint32(frame_ip, frame_ip_end, br_count);
if (!(br_depths = wasm_malloc((uint32)sizeof(uint32) * (br_count + 1)))) {
if (!(br_depths =
wasm_runtime_malloc((uint32)sizeof(uint32) * (br_count + 1)))) {
aot_set_last_error("allocate memory failed.");
goto fail;
}
@ -161,11 +161,11 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
if (!aot_compile_op_br_table(comp_ctx, func_ctx,
br_depths, br_count, &frame_ip)) {
wasm_free(br_depths);
wasm_runtime_free(br_depths);
return false;
}
wasm_free(br_depths);
wasm_runtime_free(br_depths);
break;
case WASM_OP_RETURN:

View File

@ -8,7 +8,6 @@
#include "aot.h"
#include "aot_llvm.h"
#include "bh_memory.h"
#ifdef __cplusplus
extern "C" {
@ -103,7 +102,7 @@ typedef enum FloatArithmetic {
&& (aot_value->type != VALUE_TYPE_I32 \
&& aot_value->type != VALUE_TYPE_I1))) { \
aot_set_last_error("invalid WASM stack data type."); \
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
goto fail; \
} \
if (aot_value->type == value_type) \
@ -113,11 +112,11 @@ typedef enum FloatArithmetic {
if (!(llvm_value = LLVMBuildZExt(comp_ctx->builder, \
aot_value->value, I32_TYPE, "i1toi32"))) { \
aot_set_last_error("invalid WASM stack data type.");\
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
goto fail; \
} \
} \
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
} while (0)
#define POP_I32(v) POP(v, VALUE_TYPE_I32)
@ -133,7 +132,7 @@ typedef enum FloatArithmetic {
if (aot_value->type != VALUE_TYPE_I1 \
&& aot_value->type != VALUE_TYPE_I32) { \
aot_set_last_error("invalid WASM stack data type."); \
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
goto fail; \
} \
if (aot_value->type == VALUE_TYPE_I1) \
@ -143,11 +142,11 @@ typedef enum FloatArithmetic {
LLVMIntNE, aot_value->value, I32_ZERO, \
"i1_cond"))){ \
aot_set_last_error("llvm build trunc failed."); \
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
goto fail; \
} \
} \
wasm_free(aot_value); \
wasm_runtime_free(aot_value); \
} while (0)
#define PUSH(llvm_value, value_type) do { \
@ -156,7 +155,7 @@ typedef enum FloatArithmetic {
aot_set_last_error("WASM block stack underflow."); \
goto fail; \
} \
aot_value = wasm_malloc(sizeof(AOTValue)); \
aot_value = wasm_runtime_malloc(sizeof(AOTValue)); \
memset(aot_value, 0, sizeof(AOTValue)); \
if (!aot_value) { \
aot_set_last_error("allocate memory failed."); \

View File

@ -509,7 +509,7 @@ get_relocation_symbol_index(const char *symbol_name,
}
/* Not found in symbol_list, add it */
sym = bh_malloc(sizeof(AOTSymbolNode));
sym = wasm_runtime_malloc(sizeof(AOTSymbolNode));
if (!sym) {
return (uint32)-1;
}
@ -1492,7 +1492,7 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data)
if (sections_count > 0) {
size = (uint32)sizeof(AOTObjectDataSection) * sections_count;
if (!(data_section = obj_data->data_sections = bh_malloc(size))) {
if (!(data_section = obj_data->data_sections = wasm_runtime_malloc(size))) {
aot_set_last_error("allocate memory for data sections failed.");
return false;
}
@ -1531,7 +1531,7 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
/* allocate memory for aot function */
obj_data->func_count = comp_ctx->comp_data->func_count;
if (!(obj_data->funcs
= bh_malloc((uint32)sizeof(AOTObjectFunc) * obj_data->func_count))) {
= wasm_runtime_malloc((uint32)sizeof(AOTObjectFunc) * obj_data->func_count))) {
aot_set_last_error("allocate memory for functions failed.");
return false;
}
@ -1602,7 +1602,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
return false;
}
size = (uint32)sizeof(AOTRelocation) * group->relocation_count;
if (!(relocation = group->relocations = bh_malloc(size))) {
if (!(relocation = group->relocations = wasm_runtime_malloc(size))) {
aot_set_last_error("allocate memory for relocations failed.");
return false;
}
@ -1754,7 +1754,7 @@ aot_resolve_object_relocation_groups(AOTObjectData *obj_data)
return true;
size = (uint32)sizeof(AOTRelocationGroup) * group_count;
if (!(relocation_group = obj_data->relocation_groups = bh_malloc(size))) {
if (!(relocation_group = obj_data->relocation_groups = wasm_runtime_malloc(size))) {
aot_set_last_error("allocate memory for relocation groups failed.");
return false;
}
@ -1795,8 +1795,8 @@ destroy_relocation_groups(AOTRelocationGroup *relocation_groups,
for (i = 0; i < relocation_group_count; i++, relocation_group++)
if (relocation_group->relocations)
bh_free(relocation_group->relocations);
bh_free(relocation_groups);
wasm_runtime_free(relocation_group->relocations);
wasm_runtime_free(relocation_groups);
}
static void
@ -1807,7 +1807,7 @@ destroy_relocation_symbol_list(AOTSymbolList *symbol_list)
elem = symbol_list->head;
while (elem) {
AOTSymbolNode *next = elem->next;
bh_free(elem);
wasm_runtime_free(elem);
elem = next;
}
}
@ -1820,15 +1820,15 @@ aot_obj_data_destroy(AOTObjectData *obj_data)
if (obj_data->mem_buf)
LLVMDisposeMemoryBuffer(obj_data->mem_buf);
if (obj_data->funcs)
bh_free(obj_data->funcs);
wasm_runtime_free(obj_data->funcs);
if (obj_data->data_sections)
bh_free(obj_data->data_sections);
wasm_runtime_free(obj_data->data_sections);
if (obj_data->relocation_groups)
destroy_relocation_groups(obj_data->relocation_groups,
obj_data->relocation_group_count);
if (obj_data->symbol_list.len)
destroy_relocation_symbol_list(&obj_data->symbol_list);
bh_free(obj_data);
wasm_runtime_free(obj_data);
}
static AOTObjectData *
@ -1837,7 +1837,7 @@ aot_obj_data_create(AOTCompContext *comp_ctx)
char *err = NULL;
AOTObjectData *obj_data;
if (!(obj_data = bh_malloc(sizeof(AOTObjectData)))) {
if (!(obj_data = wasm_runtime_malloc(sizeof(AOTObjectData)))) {
aot_set_last_error("allocate memory failed.");
return false;
}
@ -1896,7 +1896,7 @@ aot_emit_aot_file(AOTCompContext *comp_ctx, AOTCompData *comp_data,
aot_file_size = get_aot_file_size(comp_data, obj_data);
if (!(buf = aot_file_buf = bh_malloc(aot_file_size))) {
if (!(buf = aot_file_buf = wasm_runtime_malloc(aot_file_size))) {
aot_set_last_error("allocate memory failed.");
goto fail1;
}
@ -1938,7 +1938,7 @@ fail3:
fclose(file);
fail2:
bh_free(aot_file_buf);
wasm_runtime_free(aot_file_buf);
fail1:
aot_obj_data_destroy(obj_data);

View File

@ -7,7 +7,6 @@
#include "aot_emit_exception.h"
#include "../aot/aot_runtime.h"
#include "../interpreter/wasm_loader.h"
#include "bh_memory.h"
static char *block_name_prefix[] = { "block", "loop", "if" };
static char *block_name_suffix[] = { "begin", "else", "end" };
@ -208,7 +207,7 @@ aot_compile_op_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
}
/* Allocate memory */
if (!(block = wasm_malloc(sizeof(AOTBlock)))) {
if (!(block = wasm_runtime_malloc(sizeof(AOTBlock)))) {
aot_set_last_error("allocate memory failed.");
return false;
}
@ -309,7 +308,7 @@ aot_compile_op_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
goto fail;
}
/* skip the block */
wasm_free(block);
wasm_runtime_free(block);
*p_frame_ip = end_addr + 1;
}
}
@ -322,7 +321,7 @@ aot_compile_op_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return true;
fail:
wasm_free(block);
wasm_runtime_free(block);
return false;
}

View File

@ -247,7 +247,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
param_count = (int32)func_type->param_count;
total_size = sizeof(LLVMValueRef) * (uint64)(param_count + 1);
if (total_size >= UINT32_MAX
|| !(param_values = wasm_malloc((uint32)total_size))) {
|| !(param_values = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("Allocate memory failed.");
return false;
}
@ -268,7 +268,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
/* Initialize parameter types of the LLVM function */
total_size = sizeof(LLVMTypeRef) * (uint64)(param_count + 1);
if (total_size >= UINT32_MAX
|| !(param_types = wasm_malloc((uint32)total_size))) {
|| !(param_types = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("Allocate memory failed.");
goto fail;
}
@ -321,9 +321,9 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
ret = true;
fail:
if (param_types)
wasm_free(param_types);
wasm_runtime_free(param_types);
if (param_values)
wasm_free(param_values);
wasm_runtime_free(param_values);
return ret;
}
@ -548,7 +548,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
param_count = (int32)func_type->param_count;
total_size = sizeof(LLVMTypeRef) * (uint64)(param_count + 1);
if (total_size >= UINT32_MAX
|| !(param_types = wasm_malloc((uint32)total_size))) {
|| !(param_types = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("Allocate memory failed.");
goto fail;
}
@ -571,7 +571,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
/* Allocate memory for parameters */
total_size = sizeof(LLVMValueRef) * (uint64)(param_count + 1);
if (total_size >= UINT32_MAX
|| !(param_values = wasm_malloc((uint32)total_size))) {
|| !(param_values = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("Allocate memory failed.");
goto fail;
}
@ -601,9 +601,9 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
fail:
if (param_values)
wasm_free(param_values);
wasm_runtime_free(param_values);
if (param_types)
wasm_free(param_types);
wasm_runtime_free(param_types);
return ret;
}

View File

@ -186,7 +186,7 @@ call_llvm_intrinsic(AOTCompContext *comp_ctx,
/* Create param values */
total_size = sizeof(LLVMValueRef) * (uint64)param_count;
if (total_size >= UINT32_MAX
|| !(param_values = wasm_malloc((uint32)total_size))) {
|| !(param_values = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("allocate memory for param values failed.");
return false;
}
@ -201,7 +201,7 @@ call_llvm_intrinsic(AOTCompContext *comp_ctx,
param_types, param_count,
param_values);
wasm_free(param_values);
wasm_runtime_free(param_values);
return ret;
}
@ -221,7 +221,7 @@ call_llvm_intrinsic_v(AOTCompContext *comp_ctx,
/* Create param values */
total_size = sizeof(LLVMValueRef) * (uint64)param_count;
if (total_size >= UINT32_MAX
|| !(param_values = wasm_malloc((uint32)total_size))) {
|| !(param_values = wasm_runtime_malloc((uint32)total_size))) {
aot_set_last_error("allocate memory for param values failed.");
return false;
}
@ -234,7 +234,7 @@ call_llvm_intrinsic_v(AOTCompContext *comp_ctx,
param_types, param_count,
param_values);
wasm_free(param_values);
wasm_runtime_free(param_values);
return ret;
}

View File

@ -43,7 +43,7 @@ pop_value_from_wasm_stack(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
*p_value = aot_value->value;
}
wasm_free(aot_value);
wasm_runtime_free(aot_value);
if ((is_32
&& (type != VALUE_TYPE_I32 && type != VALUE_TYPE_F32))

View File

@ -4,7 +4,6 @@
*/
#include "aot_llvm.h"
#include "bh_memory.h"
#include "aot_compiler.h"
#include "../aot/aot_runtime.h"
@ -47,7 +46,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, AOTFuncType *aot_func_type,
/* Initialize parameter types of the LLVM function */
size = sizeof(LLVMTypeRef) * ((uint64)param_count);
if (size >= UINT32_MAX
|| !(param_types = wasm_malloc((uint32)size))) {
|| !(param_types = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -88,7 +87,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, AOTFuncType *aot_func_type,
}
fail:
wasm_free(param_types);
wasm_runtime_free(param_types);
return func;
}
@ -102,7 +101,7 @@ aot_create_func_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
AOTBlock *aot_block;
/* Allocate memory */
if (!(aot_block = wasm_malloc(sizeof(AOTBlock)))) {
if (!(aot_block = wasm_runtime_malloc(sizeof(AOTBlock)))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -129,7 +128,7 @@ aot_create_func_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return aot_block;
fail:
wasm_free(aot_block);
wasm_runtime_free(aot_block);
return NULL;
}
@ -137,7 +136,7 @@ static bool
create_exception_blocks(AOTFuncContext *func_ctx)
{
if (!(func_ctx->exception_blocks =
wasm_malloc(sizeof(LLVMBasicBlockRef) * EXCE_NUM))) {
wasm_runtime_malloc(sizeof(LLVMBasicBlockRef) * EXCE_NUM))) {
aot_set_last_error("allocate memory failed.");
return false;;
}
@ -451,7 +450,7 @@ aot_create_func_context(AOTCompData *comp_data, AOTCompContext *comp_ctx,
size = offsetof(AOTFuncContext, locals) + sizeof(LLVMValueRef) *
((uint64)aot_func_type->param_count + func->local_count);
if (size >= UINT32_MAX
|| !(func_ctx = wasm_malloc((uint32)size))) {
|| !(func_ctx = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -605,9 +604,9 @@ aot_create_func_context(AOTCompData *comp_data, AOTCompContext *comp_ctx,
fail:
if (func_ctx->exception_blocks)
wasm_free(func_ctx->exception_blocks);
wasm_runtime_free(func_ctx->exception_blocks);
aot_block_stack_destroy(&func_ctx->block_stack);
wasm_free(func_ctx);
wasm_runtime_free(func_ctx);
return NULL;
}
@ -619,11 +618,11 @@ aot_destroy_func_contexts(AOTFuncContext **func_ctxes, uint32 count)
for (i = 0; i < count; i++)
if (func_ctxes[i]) {
if (func_ctxes[i]->exception_blocks)
wasm_free(func_ctxes[i]->exception_blocks);
wasm_runtime_free(func_ctxes[i]->exception_blocks);
aot_block_stack_destroy(&func_ctxes[i]->block_stack);
wasm_free(func_ctxes[i]);
wasm_runtime_free(func_ctxes[i]);
}
wasm_free(func_ctxes);
wasm_runtime_free(func_ctxes);
}
/**
@ -639,7 +638,7 @@ aot_create_func_contexts(AOTCompData *comp_data, AOTCompContext *comp_ctx)
/* Allocate memory */
size = sizeof(AOTFuncContext*) * (uint64)comp_data->func_count;
if (size >= UINT32_MAX
|| !(func_ctxes = wasm_malloc((uint32)size))) {
|| !(func_ctxes = wasm_runtime_malloc((uint32)size))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -877,7 +876,7 @@ aot_create_comp_context(AOTCompData *comp_data,
LLVMLinkInMCJIT();
/* Allocate memory */
if (!(comp_ctx = wasm_malloc(sizeof(AOTCompContext)))) {
if (!(comp_ctx = wasm_runtime_malloc(sizeof(AOTCompContext)))) {
aot_set_last_error("allocate memory failed.");
return NULL;
}
@ -1176,7 +1175,7 @@ aot_destroy_comp_context(AOTCompContext *comp_ctx)
if (comp_ctx->func_ctxes)
aot_destroy_func_contexts(comp_ctx->func_ctxes, comp_ctx->func_ctx_count);
wasm_free(comp_ctx);
wasm_runtime_free(comp_ctx);
}
void
@ -1216,7 +1215,7 @@ aot_value_stack_destroy(AOTValueStack *stack)
while (value) {
p = value->next;
wasm_free(value);
wasm_runtime_free(value);
value = p;
}
}
@ -1259,7 +1258,7 @@ aot_block_stack_destroy(AOTBlockStack *stack)
while (block) {
p = block->next;
aot_value_stack_destroy(&block->value_stack);
wasm_free(block);
wasm_runtime_free(block);
block = p;
}
}
@ -1268,5 +1267,5 @@ void
aot_block_destroy(AOTBlock *block)
{
aot_value_stack_destroy(&block->value_stack);
wasm_free(block);
wasm_runtime_free(block);
}