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

@ -27,7 +27,6 @@
#include "bh_common.h"
#include "bh_queue.h"
#include "bh_thread.h"
#include "bh_memory.h"
#include "runtime_sensor.h"
#include "bi-inc/attr_container.h"
#include "module_wasm_app.h"
@ -448,8 +447,6 @@ static bool parse_args(int argc, char *argv[])
}
static NativeSymbol native_symbols[] = {
#include "runtime_sensor.inl"
#include "connection.inl"
EXPORT_WASM_API_WITH_SIG(display_input_read, "(*)i"),
EXPORT_WASM_API_WITH_SIG(display_flush, "(iiii*)"),
EXPORT_WASM_API_WITH_SIG(display_fill, "(iiii*)"),
@ -461,29 +458,29 @@ static NativeSymbol native_symbols[] = {
// Driver function
int iwasm_main(int argc, char *argv[])
{
RuntimeInitArgs init_args;
korp_thread tid;
uint32 n_native_symbols;
if (!parse_args(argc, argv))
return -1;
if (bh_memory_init_with_pool(global_heap_buf, sizeof(global_heap_buf))
!= 0) {
printf("Init global heap failed.\n");
memset(&init_args, 0, sizeof(RuntimeInitArgs));
init_args.mem_alloc_type = Alloc_With_Pool;
init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
init_args.native_module_name = "env";
init_args.n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol);
init_args.native_symbols = native_symbols;
/* initialize runtime environment */
if (!wasm_runtime_full_init(&init_args)) {
bh_printf("Init runtime environment failed.\n");
return -1;
}
if (vm_thread_sys_init() != 0) {
goto fail1;
}
/* Register native functions */
n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol);
if (!wasm_runtime_register_natives("env",
native_symbols, n_native_symbols)) {
goto fail1;
}
if (!init_connection_framework()) {
vm_thread_sys_destroy();
goto fail1;
@ -514,7 +511,7 @@ int iwasm_main(int argc, char *argv[])
exit_connection_framework();
fail1:
bh_memory_destroy();
wasm_runtime_destroy();
return -1;
}