mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 17:35:13 +00:00
Fix some coding style issues, fix doc typo and refine some codes (#392)
This commit is contained in:
parent
7c8ccc7c26
commit
e501a6963b
|
@ -2202,9 +2202,9 @@ interp_process_export(wasm_store_t *store,
|
||||||
|
|
||||||
external = wasm_global_as_extern(global);
|
external = wasm_global_as_extern(global);
|
||||||
break;
|
break;
|
||||||
// TODO:
|
|
||||||
case EXPORT_KIND_MEMORY:
|
case EXPORT_KIND_MEMORY:
|
||||||
case EXPORT_KIND_TABLE:
|
case EXPORT_KIND_TABLE:
|
||||||
|
/* TODO: */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
|
@ -31,9 +31,9 @@ typedef enum runtime_mode_e {
|
||||||
} runtime_mode_e;
|
} runtime_mode_e;
|
||||||
|
|
||||||
struct wasm_engine_t {
|
struct wasm_engine_t {
|
||||||
// support one store for now
|
/* support one store for now */
|
||||||
wasm_store_vec_t *stores;
|
wasm_store_vec_t *stores;
|
||||||
// Interpreter by deault
|
/* Interpreter by deault */
|
||||||
runtime_mode_e mode;
|
runtime_mode_e mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,21 +49,21 @@ struct wasm_valtype_t {
|
||||||
|
|
||||||
struct wasm_functype_t {
|
struct wasm_functype_t {
|
||||||
uint32 extern_kind;
|
uint32 extern_kind;
|
||||||
// gona to new and delete own
|
/* gona to new and delete own */
|
||||||
wasm_valtype_vec_t *params;
|
wasm_valtype_vec_t *params;
|
||||||
wasm_valtype_vec_t *results;
|
wasm_valtype_vec_t *results;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wasm_globaltype_t {
|
struct wasm_globaltype_t {
|
||||||
uint32 extern_kind;
|
uint32 extern_kind;
|
||||||
// gona to new and delete own
|
/* gona to new and delete own */
|
||||||
wasm_valtype_t *val_type;
|
wasm_valtype_t *val_type;
|
||||||
wasm_mutability_t mutability;
|
wasm_mutability_t mutability;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wasm_tabletype_t {
|
struct wasm_tabletype_t {
|
||||||
uint32 extern_kind;
|
uint32 extern_kind;
|
||||||
// always be WASM_FUNCREF
|
/* always be WASM_FUNCREF */
|
||||||
wasm_valtype_t *type;
|
wasm_valtype_t *type;
|
||||||
wasm_limits_t *limits;
|
wasm_limits_t *limits;
|
||||||
};
|
};
|
||||||
|
|
|
@ -791,6 +791,7 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
|
||||||
wasm_exec_env_destroy(exec_env);
|
wasm_exec_env_destroy(exec_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (WASM_ENABLE_MEMORY_PROFILING != 0) || (WASM_ENABLE_MEMORY_TRACING != 0)
|
||||||
void
|
void
|
||||||
wasm_runtime_dump_module_mem_consumption(const WASMModuleCommon *module)
|
wasm_runtime_dump_module_mem_consumption(const WASMModuleCommon *module)
|
||||||
{
|
{
|
||||||
|
@ -872,7 +873,6 @@ wasm_runtime_dump_exec_env_mem_consumption(const WASMExecEnv *exec_env)
|
||||||
os_printf(" stack size: %u\n", exec_env->wasm_stack_size);
|
os_printf(" stack size: %u\n", exec_env->wasm_stack_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WASM_ENABLE_MEMORY_PROFILING != 0
|
|
||||||
uint32
|
uint32
|
||||||
gc_get_heap_highmark_size(void *heap);
|
gc_get_heap_highmark_size(void *heap);
|
||||||
|
|
||||||
|
@ -951,7 +951,8 @@ wasm_runtime_dump_mem_consumption(WASMExecEnv *exec_env)
|
||||||
|
|
||||||
os_printf("Total app heap used: %u\n", app_heap_peak_size);
|
os_printf("Total app heap used: %u\n", app_heap_peak_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0)
|
||||||
|
|| (WASM_ENABLE_MEMORY_TRACING != 0) */
|
||||||
|
|
||||||
WASMModuleInstanceCommon *
|
WASMModuleInstanceCommon *
|
||||||
wasm_runtime_get_module_inst(WASMExecEnv *exec_env)
|
wasm_runtime_get_module_inst(WASMExecEnv *exec_env)
|
||||||
|
@ -2645,7 +2646,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = !wasm_runtime_get_exception(module) ? true : false;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (argv1 != argv_buf)
|
if (argv1 != argv_buf)
|
||||||
|
@ -2900,7 +2901,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
exec_env->attachment = NULL;
|
exec_env->attachment = NULL;
|
||||||
|
|
||||||
ret = true;
|
ret = !wasm_runtime_get_exception(module) ? true : false;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (argv1 != argv_buf)
|
if (argv1 != argv_buf)
|
||||||
|
@ -3053,7 +3054,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
exec_env->attachment = NULL;
|
exec_env->attachment = NULL;
|
||||||
|
|
||||||
ret = true;
|
ret = !wasm_runtime_get_exception(module) ? true : false;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (argv1 != argv_buf)
|
if (argv1 != argv_buf)
|
||||||
|
@ -3231,7 +3232,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
exec_env->attachment = NULL;
|
exec_env->attachment = NULL;
|
||||||
|
|
||||||
ret = true;
|
ret = !wasm_runtime_get_exception(module) ? true : false;
|
||||||
fail:
|
fail:
|
||||||
if (argv1 != argv_buf)
|
if (argv1 != argv_buf)
|
||||||
wasm_runtime_free(argv1);
|
wasm_runtime_free(argv1);
|
||||||
|
|
|
@ -175,7 +175,7 @@ typedef struct WASMGlobalImport {
|
||||||
WASMValue global_data_linked;
|
WASMValue global_data_linked;
|
||||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||||
/* imported function pointer after linked */
|
/* imported function pointer after linked */
|
||||||
// TODO: remove if not necessary
|
/* TODO: remove if not needed */
|
||||||
WASMModule *import_module;
|
WASMModule *import_module;
|
||||||
WASMGlobal *import_global_linked;
|
WASMGlobal *import_global_linked;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3269,7 +3269,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
|
||||||
WASMFunctionInstance *function,
|
WASMFunctionInstance *function,
|
||||||
uint32 argc, uint32 argv[])
|
uint32 argc, uint32 argv[])
|
||||||
{
|
{
|
||||||
// TODO: since module_inst = exec_env->module_inst, shall we remove the 1st arg?
|
|
||||||
WASMRuntimeFrame *prev_frame = wasm_exec_env_get_cur_frame(exec_env);
|
WASMRuntimeFrame *prev_frame = wasm_exec_env_get_cur_frame(exec_env);
|
||||||
WASMInterpFrame *frame, *outs_area;
|
WASMInterpFrame *frame, *outs_area;
|
||||||
|
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ wasm_interp_dump_op_count()
|
||||||
|
|
||||||
#if WASM_ENABLE_LABELS_AS_VALUES != 0
|
#if WASM_ENABLE_LABELS_AS_VALUES != 0
|
||||||
|
|
||||||
//#define HANDLE_OP(opcode) HANDLE_##opcode:printf(#opcode"\n");h_##opcode
|
/* #define HANDLE_OP(opcode) HANDLE_##opcode:printf(#opcode"\n");h_##opcode */
|
||||||
#if WASM_ENABLE_OPCODE_COUNTER != 0
|
#if WASM_ENABLE_OPCODE_COUNTER != 0
|
||||||
#define HANDLE_OP(opcode) HANDLE_##opcode:opcode_table[opcode].count++;h_##opcode
|
#define HANDLE_OP(opcode) HANDLE_##opcode:opcode_table[opcode].count++;h_##opcode
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -3961,7 +3961,7 @@ fail:
|
||||||
LOG_OP("\nemit_op [%02x]\t", opcode); \
|
LOG_OP("\nemit_op [%02x]\t", opcode); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// drop local.get / const / block / loop / end
|
/* drop local.get / const / block / loop / end */
|
||||||
#define skip_label() do { \
|
#define skip_label() do { \
|
||||||
wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); \
|
wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); \
|
||||||
LOG_OP("\ndelete last op\n"); \
|
LOG_OP("\ndelete last op\n"); \
|
||||||
|
@ -4334,7 +4334,7 @@ wasm_loader_push_frame_offset(WASMLoaderContext *ctx, uint8 type,
|
||||||
if (type == VALUE_TYPE_VOID)
|
if (type == VALUE_TYPE_VOID)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// only check memory overflow in first traverse
|
/* only check memory overflow in first traverse */
|
||||||
if (ctx->p_code_compiled == NULL) {
|
if (ctx->p_code_compiled == NULL) {
|
||||||
if (!check_offset_push(ctx, error_buf, error_buf_size))
|
if (!check_offset_push(ctx, error_buf, error_buf_size))
|
||||||
return false;
|
return false;
|
||||||
|
@ -5695,7 +5695,7 @@ handle_op_block_and_loop:
|
||||||
+ func->func_type->param_count + idx);
|
+ func->func_type->param_count + idx);
|
||||||
POP_TYPE(ret_type);
|
POP_TYPE(ret_type);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// emit the offset after return opcode
|
/* emit the offset after return opcode */
|
||||||
POP_OFFSET_TYPE(ret_type);
|
POP_OFFSET_TYPE(ret_type);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5714,7 +5714,7 @@ handle_op_block_and_loop:
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, func_idx);
|
read_leb_uint32(p, p_end, func_idx);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// we need to emit func_idx before arguments
|
/* we need to emit func_idx before arguments */
|
||||||
emit_uint32(loader_ctx, func_idx);
|
emit_uint32(loader_ctx, func_idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5769,7 +5769,7 @@ handle_op_block_and_loop:
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, type_idx);
|
read_leb_uint32(p, p_end, type_idx);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// we need to emit func_idx before arguments
|
/* we need to emit func_idx before arguments */
|
||||||
emit_uint32(loader_ctx, type_idx);
|
emit_uint32(loader_ctx, type_idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2890,7 +2890,7 @@ wasm_loader_pop_frame_csp(WASMLoaderContext *ctx,
|
||||||
LOG_OP("\nemit_op [%02x]\t", opcode); \
|
LOG_OP("\nemit_op [%02x]\t", opcode); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// drop local.get / const / block / loop / end
|
/* drop local.get / const / block / loop / end */
|
||||||
#define skip_label() do { \
|
#define skip_label() do { \
|
||||||
wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); \
|
wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); \
|
||||||
LOG_OP("\ndelete last op\n"); \
|
LOG_OP("\ndelete last op\n"); \
|
||||||
|
@ -3264,7 +3264,7 @@ wasm_loader_push_frame_offset(WASMLoaderContext *ctx, uint8 type,
|
||||||
if (type == VALUE_TYPE_VOID)
|
if (type == VALUE_TYPE_VOID)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// only check memory overflow in first traverse
|
/* only check memory overflow in first traverse */
|
||||||
if (ctx->p_code_compiled == NULL) {
|
if (ctx->p_code_compiled == NULL) {
|
||||||
if (!check_offset_push(ctx, error_buf, error_buf_size))
|
if (!check_offset_push(ctx, error_buf, error_buf_size))
|
||||||
return false;
|
return false;
|
||||||
|
@ -4525,7 +4525,7 @@ handle_op_block_and_loop:
|
||||||
+ func->func_type->param_count + idx);
|
+ func->func_type->param_count + idx);
|
||||||
POP_TYPE(ret_type);
|
POP_TYPE(ret_type);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// emit the offset after return opcode
|
/* emit the offset after return opcode */
|
||||||
POP_OFFSET_TYPE(ret_type);
|
POP_OFFSET_TYPE(ret_type);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -4544,7 +4544,7 @@ handle_op_block_and_loop:
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, func_idx);
|
read_leb_uint32(p, p_end, func_idx);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// we need to emit func_idx before arguments
|
/* we need to emit func_idx before arguments */
|
||||||
emit_uint32(loader_ctx, func_idx);
|
emit_uint32(loader_ctx, func_idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4592,7 +4592,7 @@ handle_op_block_and_loop:
|
||||||
|
|
||||||
read_leb_uint32(p, p_end, type_idx);
|
read_leb_uint32(p, p_end, type_idx);
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
// we need to emit func_idx before arguments
|
/* we need to emit func_idx before arguments */
|
||||||
emit_uint32(loader_ctx, type_idx);
|
emit_uint32(loader_ctx, type_idx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -330,15 +330,15 @@ memories_instantiate(const WASMModule *module,
|
||||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||||
WASMMemoryInstance *memory_inst_linked = NULL;
|
WASMMemoryInstance *memory_inst_linked = NULL;
|
||||||
if (import->u.memory.import_module != NULL) {
|
if (import->u.memory.import_module != NULL) {
|
||||||
|
WASMModuleInstance *module_inst_linked;
|
||||||
|
|
||||||
LOG_DEBUG("(%s, %s) is a memory of a sub-module",
|
LOG_DEBUG("(%s, %s) is a memory of a sub-module",
|
||||||
import->u.memory.module_name,
|
import->u.memory.module_name,
|
||||||
import->u.memory.field_name);
|
import->u.memory.field_name);
|
||||||
|
|
||||||
// TODO: how about native memory ?
|
module_inst_linked =
|
||||||
WASMModuleInstance *module_inst_linked =
|
get_sub_module_inst(module_inst,
|
||||||
get_sub_module_inst(
|
import->u.memory.import_module);
|
||||||
module_inst,
|
|
||||||
import->u.memory.import_module);
|
|
||||||
bh_assert(module_inst_linked);
|
bh_assert(module_inst_linked);
|
||||||
|
|
||||||
memory_inst_linked =
|
memory_inst_linked =
|
||||||
|
|
|
@ -112,38 +112,24 @@ int os_mutex_destroy(korp_mutex *mutex)
|
||||||
return ret == 0 ? BHT_OK : BHT_ERROR;
|
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returned error (EINVAL, EAGAIN and EDEADLK) from
|
|
||||||
locking the mutex indicates some logic error present in
|
|
||||||
the program somewhere.
|
|
||||||
Don't try to recover error for an existing unknown error.*/
|
|
||||||
int os_mutex_lock(korp_mutex *mutex)
|
int os_mutex_lock(korp_mutex *mutex)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(mutex);
|
assert(mutex);
|
||||||
ret = pthread_mutex_lock(mutex);
|
ret = pthread_mutex_lock(mutex);
|
||||||
if (0 != ret) {
|
|
||||||
os_printf("vm mutex lock failed (ret=%d)!\n", ret);
|
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returned error (EINVAL, EAGAIN and EPERM) from
|
|
||||||
unlocking the mutex indicates some logic error present
|
|
||||||
in the program somewhere.
|
|
||||||
Don't try to recover error for an existing unknown error.*/
|
|
||||||
int os_mutex_unlock(korp_mutex *mutex)
|
int os_mutex_unlock(korp_mutex *mutex)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(mutex);
|
assert(mutex);
|
||||||
ret = pthread_mutex_unlock(mutex);
|
ret = pthread_mutex_unlock(mutex);
|
||||||
if (0 != ret) {
|
|
||||||
os_printf("vm mutex unlock failed (ret=%d)!\n", ret);
|
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int os_cond_init(korp_cond *cond)
|
int os_cond_init(korp_cond *cond)
|
||||||
|
|
|
@ -36,11 +36,8 @@ os_mutex_lock(korp_mutex *mutex)
|
||||||
|
|
||||||
assert(mutex);
|
assert(mutex);
|
||||||
ret = pthread_mutex_lock(mutex);
|
ret = pthread_mutex_lock(mutex);
|
||||||
if (0 != ret) {
|
|
||||||
os_printf("vm mutex lock failed (ret=%d)!\n", ret);
|
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -50,11 +47,8 @@ os_mutex_unlock(korp_mutex *mutex)
|
||||||
|
|
||||||
assert(mutex);
|
assert(mutex);
|
||||||
ret = pthread_mutex_unlock(mutex);
|
ret = pthread_mutex_unlock(mutex);
|
||||||
if (0 != ret) {
|
|
||||||
os_printf("vm mutex unlock failed (ret=%d)!\n", ret);
|
return ret == 0 ? BHT_OK : BHT_ERROR;
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 *
|
uint8 *
|
||||||
|
|
|
@ -61,19 +61,11 @@ int os_mutex_destroy(korp_mutex *mutex)
|
||||||
return BHT_OK;
|
return BHT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returned error (EINVAL, EAGAIN and EDEADLK) from
|
|
||||||
locking the mutex indicates some logic error present in
|
|
||||||
the program somewhere.
|
|
||||||
Don't try to recover error for an existing unknown error.*/
|
|
||||||
int os_mutex_lock(korp_mutex *mutex)
|
int os_mutex_lock(korp_mutex *mutex)
|
||||||
{
|
{
|
||||||
return BHT_ERROR;
|
return BHT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returned error (EINVAL, EAGAIN and EPERM) from
|
|
||||||
unlocking the mutex indicates some logic error present
|
|
||||||
in the program somewhere.
|
|
||||||
Don't try to recover error for an existing unknown error.*/
|
|
||||||
int os_mutex_unlock(korp_mutex *mutex)
|
int os_mutex_unlock(korp_mutex *mutex)
|
||||||
{
|
{
|
||||||
return BHT_OK;
|
return BHT_OK;
|
||||||
|
|
|
@ -69,7 +69,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM
|
||||||
> Note: by default only platform linux/darwin/android/vxworks 64-bit will enable boundary check with hardware trap in AOT or JIT mode, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance.
|
> Note: by default only platform linux/darwin/android/vxworks 64-bit will enable boundary check with hardware trap in AOT or JIT mode, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance.
|
||||||
|
|
||||||
#### **Enable memory profiling (Experiment)**
|
#### **Enable memory profiling (Experiment)**
|
||||||
- **WAMR_BUILD_MEMORY_PROFLING**=1/0, default to disable if not set
|
- **WAMR_BUILD_MEMORY_PROFILING**=1/0, default to disable if not set
|
||||||
> Note: if it is enabled, developer can use API `void wasm_runtime_dump_mem_consumption(wasm_exec_env_t exec_env)` to dump the memory consumption info.
|
> Note: if it is enabled, developer can use API `void wasm_runtime_dump_mem_consumption(wasm_exec_env_t exec_env)` to dump the memory consumption info.
|
||||||
Currently we only profile the memory consumption of module, module_instance and exec_env, the memory consumed by other components such as `wasi-ctx`, `multi-module` and `thread-manager` are not included.
|
Currently we only profile the memory consumption of module, module_instance and exec_env, the memory consumed by other components such as `wasi-ctx`, `multi-module` and `thread-manager` are not included.
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ WAMR_DIR=${PWD}/../../..
|
||||||
--sysroot=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot \
|
--sysroot=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot \
|
||||||
-Wl,--allow-undefined-file=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt \
|
-Wl,--allow-undefined-file=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt \
|
||||||
-Wl,--export=main, \
|
-Wl,--export=main, \
|
||||||
|
-Wl,--export=__data_end, -Wl,--export=__heap_base \
|
||||||
-Wl,--no-threads,--strip-all,--no-entry \
|
-Wl,--no-threads,--strip-all,--no-entry \
|
||||||
-nostdlib -o test.wasm *.c
|
-nostdlib -o test.wasm *.c
|
||||||
#./jeffdump -o test_wasm.h -n wasm_test_file test.wasm
|
#./jeffdump -o test_wasm.h -n wasm_test_file test.wasm
|
||||||
|
|
|
@ -5,55 +5,42 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The byte array buffer is the file content of a test wasm binary file,
|
* The byte array buffer is the file content of a test wasm binary file,
|
||||||
* which is compiled by emcc or clang toolchain from C source file of:
|
* which is compiled by wasi-sdk toolchain from C source file of:
|
||||||
* core/iwasm/app-samples/hello-world/main.c.
|
* product-mini/app-samples/hello-world/main.c.
|
||||||
*/
|
*/
|
||||||
unsigned char wasm_test_file[] = { 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00,
|
unsigned char wasm_test_file[] = {
|
||||||
0x00, 0x00, 0x0D, 0x06, 0x64, 0x79, 0x6C, 0x69, 0x6E, 0x6B, 0xC0, 0x80,
|
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60,
|
||||||
0x04, 0x04, 0x00, 0x00, 0x01, 0x13, 0x04, 0x60, 0x01, 0x7F, 0x00, 0x60,
|
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01,
|
||||||
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x00,
|
0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75,
|
||||||
0x00, 0x02, 0x58, 0x06, 0x03, 0x65, 0x6E, 0x76, 0x05, 0x5F, 0x66, 0x72,
|
0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C,
|
||||||
0x65, 0x65, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F, 0x6D, 0x61,
|
0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72,
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F,
|
0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66,
|
||||||
0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76,
|
0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01,
|
||||||
0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76,
|
0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x13, 0x03,
|
||||||
0x0D, 0x5F, 0x5F, 0x6D, 0x65, 0x6D, 0x6F, 0x72, 0x79, 0x5F, 0x62, 0x61,
|
0x7F, 0x01, 0x41, 0xC0, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0xBA, 0x08, 0x0B,
|
||||||
0x73, 0x65, 0x03, 0x7F, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x65,
|
0x7F, 0x00, 0x41, 0xC0, 0x28, 0x0B, 0x07, 0x2C, 0x04, 0x06, 0x6D, 0x65,
|
||||||
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x01, 0x03, 0x04, 0x03, 0x02, 0x03,
|
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74,
|
||||||
0x03, 0x06, 0x10, 0x03, 0x7F, 0x01, 0x41, 0x00, 0x0B, 0x7F, 0x01, 0x41,
|
0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, 0x01, 0x0B, 0x5F, 0x5F, 0x68, 0x65,
|
||||||
0x00, 0x0B, 0x7F, 0x00, 0x41, 0x1B, 0x0B, 0x07, 0x33, 0x04, 0x12, 0x5F,
|
0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x02, 0x04, 0x6D, 0x61,
|
||||||
0x5F, 0x70, 0x6F, 0x73, 0x74, 0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E,
|
0x69, 0x6E, 0x00, 0x04, 0x0A, 0xB2, 0x01, 0x01, 0xAF, 0x01, 0x01, 0x03,
|
||||||
0x74, 0x69, 0x61, 0x74, 0x65, 0x00, 0x06, 0x05, 0x5F, 0x6D, 0x61, 0x69,
|
0x7F, 0x23, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02,
|
||||||
0x6E, 0x00, 0x04, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74, 0x53,
|
0x24, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x9B, 0x88, 0x80, 0x80, 0x00,
|
||||||
0x65, 0x74, 0x73, 0x00, 0x05, 0x04, 0x5F, 0x73, 0x74, 0x72, 0x03, 0x03,
|
0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41,
|
||||||
0x0A, 0xBA, 0x01, 0x03, 0x9E, 0x01, 0x01, 0x01, 0x7F, 0x23, 0x01, 0x21,
|
0x80, 0x08, 0x10, 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00,
|
||||||
0x00, 0x23, 0x01, 0x41, 0x10, 0x6A, 0x24, 0x01, 0x20, 0x00, 0x41, 0x08,
|
0x41, 0xA8, 0x88, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00,
|
||||||
0x6A, 0x21, 0x02, 0x23, 0x00, 0x41, 0x1B, 0x6A, 0x10, 0x03, 0x1A, 0x41,
|
0x1A, 0x41, 0x7F, 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x80, 0x08, 0x10, 0x01, 0x21, 0x01, 0x20, 0x01, 0x04, 0x7F, 0x20, 0x00,
|
0x36, 0x02, 0x10, 0x41, 0x80, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41,
|
||||||
0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x20, 0x00, 0x10, 0x02, 0x1A,
|
0x10, 0x6A, 0x10, 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21,
|
||||||
0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x0D, 0x3A, 0x00, 0x00, 0x20, 0x01,
|
0x04, 0x20, 0x03, 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x88,
|
||||||
0x23, 0x00, 0x2C, 0x00, 0x0E, 0x3A, 0x00, 0x01, 0x20, 0x01, 0x23, 0x00,
|
0x80, 0x80, 0x00, 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00,
|
||||||
0x2C, 0x00, 0x0F, 0x3A, 0x00, 0x02, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00,
|
0x8D, 0x88, 0x80, 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x10, 0x3A, 0x00, 0x03, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x11, 0x3A,
|
0x36, 0x02, 0x00, 0x41, 0x93, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10,
|
||||||
0x00, 0x04, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x12, 0x3A, 0x00, 0x05,
|
0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x41, 0x13, 0x6A,
|
0x80, 0x00, 0x0B, 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x10, 0x02, 0x1A, 0x20, 0x01, 0x10, 0x00, 0x20, 0x00, 0x24,
|
0x80, 0x00, 0x20, 0x04, 0x0B, 0x0B, 0x41, 0x01, 0x00, 0x41, 0x80, 0x08,
|
||||||
0x01, 0x41, 0x00, 0x05, 0x23, 0x00, 0x41, 0x28, 0x6A, 0x10, 0x03, 0x1A,
|
0x0B, 0x3A, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25,
|
||||||
0x20, 0x00, 0x24, 0x01, 0x41, 0x7F, 0x0B, 0x0B, 0x03, 0x00, 0x01, 0x0B,
|
0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66,
|
||||||
0x14, 0x00, 0x23, 0x00, 0x41, 0x40, 0x6B, 0x24, 0x01, 0x23, 0x01, 0x41,
|
0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77,
|
||||||
0x80, 0x80, 0x04, 0x6A, 0x24, 0x02, 0x10, 0x05, 0x0B, 0x0B, 0x3F, 0x01,
|
0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63,
|
||||||
0x00, 0x23, 0x00, 0x0B, 0x39, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72,
|
0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00
|
||||||
0x3A, 0x20, 0x25, 0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00,
|
};
|
||||||
0x62, 0x75, 0x66, 0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C,
|
|
||||||
0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C,
|
|
||||||
0x6C, 0x6F, 0x63, 0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C,
|
|
||||||
0x65, 0x64, 0x00, 0x50, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x01, 0x49, 0x07,
|
|
||||||
0x00, 0x05, 0x5F, 0x66, 0x72, 0x65, 0x65, 0x01, 0x07, 0x5F, 0x6D, 0x61,
|
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x02, 0x07, 0x5F, 0x70, 0x72, 0x69, 0x6E, 0x74,
|
|
||||||
0x66, 0x03, 0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x04, 0x05, 0x5F, 0x6D,
|
|
||||||
0x61, 0x69, 0x6E, 0x05, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74,
|
|
||||||
0x53, 0x65, 0x74, 0x73, 0x06, 0x12, 0x5F, 0x5F, 0x70, 0x6F, 0x73, 0x74,
|
|
||||||
0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74, 0x69, 0x61, 0x74, 0x65,
|
|
||||||
0x00, 0x20, 0x10, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x4D, 0x61, 0x70,
|
|
||||||
0x70, 0x69, 0x6E, 0x67, 0x55, 0x52, 0x4C, 0x0E, 0x61, 0x2E, 0x6F, 0x75,
|
|
||||||
0x74, 0x2E, 0x77, 0x61, 0x73, 0x6D, 0x2E, 0x6D, 0x61, 0x70 };
|
|
||||||
|
|
|
@ -20,56 +20,42 @@ app_instance_main(wasm_module_inst_t module_inst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING! CAN NOT BE READ ONLY!!!
|
// WARNING! CAN NOT BE READ ONLY!!!
|
||||||
static unsigned char wasm_test_file[] = { 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00,
|
static unsigned char wasm_test_file[] = {
|
||||||
0x00, 0x00, 0x0D, 0x06, 0x64, 0x79, 0x6C, 0x69, 0x6E, 0x6B, 0xC0, 0x80,
|
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60,
|
||||||
0x04, 0x04, 0x00, 0x00, 0x01, 0x13, 0x04, 0x60, 0x01, 0x7F, 0x00, 0x60,
|
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01,
|
||||||
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x00,
|
0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75,
|
||||||
0x00, 0x02, 0x58, 0x06, 0x03, 0x65, 0x6E, 0x76, 0x05, 0x5F, 0x66, 0x72,
|
0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C,
|
||||||
0x65, 0x65, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F, 0x6D, 0x61,
|
0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72,
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F,
|
0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66,
|
||||||
0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76,
|
0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01,
|
||||||
0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76,
|
0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x13, 0x03,
|
||||||
0x0D, 0x5F, 0x5F, 0x6D, 0x65, 0x6D, 0x6F, 0x72, 0x79, 0x5F, 0x62, 0x61,
|
0x7F, 0x01, 0x41, 0xC0, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0xBA, 0x08, 0x0B,
|
||||||
0x73, 0x65, 0x03, 0x7F, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x65,
|
0x7F, 0x00, 0x41, 0xC0, 0x28, 0x0B, 0x07, 0x2C, 0x04, 0x06, 0x6D, 0x65,
|
||||||
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x01, 0x03, 0x04, 0x03, 0x02, 0x03,
|
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74,
|
||||||
0x03, 0x06, 0x10, 0x03, 0x7F, 0x01, 0x41, 0x00, 0x0B, 0x7F, 0x01, 0x41,
|
0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, 0x01, 0x0B, 0x5F, 0x5F, 0x68, 0x65,
|
||||||
0x00, 0x0B, 0x7F, 0x00, 0x41, 0x1B, 0x0B, 0x07, 0x33, 0x04, 0x12, 0x5F,
|
0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x02, 0x04, 0x6D, 0x61,
|
||||||
0x5F, 0x70, 0x6F, 0x73, 0x74, 0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E,
|
0x69, 0x6E, 0x00, 0x04, 0x0A, 0xB2, 0x01, 0x01, 0xAF, 0x01, 0x01, 0x03,
|
||||||
0x74, 0x69, 0x61, 0x74, 0x65, 0x00, 0x06, 0x05, 0x5F, 0x6D, 0x61, 0x69,
|
0x7F, 0x23, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02,
|
||||||
0x6E, 0x00, 0x04, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74, 0x53,
|
0x24, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x9B, 0x88, 0x80, 0x80, 0x00,
|
||||||
0x65, 0x74, 0x73, 0x00, 0x05, 0x04, 0x5F, 0x73, 0x74, 0x72, 0x03, 0x03,
|
0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41,
|
||||||
0x0A, 0xBA, 0x01, 0x03, 0x9E, 0x01, 0x01, 0x01, 0x7F, 0x23, 0x01, 0x21,
|
0x80, 0x08, 0x10, 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00,
|
||||||
0x00, 0x23, 0x01, 0x41, 0x10, 0x6A, 0x24, 0x01, 0x20, 0x00, 0x41, 0x08,
|
0x41, 0xA8, 0x88, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00,
|
||||||
0x6A, 0x21, 0x02, 0x23, 0x00, 0x41, 0x1B, 0x6A, 0x10, 0x03, 0x1A, 0x41,
|
0x1A, 0x41, 0x7F, 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x80, 0x08, 0x10, 0x01, 0x21, 0x01, 0x20, 0x01, 0x04, 0x7F, 0x20, 0x00,
|
0x36, 0x02, 0x10, 0x41, 0x80, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41,
|
||||||
0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x20, 0x00, 0x10, 0x02, 0x1A,
|
0x10, 0x6A, 0x10, 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21,
|
||||||
0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x0D, 0x3A, 0x00, 0x00, 0x20, 0x01,
|
0x04, 0x20, 0x03, 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x88,
|
||||||
0x23, 0x00, 0x2C, 0x00, 0x0E, 0x3A, 0x00, 0x01, 0x20, 0x01, 0x23, 0x00,
|
0x80, 0x80, 0x00, 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00,
|
||||||
0x2C, 0x00, 0x0F, 0x3A, 0x00, 0x02, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00,
|
0x8D, 0x88, 0x80, 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x10, 0x3A, 0x00, 0x03, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x11, 0x3A,
|
0x36, 0x02, 0x00, 0x41, 0x93, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10,
|
||||||
0x00, 0x04, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x12, 0x3A, 0x00, 0x05,
|
0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x41, 0x13, 0x6A,
|
0x80, 0x00, 0x0B, 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x10, 0x02, 0x1A, 0x20, 0x01, 0x10, 0x00, 0x20, 0x00, 0x24,
|
0x80, 0x00, 0x20, 0x04, 0x0B, 0x0B, 0x41, 0x01, 0x00, 0x41, 0x80, 0x08,
|
||||||
0x01, 0x41, 0x00, 0x05, 0x23, 0x00, 0x41, 0x28, 0x6A, 0x10, 0x03, 0x1A,
|
0x0B, 0x3A, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25,
|
||||||
0x20, 0x00, 0x24, 0x01, 0x41, 0x7F, 0x0B, 0x0B, 0x03, 0x00, 0x01, 0x0B,
|
0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66,
|
||||||
0x14, 0x00, 0x23, 0x00, 0x41, 0x40, 0x6B, 0x24, 0x01, 0x23, 0x01, 0x41,
|
0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77,
|
||||||
0x80, 0x80, 0x04, 0x6A, 0x24, 0x02, 0x10, 0x05, 0x0B, 0x0B, 0x3F, 0x01,
|
0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63,
|
||||||
0x00, 0x23, 0x00, 0x0B, 0x39, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72,
|
0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00
|
||||||
0x3A, 0x20, 0x25, 0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00,
|
};
|
||||||
0x62, 0x75, 0x66, 0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C,
|
|
||||||
0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C,
|
|
||||||
0x6C, 0x6F, 0x63, 0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C,
|
|
||||||
0x65, 0x64, 0x00, 0x50, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x01, 0x49, 0x07,
|
|
||||||
0x00, 0x05, 0x5F, 0x66, 0x72, 0x65, 0x65, 0x01, 0x07, 0x5F, 0x6D, 0x61,
|
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x02, 0x07, 0x5F, 0x70, 0x72, 0x69, 0x6E, 0x74,
|
|
||||||
0x66, 0x03, 0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x04, 0x05, 0x5F, 0x6D,
|
|
||||||
0x61, 0x69, 0x6E, 0x05, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74,
|
|
||||||
0x53, 0x65, 0x74, 0x73, 0x06, 0x12, 0x5F, 0x5F, 0x70, 0x6F, 0x73, 0x74,
|
|
||||||
0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74, 0x69, 0x61, 0x74, 0x65,
|
|
||||||
0x00, 0x20, 0x10, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x4D, 0x61, 0x70,
|
|
||||||
0x70, 0x69, 0x6E, 0x67, 0x55, 0x52, 0x4C, 0x0E, 0x61, 0x2E, 0x6F, 0x75,
|
|
||||||
0x74, 0x2E, 0x77, 0x61, 0x73, 0x6D, 0x2E, 0x6D, 0x61, 0x70 };
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT void JNICALL
|
extern "C" JNIEXPORT void JNICALL
|
||||||
Java_com_intel_wasm_api_Runtime_run(JNIEnv *env, jclass thiz) {
|
Java_com_intel_wasm_api_Runtime_run(JNIEnv *env, jclass thiz) {
|
||||||
|
|
|
@ -176,11 +176,12 @@ static char global_heap_buf[10 * 1024 * 1024] = { 0 };
|
||||||
static char *
|
static char *
|
||||||
handle_module_path(const char *module_path)
|
handle_module_path(const char *module_path)
|
||||||
{
|
{
|
||||||
// next character after =
|
/* next character after = */
|
||||||
return (strchr(module_path, '=')) + 1;
|
return (strchr(module_path, '=')) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *module_search_path = ".";
|
static char *module_search_path = ".";
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
module_reader_callback(const char *module_name, uint8 **p_buffer,
|
module_reader_callback(const char *module_name, uint8 **p_buffer,
|
||||||
uint32 *p_size)
|
uint32 *p_size)
|
||||||
|
@ -237,8 +238,6 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Process options. */
|
/* Process options. */
|
||||||
// TODO: use a option name and option handler pair table to
|
|
||||||
// optimize
|
|
||||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||||
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
|
|
|
@ -99,7 +99,7 @@ static char global_heap_buf[164 * 1024] = { 0 };
|
||||||
static char *
|
static char *
|
||||||
handle_module_path(const char *module_path)
|
handle_module_path(const char *module_path)
|
||||||
{
|
{
|
||||||
// next character after =
|
/* next character after = */
|
||||||
return (strchr(module_path, '=')) + 1;
|
return (strchr(module_path, '=')) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +159,6 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Process options. */
|
/* Process options. */
|
||||||
// TODO: use a option name and option handler pair table to
|
|
||||||
// optimize
|
|
||||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||||
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
|
|
|
@ -236,8 +236,6 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Process options. */
|
/* Process options. */
|
||||||
// TODO: use a option name and option handler pair table to
|
|
||||||
// optimize
|
|
||||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||||
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
|
|
|
@ -5,55 +5,42 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The byte array buffer is the file content of a test wasm binary file,
|
* The byte array buffer is the file content of a test wasm binary file,
|
||||||
* which is compiled by emcc or clang toolchain from C source file of:
|
* which is compiled by wasi-sdk toolchain from C source file of:
|
||||||
* core/iwasm/app-samples/hello-world/main.c.
|
* product-mini/app-samples/hello-world/main.c.
|
||||||
*/
|
*/
|
||||||
unsigned char __aligned(4) wasm_test_file[] = { 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00,
|
unsigned char __aligned(4) wasm_test_file[] = {
|
||||||
0x00, 0x00, 0x0D, 0x06, 0x64, 0x79, 0x6C, 0x69, 0x6E, 0x6B, 0xC0, 0x80,
|
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60,
|
||||||
0x04, 0x04, 0x00, 0x00, 0x01, 0x13, 0x04, 0x60, 0x01, 0x7F, 0x00, 0x60,
|
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01,
|
||||||
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x00,
|
0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75,
|
||||||
0x00, 0x02, 0x58, 0x06, 0x03, 0x65, 0x6E, 0x76, 0x05, 0x5F, 0x66, 0x72,
|
0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C,
|
||||||
0x65, 0x65, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F, 0x6D, 0x61,
|
0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72,
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x5F,
|
0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66,
|
||||||
0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76,
|
0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01,
|
||||||
0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76,
|
0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x13, 0x03,
|
||||||
0x0D, 0x5F, 0x5F, 0x6D, 0x65, 0x6D, 0x6F, 0x72, 0x79, 0x5F, 0x62, 0x61,
|
0x7F, 0x01, 0x41, 0xC0, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0xBA, 0x08, 0x0B,
|
||||||
0x73, 0x65, 0x03, 0x7F, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x65,
|
0x7F, 0x00, 0x41, 0xC0, 0x28, 0x0B, 0x07, 0x2C, 0x04, 0x06, 0x6D, 0x65,
|
||||||
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x01, 0x03, 0x04, 0x03, 0x02, 0x03,
|
0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74,
|
||||||
0x03, 0x06, 0x10, 0x03, 0x7F, 0x01, 0x41, 0x00, 0x0B, 0x7F, 0x01, 0x41,
|
0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, 0x01, 0x0B, 0x5F, 0x5F, 0x68, 0x65,
|
||||||
0x00, 0x0B, 0x7F, 0x00, 0x41, 0x1B, 0x0B, 0x07, 0x33, 0x04, 0x12, 0x5F,
|
0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x02, 0x04, 0x6D, 0x61,
|
||||||
0x5F, 0x70, 0x6F, 0x73, 0x74, 0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E,
|
0x69, 0x6E, 0x00, 0x04, 0x0A, 0xB2, 0x01, 0x01, 0xAF, 0x01, 0x01, 0x03,
|
||||||
0x74, 0x69, 0x61, 0x74, 0x65, 0x00, 0x06, 0x05, 0x5F, 0x6D, 0x61, 0x69,
|
0x7F, 0x23, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02,
|
||||||
0x6E, 0x00, 0x04, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74, 0x53,
|
0x24, 0x80, 0x80, 0x80, 0x80, 0x00, 0x41, 0x9B, 0x88, 0x80, 0x80, 0x00,
|
||||||
0x65, 0x74, 0x73, 0x00, 0x05, 0x04, 0x5F, 0x73, 0x74, 0x72, 0x03, 0x03,
|
0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41,
|
||||||
0x0A, 0xBA, 0x01, 0x03, 0x9E, 0x01, 0x01, 0x01, 0x7F, 0x23, 0x01, 0x21,
|
0x80, 0x08, 0x10, 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00,
|
||||||
0x00, 0x23, 0x01, 0x41, 0x10, 0x6A, 0x24, 0x01, 0x20, 0x00, 0x41, 0x08,
|
0x41, 0xA8, 0x88, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00,
|
||||||
0x6A, 0x21, 0x02, 0x23, 0x00, 0x41, 0x1B, 0x6A, 0x10, 0x03, 0x1A, 0x41,
|
0x1A, 0x41, 0x7F, 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x80, 0x08, 0x10, 0x01, 0x21, 0x01, 0x20, 0x01, 0x04, 0x7F, 0x20, 0x00,
|
0x36, 0x02, 0x10, 0x41, 0x80, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41,
|
||||||
0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x20, 0x00, 0x10, 0x02, 0x1A,
|
0x10, 0x6A, 0x10, 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21,
|
||||||
0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x0D, 0x3A, 0x00, 0x00, 0x20, 0x01,
|
0x04, 0x20, 0x03, 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x88,
|
||||||
0x23, 0x00, 0x2C, 0x00, 0x0E, 0x3A, 0x00, 0x01, 0x20, 0x01, 0x23, 0x00,
|
0x80, 0x80, 0x00, 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00,
|
||||||
0x2C, 0x00, 0x0F, 0x3A, 0x00, 0x02, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00,
|
0x8D, 0x88, 0x80, 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03,
|
||||||
0x10, 0x3A, 0x00, 0x03, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x11, 0x3A,
|
0x36, 0x02, 0x00, 0x41, 0x93, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10,
|
||||||
0x00, 0x04, 0x20, 0x01, 0x23, 0x00, 0x2C, 0x00, 0x12, 0x3A, 0x00, 0x05,
|
0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x20, 0x01, 0x36, 0x02, 0x00, 0x23, 0x00, 0x41, 0x13, 0x6A,
|
0x80, 0x00, 0x0B, 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80,
|
||||||
0x20, 0x02, 0x10, 0x02, 0x1A, 0x20, 0x01, 0x10, 0x00, 0x20, 0x00, 0x24,
|
0x80, 0x00, 0x20, 0x04, 0x0B, 0x0B, 0x41, 0x01, 0x00, 0x41, 0x80, 0x08,
|
||||||
0x01, 0x41, 0x00, 0x05, 0x23, 0x00, 0x41, 0x28, 0x6A, 0x10, 0x03, 0x1A,
|
0x0B, 0x3A, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25,
|
||||||
0x20, 0x00, 0x24, 0x01, 0x41, 0x7F, 0x0B, 0x0B, 0x03, 0x00, 0x01, 0x0B,
|
0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66,
|
||||||
0x14, 0x00, 0x23, 0x00, 0x41, 0x40, 0x6B, 0x24, 0x01, 0x23, 0x01, 0x41,
|
0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77,
|
||||||
0x80, 0x80, 0x04, 0x6A, 0x24, 0x02, 0x10, 0x05, 0x0B, 0x0B, 0x3F, 0x01,
|
0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63,
|
||||||
0x00, 0x23, 0x00, 0x0B, 0x39, 0x62, 0x75, 0x66, 0x20, 0x70, 0x74, 0x72,
|
0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00
|
||||||
0x3A, 0x20, 0x25, 0x70, 0x0A, 0x00, 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00,
|
};
|
||||||
0x62, 0x75, 0x66, 0x3A, 0x20, 0x25, 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C,
|
|
||||||
0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C,
|
|
||||||
0x6C, 0x6F, 0x63, 0x20, 0x62, 0x75, 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C,
|
|
||||||
0x65, 0x64, 0x00, 0x50, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x01, 0x49, 0x07,
|
|
||||||
0x00, 0x05, 0x5F, 0x66, 0x72, 0x65, 0x65, 0x01, 0x07, 0x5F, 0x6D, 0x61,
|
|
||||||
0x6C, 0x6C, 0x6F, 0x63, 0x02, 0x07, 0x5F, 0x70, 0x72, 0x69, 0x6E, 0x74,
|
|
||||||
0x66, 0x03, 0x05, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x04, 0x05, 0x5F, 0x6D,
|
|
||||||
0x61, 0x69, 0x6E, 0x05, 0x0B, 0x72, 0x75, 0x6E, 0x50, 0x6F, 0x73, 0x74,
|
|
||||||
0x53, 0x65, 0x74, 0x73, 0x06, 0x12, 0x5F, 0x5F, 0x70, 0x6F, 0x73, 0x74,
|
|
||||||
0x5F, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74, 0x69, 0x61, 0x74, 0x65,
|
|
||||||
0x00, 0x20, 0x10, 0x73, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x4D, 0x61, 0x70,
|
|
||||||
0x70, 0x69, 0x6E, 0x67, 0x55, 0x52, 0x4C, 0x0E, 0x61, 0x2E, 0x6F, 0x75,
|
|
||||||
0x74, 0x2E, 0x77, 0x61, 0x73, 0x6D, 0x2E, 0x6D, 0x61, 0x70 };
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user