Skip to content

Commit b06ae72

Browse files
authored
Remove heap size check when creating wasi ctx (#565)
Remove check for heap_size==0 when creating wasi ctx, as the related data structures are allocated from global heap instead of app heap now, so it also works when app heap isn't created. Also add v128 type for Windows so as to fix wamrc compilation error in Windows platform. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
1 parent 9327f20 commit b06ae72

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

core/iwasm/aot/aot_runtime.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -879,17 +879,16 @@ aot_instantiate(AOTModule *module, bool is_sub_inst,
879879

880880
#if WASM_ENABLE_LIBC_WASI != 0
881881
if (!is_sub_inst) {
882-
if (heap_size > 0
883-
&& !wasm_runtime_init_wasi((WASMModuleInstanceCommon*)module_inst,
884-
module->wasi_args.dir_list,
885-
module->wasi_args.dir_count,
886-
module->wasi_args.map_dir_list,
887-
module->wasi_args.map_dir_count,
888-
module->wasi_args.env,
889-
module->wasi_args.env_count,
890-
module->wasi_args.argv,
891-
module->wasi_args.argc,
892-
error_buf, error_buf_size))
882+
if (!wasm_runtime_init_wasi((WASMModuleInstanceCommon*)module_inst,
883+
module->wasi_args.dir_list,
884+
module->wasi_args.dir_count,
885+
module->wasi_args.map_dir_list,
886+
module->wasi_args.map_dir_count,
887+
module->wasi_args.env,
888+
module->wasi_args.env_count,
889+
module->wasi_args.argv,
890+
module->wasi_args.argc,
891+
error_buf, error_buf_size))
893892
goto fail;
894893
}
895894
#endif

core/iwasm/common/wasm_runtime_common.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,8 +3400,21 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
34003400
#undef v128
34013401
#endif
34023402

3403+
#if defined(_WIN32) || defined(_WIN32_)
3404+
typedef union __declspec(intrin_type) __declspec(align(1)) v128 {
3405+
__int8 m128i_i8[16];
3406+
__int16 m128i_i16[8];
3407+
__int32 m128i_i32[4];
3408+
__int64 m128i_i64[2];
3409+
unsigned __int8 m128i_u8[16];
3410+
unsigned __int16 m128i_u16[8];
3411+
unsigned __int32 m128i_u32[4];
3412+
unsigned __int64 m128i_u64[2];
3413+
} v128;
3414+
#else
34033415
typedef long long v128 __attribute__ ((__vector_size__ (16),
34043416
__may_alias__, __aligned__ (1)));
3417+
#endif /* end of defined(_WIN32) || defined(_WIN32_) */
34053418

34063419
#endif /* end of WASM_ENABLE_SIMD != 0 */
34073420

core/iwasm/include/wasm_export.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ wasm_runtime_set_wasi_args(wasm_module_t module,
333333
* specified here is ignored.
334334
* @param heap_size the default heap size of the module instance, a heap will
335335
* be created besides the app memory space. Both wasm app and native
336-
* function can allocate memory from the heap. If heap_size is 0, the
337-
* default heap size will be used.
336+
* function can allocate memory from the heap.
338337
* @param error_buf buffer to output the error info if failed
339338
* @param error_buf_size the size of the error buffer
340339
*

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,17 +1411,16 @@ wasm_instantiate(WASMModule *module, bool is_sub_inst,
14111411
#if WASM_ENABLE_LIBC_WASI != 0
14121412
/* The sub-instance will get the wasi_ctx from main-instance */
14131413
if (!is_sub_inst) {
1414-
if (heap_size > 0
1415-
&& !wasm_runtime_init_wasi((WASMModuleInstanceCommon*)module_inst,
1416-
module->wasi_args.dir_list,
1417-
module->wasi_args.dir_count,
1418-
module->wasi_args.map_dir_list,
1419-
module->wasi_args.map_dir_count,
1420-
module->wasi_args.env,
1421-
module->wasi_args.env_count,
1422-
module->wasi_args.argv,
1423-
module->wasi_args.argc,
1424-
error_buf, error_buf_size)) {
1414+
if (!wasm_runtime_init_wasi((WASMModuleInstanceCommon*)module_inst,
1415+
module->wasi_args.dir_list,
1416+
module->wasi_args.dir_count,
1417+
module->wasi_args.map_dir_list,
1418+
module->wasi_args.map_dir_count,
1419+
module->wasi_args.env,
1420+
module->wasi_args.env_count,
1421+
module->wasi_args.argv,
1422+
module->wasi_args.argc,
1423+
error_buf, error_buf_size)) {
14251424
goto fail;
14261425
}
14271426
}

0 commit comments

Comments
 (0)