@@ -1623,41 +1623,45 @@ wasm_runtime_get_max_mem(uint32 max_memory_pages, uint32 module_init_page_count,
16231623WASMModuleInstanceCommon *
16241624wasm_runtime_instantiate_internal (WASMModuleCommon * module ,
16251625 WASMModuleInstanceCommon * parent ,
1626- WASMExecEnv * exec_env_main , uint32 stack_size ,
1627- uint32 heap_size , uint32 max_memory_pages ,
1626+ WASMExecEnv * exec_env_main ,
1627+ const struct InstantiationArgs2 * args ,
16281628 char * error_buf , uint32 error_buf_size )
16291629{
16301630#if WASM_ENABLE_INTERP != 0
16311631 if (module -> module_type == Wasm_Module_Bytecode )
16321632 return (WASMModuleInstanceCommon * )wasm_instantiate (
16331633 (WASMModule * )module , (WASMModuleInstance * )parent , exec_env_main ,
1634- stack_size , heap_size , max_memory_pages , error_buf , error_buf_size );
1634+ args , error_buf , error_buf_size );
16351635#endif
16361636#if WASM_ENABLE_AOT != 0
16371637 if (module -> module_type == Wasm_Module_AoT )
16381638 return (WASMModuleInstanceCommon * )aot_instantiate (
16391639 (AOTModule * )module , (AOTModuleInstance * )parent , exec_env_main ,
1640- stack_size , heap_size , max_memory_pages , error_buf , error_buf_size );
1640+ args , error_buf , error_buf_size );
16411641#endif
16421642 set_error_buf (error_buf , error_buf_size ,
16431643 "Instantiate module failed, invalid module type" );
16441644 return NULL ;
16451645}
16461646
1647+ void
1648+ wasm_runtime_instantiation_args_set_defaults (struct InstantiationArgs2 * args )
1649+ {
1650+ memset (args , 0 , sizeof (* args ));
1651+ }
1652+
16471653WASMModuleInstanceCommon *
16481654wasm_runtime_instantiate (WASMModuleCommon * module , uint32 stack_size ,
16491655 uint32 heap_size , char * error_buf ,
16501656 uint32 error_buf_size )
16511657{
1652- return wasm_runtime_instantiate_internal (module , NULL , NULL , stack_size ,
1653- heap_size , 0 , error_buf ,
1654- error_buf_size );
1655- }
1656-
1657- static void
1658- instantiation_args_set_defaults (struct InstantiationArgs2 * args )
1659- {
1660- memset (args , 0 , sizeof (* args ));
1658+ struct InstantiationArgs2 args ;
1659+ wasm_runtime_instantiation_args_set_defaults (& args );
1660+ wasm_runtime_instantiation_args_set_default_stack_size (& args , stack_size );
1661+ wasm_runtime_instantiation_args_set_host_managed_heap_size (& args ,
1662+ heap_size );
1663+ return wasm_runtime_instantiate_internal (module , NULL , NULL , & args ,
1664+ error_buf , error_buf_size );
16611665}
16621666
16631667WASMModuleInstanceCommon *
@@ -1666,7 +1670,7 @@ wasm_runtime_instantiate_ex(WASMModuleCommon *module,
16661670 uint32 error_buf_size )
16671671{
16681672 struct InstantiationArgs2 v2 ;
1669- instantiation_args_set_defaults (& v2 );
1673+ wasm_runtime_instantiation_args_set_defaults (& v2 );
16701674 v2 .v1 = * args ;
16711675 return wasm_runtime_instantiate_ex2 (module , & v2 , error_buf , error_buf_size );
16721676}
@@ -1678,7 +1682,7 @@ wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p)
16781682 if (args == NULL ) {
16791683 return false;
16801684 }
1681- instantiation_args_set_defaults (args );
1685+ wasm_runtime_instantiation_args_set_defaults (args );
16821686 * p = args ;
16831687 return true;
16841688}
@@ -1715,10 +1719,8 @@ wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
17151719 const struct InstantiationArgs2 * args ,
17161720 char * error_buf , uint32 error_buf_size )
17171721{
1718- return wasm_runtime_instantiate_internal (
1719- module , NULL , NULL , args -> v1 .default_stack_size ,
1720- args -> v1 .host_managed_heap_size , args -> v1 .max_memory_pages , error_buf ,
1721- error_buf_size );
1722+ return wasm_runtime_instantiate_internal (module , NULL , NULL , args ,
1723+ error_buf , error_buf_size );
17221724}
17231725
17241726void
@@ -7666,9 +7668,8 @@ wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module,
76667668bool
76677669wasm_runtime_sub_module_instantiate (WASMModuleCommon * module ,
76687670 WASMModuleInstanceCommon * module_inst ,
7669- uint32 stack_size , uint32 heap_size ,
7670- uint32 max_memory_pages , char * error_buf ,
7671- uint32 error_buf_size )
7671+ const struct InstantiationArgs2 * args ,
7672+ char * error_buf , uint32 error_buf_size )
76727673{
76737674 bh_list * sub_module_inst_list = NULL ;
76747675 WASMRegisteredModule * sub_module_list_node = NULL ;
@@ -7696,8 +7697,7 @@ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
76967697 WASMModuleCommon * sub_module = sub_module_list_node -> module ;
76977698 WASMModuleInstanceCommon * sub_module_inst = NULL ;
76987699 sub_module_inst = wasm_runtime_instantiate_internal (
7699- sub_module , NULL , NULL , stack_size , heap_size , max_memory_pages ,
7700- error_buf , error_buf_size );
7700+ sub_module , NULL , NULL , args , error_buf , error_buf_size );
77017701 if (!sub_module_inst ) {
77027702 LOG_DEBUG ("instantiate %s failed" ,
77037703 sub_module_list_node -> module_name );
0 commit comments