Merge branch main into dev/wasi-libc-windows

This commit is contained in:
Wenyong Huang
2023-11-09 10:13:59 +08:00
48 changed files with 900 additions and 512 deletions

View File

@ -161,8 +161,11 @@ app_instance_repl(wasm_module_inst_t module_inst)
break;
}
if (app_argc != 0) {
const char *exception;
wasm_application_execute_func(module_inst, app_argv[0],
app_argc - 1, app_argv + 1);
if ((exception = wasm_runtime_get_exception(module_inst)))
printf("%s\n", exception);
}
free(app_argv);
}
@ -172,7 +175,37 @@ app_instance_repl(wasm_module_inst_t module_inst)
#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
static char global_heap_buf[WASM_GLOBAL_HEAP_SIZE] = { 0 };
#else
static void *
malloc_func(
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
void *user_data,
#endif
unsigned int size)
{
return malloc(size);
}
static void *
realloc_func(
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
void *user_data,
#endif
void *ptr, unsigned int size)
{
return realloc(ptr, size);
}
static void
free_func(
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
void *user_data,
#endif
void *ptr)
{
free(ptr);
}
#endif /* end of WASM_ENABLE_GLOBAL_HEAP_POOL */
#if WASM_ENABLE_MULTI_MODULE != 0
static char *
@ -200,7 +233,7 @@ module_reader_callback(package_type_t module_type, const char *module_name,
const char *format = "%s/%s%s";
int sz = strlen(module_search_path) + strlen("/") + strlen(module_name)
+ strlen(file_format) + 1;
char *wasm_file_name = BH_MALLOC(sz);
char *wasm_file_name = wasm_runtime_malloc(sz);
if (!wasm_file_name) {
return false;
}
@ -414,9 +447,13 @@ main(int argc, char *argv[])
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
#else
init_args.mem_alloc_type = Alloc_With_Allocator;
init_args.mem_alloc_option.allocator.malloc_func = malloc;
init_args.mem_alloc_option.allocator.realloc_func = realloc;
init_args.mem_alloc_option.allocator.free_func = free;
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
/* Set user data for the allocator is needed */
/* init_args.mem_alloc_option.allocator.user_data = user_data; */
#endif
init_args.mem_alloc_option.allocator.malloc_func = malloc_func;
init_args.mem_alloc_option.allocator.realloc_func = realloc_func;
init_args.mem_alloc_option.allocator.free_func = free_func;
#endif
#if WASM_ENABLE_JIT != 0