mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 09:25:20 +00:00
fix exec_env not checked issue, export __heap_base and __data_end in sample to decrease memory usage (#371)
This commit is contained in:
parent
c8df3f6eed
commit
2e0cef3ef1
|
@ -84,16 +84,17 @@ WASMExecEnv *
|
|||
wasm_exec_env_create(struct WASMModuleInstanceCommon *module_inst,
|
||||
uint32 stack_size)
|
||||
{
|
||||
WASMExecEnv *exec_env = wasm_exec_env_create_internal(module_inst,
|
||||
stack_size);
|
||||
WASMExecEnv *exec_env =
|
||||
wasm_exec_env_create_internal(module_inst, stack_size);
|
||||
|
||||
if (!exec_env)
|
||||
return NULL;
|
||||
|
||||
/* Set the aux_stack_boundary to 0 */
|
||||
exec_env->aux_stack_boundary = 0;
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
WASMCluster *cluster;
|
||||
|
||||
if (!exec_env)
|
||||
return NULL;
|
||||
|
||||
/* Create a new cluster for this exec_env */
|
||||
cluster = wasm_cluster_create(exec_env);
|
||||
if (!cluster) {
|
||||
|
|
|
@ -335,14 +335,14 @@ wasm_native_init()
|
|||
#if WASM_ENABLE_LIBC_BUILTIN != 0
|
||||
n_native_symbols = get_libc_builtin_export_apis(&native_symbols);
|
||||
if (!wasm_native_register_natives("env",
|
||||
native_symbols, n_native_symbols))
|
||||
native_symbols, n_native_symbols))
|
||||
return false;
|
||||
#endif /* WASM_ENABLE_LIBC_BUILTIN */
|
||||
|
||||
#if WASM_ENABLE_SPEC_TEST
|
||||
n_native_symbols = get_spectest_export_apis(&native_symbols);
|
||||
if (!wasm_native_register_natives("spectest",
|
||||
native_symbols, n_native_symbols))
|
||||
native_symbols, n_native_symbols))
|
||||
return false;
|
||||
#endif /* WASM_ENABLE_SPEC_TEST */
|
||||
|
||||
|
|
|
@ -1365,14 +1365,6 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
wasi_ctx->curfds_offset = offset_curfds;
|
||||
wasi_ctx->prestats_offset = offset_prestats;
|
||||
wasi_ctx->argv_environ_offset = offset_argv_environ;
|
||||
wasi_ctx->argv_buf_offset = offset_argv_buf;
|
||||
wasi_ctx->argv_offsets_offset = offset_argv_offsets;
|
||||
wasi_ctx->env_buf_offset = offset_env_buf;
|
||||
wasi_ctx->env_offsets_offset = offset_env_offsets;
|
||||
|
||||
if (!fd_table_init(curfds)) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"Init wasi environment failed: "
|
||||
|
@ -1434,6 +1426,14 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|||
fd_prestats_insert(prestats, dir_list[i], wasm_fd);
|
||||
}
|
||||
|
||||
wasi_ctx->curfds_offset = offset_curfds;
|
||||
wasi_ctx->prestats_offset = offset_prestats;
|
||||
wasi_ctx->argv_environ_offset = offset_argv_environ;
|
||||
wasi_ctx->argv_buf_offset = offset_argv_buf;
|
||||
wasi_ctx->argv_offsets_offset = offset_argv_offsets;
|
||||
wasi_ctx->env_buf_offset = offset_env_buf;
|
||||
wasi_ctx->env_offsets_offset = offset_env_offsets;
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
|
|
|
@ -153,6 +153,7 @@ OUT_FILE=${i%.*}.wasm
|
|||
-Wl,--export=on_request -Wl,--export=on_response \
|
||||
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_connection_data \
|
||||
-Wl,--export=__heap_base -Wl,--export=__data_end \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
||||
echo "build ${OUT_FILE} success"
|
||||
|
|
Loading…
Reference in New Issue
Block a user