Re-org memory allocation interfaces, add --stack-size and --heap-size option (#193)
This commit is contained in:
@ -84,9 +84,9 @@ typedef int16_t lv_coord_t;
|
||||
/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */
|
||||
# define LV_MEM_AUTO_DEFRAG 1
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
# define LV_MEM_CUSTOM_INCLUDE "bh_memory.h" /*Header for the dynamic memory function*/
|
||||
# define LV_MEM_CUSTOM_ALLOC bh_malloc /*Wrapper to malloc*/
|
||||
# define LV_MEM_CUSTOM_FREE bh_free /*Wrapper to free*/
|
||||
# define LV_MEM_CUSTOM_INCLUDE "bh_config.h" /*Header for the dynamic memory function*/
|
||||
# define LV_MEM_CUSTOM_ALLOC BH_MALLOC /*Wrapper to malloc*/
|
||||
# define LV_MEM_CUSTOM_FREE BH_FREE /*Wrapper to free*/
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Garbage Collector settings
|
||||
|
||||
@ -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"
|
||||
@ -466,19 +465,22 @@ static void hal_init(void)
|
||||
// Driver function
|
||||
int iwasm_main(int argc, char *argv[])
|
||||
{
|
||||
RuntimeInitArgs init_args;
|
||||
korp_thread tid;
|
||||
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
memset(&init_args, 0, sizeof(RuntimeInitArgs));
|
||||
|
||||
if (vm_thread_sys_init() != 0) {
|
||||
goto fail1;
|
||||
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);
|
||||
|
||||
/* initialize runtime environment */
|
||||
if (!wasm_runtime_full_init(&init_args)) {
|
||||
bh_printf("Init runtime environment failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!init_connection_framework()) {
|
||||
@ -513,7 +515,6 @@ int iwasm_main(int argc, char *argv[])
|
||||
exit_connection_framework();
|
||||
|
||||
fail1:
|
||||
bh_memory_destroy();
|
||||
|
||||
wasm_runtime_destroy();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -10,7 +10,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"
|
||||
@ -146,16 +145,19 @@ static void hal_init(void)
|
||||
|
||||
int iwasm_main()
|
||||
{
|
||||
RuntimeInitArgs init_args;
|
||||
host_init();
|
||||
|
||||
if (bh_memory_init_with_pool(global_heap_buf, sizeof(global_heap_buf))
|
||||
!= 0) {
|
||||
printf("Init global heap failed.\n");
|
||||
return -1;
|
||||
}
|
||||
memset(&init_args, 0, sizeof(RuntimeInitArgs));
|
||||
|
||||
if (vm_thread_sys_init() != 0) {
|
||||
goto fail1;
|
||||
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);
|
||||
|
||||
/* initialize runtime environment */
|
||||
if (!wasm_runtime_full_init(&init_args)) {
|
||||
bh_printf("Init runtime environment failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
wgl_init();
|
||||
@ -167,7 +169,6 @@ int iwasm_main()
|
||||
// TODO:
|
||||
app_manager_startup(&interface);
|
||||
|
||||
fail1:
|
||||
bh_memory_destroy();
|
||||
wasm_runtime_destroy();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "bh_log.h"
|
||||
#include "bh_platform_log.h"
|
||||
#include "wasm_export.h"
|
||||
#include "bh_memory.h"
|
||||
|
||||
extern int iwasm_main();
|
||||
|
||||
|
||||
@ -10,6 +10,9 @@ set (WAMR_BUILD_PLATFORM "zephyr")
|
||||
|
||||
enable_language (ASM)
|
||||
|
||||
add_definitions(-DWA_MALLOC=wasm_runtime_malloc)
|
||||
add_definitions(-DWA_FREE=wasm_runtime_free)
|
||||
|
||||
# Build as THUMB by default
|
||||
# change to "ARM[sub]", "THUMB[sub]", "X86_32", "MIPS" or "XTENSA"
|
||||
# if we want to support arm_32, x86, mips or xtensa
|
||||
@ -17,7 +20,6 @@ if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
set (WAMR_BUILD_TARGET "THUMBV7")
|
||||
endif ()
|
||||
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_INTERP)
|
||||
# Enable Interpreter by default
|
||||
set (WAMR_BUILD_INTERP 1)
|
||||
|
||||
Reference in New Issue
Block a user