Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)

* Implement memory profiler, optimize memory usage, modify code indent

* Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default

* Add a new extension library: connection

* Fix bug of reading magic number and version in big endian platform

* Re-org platform APIs: move most platform APIs from iwasm to shared-lib

* Enhance wasm loader to fix some security issues

* Fix issue about illegal load of EXC_RETURN into PC on stm32 board

* Updates that let a restricted version of the interpreter run in SGX

* Enable native/app address validation and conversion for wasm app

* Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused

* Refine binary size and fix several minor issues

Optimize interpreter LOAD/STORE opcodes to decrease the binary size
Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found
Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper
Add macros of global heap size, stack size, heap size for Zephyr main.c
Clear compile warning of wasm_application.c

* Add more strict security checks for libc wrapper API's

* Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files

* Enhance security of libc strcpy/sprintf wrapper function

* Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions

* Remove get_module_inst() and fix issue of call native

* Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate

* Refine interpreter call native process, refine memory boudary check

* Fix issues of invokeNative function of arm/mips/general version

* Add a switch to build simple sample without gui support

* Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code

* Re-org shared lib header files, remove unused info; fix compile issues of vxworks

* Add build target general

* Remove unused files

* Update license header

* test push

* Restore file

* Sync up with internal/feature

* Sync up with internal/feature

* Rename build_wamr_app to build_wasm_app

* Fix small issues of README

* Enhance malformed wasm file checking
Fix issue of print hex int and implement utf8 string check
Fix wasi file read/write right issue
Fix minor issue of build wasm app doc

* Sync up with internal/feature

* Sync up with internal/feature: fix interpreter arm issue, fix read leb issue

* Sync up with internal/feature

* Fix bug of config.h and rename wasi config.h to ssp_config.h

* Sync up with internal/feature

* Import wamr aot

* update document

* update document

* Update document, disable WASI in 32bit

* update document

* remove files

* update document

* Update document

* update document

* update document

* update samples

* Sync up with internal repo
This commit is contained in:
wenyongh
2020-01-21 13:26:14 +08:00
committed by Wang Xin
parent 2a4528c749
commit 46b93b9d22
464 changed files with 25137 additions and 7911 deletions

View File

@ -27,6 +27,16 @@ extern "C" {
#define SECTION_TYPE_CODE 10
#define SECTION_TYPE_DATA 11
typedef enum AOTSectionType {
AOT_SECTION_TYPE_TARGET_INFO = 0,
AOT_SECTION_TYPE_INIT_DATA,
AOT_SECTION_TYPE_TEXT,
AOT_SECTION_TYPE_FUNCTION,
AOT_SECTION_TYPE_EXPORT,
AOT_SECTION_TYPE_RELOCATION,
AOT_SECTION_TYPE_SIGANATURE
} AOTSectionType;
enum {
WASM_Msg_Start = BASE_EVENT_MAX,
TIMER_EVENT_WASM,
@ -42,12 +52,16 @@ typedef struct wasm_data {
wasm_module_inst_t wasm_module_inst;
/* Permissions of the WASM app */
char *perms;
/*thread list mapped with this WASM module */
/* thread list mapped with this WASM module */
korp_tid thread_id;
/* for easily access the containing module data */
module_data* m_data;
/* section list of wasm bytecode */
wasm_section_list_t sections;
/* is bytecode or aot */
bool is_bytecode;
/* sections of wasm bytecode or aot file */
void *sections;
/* execution environment */
wasm_exec_env_t exec_env;
} wasm_data;
/* sensor event */
@ -59,8 +73,8 @@ typedef struct _sensor_event_data {
void *data;
} sensor_event_data_t;
/* WASM App File */
typedef struct wasm_app_file {
/* WASM Bytecode File */
typedef struct wasm_bytecode_file {
/* magics */
int magic;
/* current version */
@ -69,6 +83,26 @@ typedef struct wasm_app_file {
wasm_section_list_t sections;
/* Last WASM section in the list */
wasm_section_t *section_end;
} wasm_bytecode_file_t;
/* WASM AOT File */
typedef struct wasm_aot_file {
/* magics */
int magic;
/* current version */
int version;
/* AOT section list */
aot_section_list_t sections;
/* Last AOT section in the list */
aot_section_t *section_end;
} wasm_aot_file_t;
/* WASM App File */
typedef struct wasm_app_file_t {
union {
wasm_bytecode_file_t bytecode;
wasm_aot_file_t aot;
} u;
} wasm_app_file_t;
extern module_interface wasm_app_module_interface;
@ -80,6 +114,25 @@ extern bool wasm_register_msg_callback(int msg_type,
typedef void (*resource_cleanup_handler_t)(uint32 module_id);
extern bool wasm_register_cleanup_callback(resource_cleanup_handler_t handler);
/**
* Set WASI root dir for modules. On each wasm app installation, a sub dir named
* with the app's name will be created autamically. That wasm app can only access
* this sub dir.
*
* @param root_dir the root dir to set
* @return true for success, false otherwise
*/
bool
wasm_set_wasi_root_dir(const char *root_dir);
/**
* Get WASI root dir
*
* @return the WASI root dir
*/
const char *
wasm_get_wasi_root_dir();
#ifdef __cplusplus
} /* end of extern "C" */
#endif