re-org bh_definition.c && introduce wamr fast interpreter (#189)
Co-authored-by: Xu Jun
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
#ifndef _LIB_EXPORT_H_
|
||||
#define _LIB_EXPORT_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -31,25 +33,9 @@ typedef struct NativeSymbol {
|
||||
*
|
||||
* @return the number of the exported API
|
||||
*/
|
||||
int
|
||||
uint32_t
|
||||
get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
||||
|
||||
/**
|
||||
* Get the exported APIs of extended lib, this API isn't provided by WASM VM,
|
||||
* it must be provided by developer to register the extended native APIs,
|
||||
* for example, developer can register his native APIs to extended_native_symbol_defs,
|
||||
* array, and include file ext_lib_export.h which implements this API.
|
||||
* And if developer hasn't any native API to register, he can define an empty
|
||||
* extended_native_symbol_defs array, and then include file ext_lib_export.h to
|
||||
* implements this API.
|
||||
*
|
||||
* @param p_base_lib_apis return the exported API array of extend lib
|
||||
*
|
||||
* @return the number of the exported API
|
||||
*/
|
||||
int
|
||||
get_extend_lib_export_apis(NativeSymbol **p_base_lib_apis);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include "lib_export.h"
|
||||
#include "bh_memory.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -25,21 +26,19 @@ struct WASMModuleInstanceCommon;
|
||||
typedef struct WASMModuleInstanceCommon *wasm_module_inst_t;
|
||||
|
||||
/* Function instance */
|
||||
struct WASMFunctionInstanceCommon;
|
||||
typedef struct WASMFunctionInstanceCommon *wasm_function_inst_t;
|
||||
typedef void WASMFunctionInstanceCommon;
|
||||
typedef WASMFunctionInstanceCommon *wasm_function_inst_t;
|
||||
|
||||
/* WASM section */
|
||||
typedef struct wasm_section {
|
||||
struct wasm_section *next;
|
||||
typedef struct wasm_section_t {
|
||||
struct wasm_section_t *next;
|
||||
/* section type */
|
||||
int section_type;
|
||||
/* section body, not include type and size */
|
||||
uint8_t *section_body;
|
||||
/* section body size */
|
||||
uint32_t section_body_size;
|
||||
} wasm_section_t, *wasm_section_list_t;
|
||||
|
||||
typedef wasm_section_t aot_section_t, *aot_section_list_t;
|
||||
} wasm_section_t, aot_section_t, *wasm_section_list_t, *aot_section_list_t;
|
||||
|
||||
/* Execution environment, e.g. stack info */
|
||||
struct WASMExecEnv;
|
||||
@ -52,6 +51,31 @@ typedef enum {
|
||||
Package_Type_Unknown = 0xFFFF
|
||||
} package_type_t;
|
||||
|
||||
/* Memory allocator type */
|
||||
typedef enum {
|
||||
Alloc_With_Pool = 0,
|
||||
Alloc_With_Allocator
|
||||
} mem_alloc_type_t;
|
||||
|
||||
/* WASM runtime initialize arguments */
|
||||
typedef struct RuntimeInitArgs {
|
||||
mem_alloc_type_t mem_alloc_type;
|
||||
union {
|
||||
struct {
|
||||
void *heap_buf;
|
||||
uint32_t heap_size;
|
||||
} pool;
|
||||
struct {
|
||||
void *malloc_func;
|
||||
void *free_func;
|
||||
} allocator;
|
||||
} mem_alloc;
|
||||
|
||||
const char *native_module_name;
|
||||
NativeSymbol *native_symbols;
|
||||
uint32_t n_native_symbols;
|
||||
} RuntimeInitArgs;
|
||||
|
||||
/**
|
||||
* Initialize the WASM runtime environment.
|
||||
*
|
||||
@ -66,6 +90,25 @@ wasm_runtime_init();
|
||||
void
|
||||
wasm_runtime_destroy();
|
||||
|
||||
/**
|
||||
* Initialize the WASM runtime environment, and also initialize
|
||||
* the memory allocator and register native symbols, which are specified
|
||||
* with init arguments
|
||||
*
|
||||
* @param init_args specifies the init arguments
|
||||
*
|
||||
* @return return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
wasm_runtime_full_init(RuntimeInitArgs *init_args);
|
||||
|
||||
/**
|
||||
* Destroy the wasm runtime environment, and also destroy
|
||||
* the memory allocator and registered native symbols
|
||||
*/
|
||||
void
|
||||
wasm_runtime_full_destroy();
|
||||
|
||||
/**
|
||||
* Get the package type of a buffer.
|
||||
*
|
||||
@ -167,7 +210,7 @@ wasm_runtime_lookup_wasi_start_function(wasm_module_inst_t module_inst);
|
||||
* @return the function instance found
|
||||
*/
|
||||
wasm_function_inst_t
|
||||
wasm_runtime_lookup_function(const wasm_module_inst_t module_inst,
|
||||
wasm_runtime_lookup_function(wasm_module_inst_t const module_inst,
|
||||
const char *name, const char *signature);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user