@@ -262,6 +262,7 @@ iwasm(int argc, char **argv)
262262 wasm_module_t wasm_module = NULL ;
263263 wasm_module_inst_t wasm_module_inst = NULL ;
264264 RuntimeInitArgs init_args ;
265+ struct InstantiationArgs2 * inst_args ;
265266 static char error_buf [128 ] = { 0 };
266267 /* avoid stack overflow */
267268#if WASM_ENABLE_LIBC_WASI != 0
@@ -369,13 +370,23 @@ iwasm(int argc, char **argv)
369370 rt_kprintf ("%s\n" , error_buf );
370371 goto fail2 ;
371372 }
373+
374+ if (!wasm_runtime_instantiation_args_create (& inst_args )) {
375+ rt_kprintf ("failed to create instantiate args\n" );
376+ goto fail3 ;
377+ }
378+ wasm_runtime_instantiation_args_set_default_stack_size (inst_args ,
379+ stack_size );
380+ wasm_runtime_instantiation_args_set_host_managed_heap_size (inst_args ,
381+ heap_size );
372382#if WASM_ENABLE_LIBC_WASI != 0
373383 libc_wasi_init (wasm_module , argc , argv , & wasi_parse_ctx );
374384#endif
375385
376386 rt_memset (error_buf , 0x00 , sizeof (error_buf ));
377- wasm_module_inst = wasm_runtime_instantiate (
378- wasm_module , stack_size , heap_size , error_buf , sizeof (error_buf ));
387+ wasm_module_inst = wasm_runtime_instantiate_ex2 (
388+ wasm_module , inst_args , error_buf , sizeof (error_buf ));
389+ wasm_runtime_instantiation_args_destroy (inst_args );
379390 if (!wasm_module_inst ) {
380391 rt_kprintf ("%s\n" , error_buf );
381392 goto fail3 ;
0 commit comments