@@ -1623,41 +1623,45 @@ wasm_runtime_get_max_mem(uint32 max_memory_pages, uint32 module_init_page_count,
1623
1623
WASMModuleInstanceCommon *
1624
1624
wasm_runtime_instantiate_internal (WASMModuleCommon * module ,
1625
1625
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 ,
1628
1628
char * error_buf , uint32 error_buf_size )
1629
1629
{
1630
1630
#if WASM_ENABLE_INTERP != 0
1631
1631
if (module -> module_type == Wasm_Module_Bytecode )
1632
1632
return (WASMModuleInstanceCommon * )wasm_instantiate (
1633
1633
(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 );
1635
1635
#endif
1636
1636
#if WASM_ENABLE_AOT != 0
1637
1637
if (module -> module_type == Wasm_Module_AoT )
1638
1638
return (WASMModuleInstanceCommon * )aot_instantiate (
1639
1639
(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 );
1641
1641
#endif
1642
1642
set_error_buf (error_buf , error_buf_size ,
1643
1643
"Instantiate module failed, invalid module type" );
1644
1644
return NULL ;
1645
1645
}
1646
1646
1647
+ static void
1648
+ instantiation_args_set_defaults (struct InstantiationArgs2 * args )
1649
+ {
1650
+ memset (args , 0 , sizeof (* args ));
1651
+ }
1652
+
1647
1653
WASMModuleInstanceCommon *
1648
1654
wasm_runtime_instantiate (WASMModuleCommon * module , uint32 stack_size ,
1649
1655
uint32 heap_size , char * error_buf ,
1650
1656
uint32 error_buf_size )
1651
1657
{
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
+ 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 );
1661
1665
}
1662
1666
1663
1667
WASMModuleInstanceCommon *
@@ -1715,10 +1719,8 @@ wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
1715
1719
const struct InstantiationArgs2 * args ,
1716
1720
char * error_buf , uint32 error_buf_size )
1717
1721
{
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 );
1722
1724
}
1723
1725
1724
1726
void
@@ -7651,9 +7653,8 @@ wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module,
7651
7653
bool
7652
7654
wasm_runtime_sub_module_instantiate (WASMModuleCommon * module ,
7653
7655
WASMModuleInstanceCommon * module_inst ,
7654
- uint32 stack_size , uint32 heap_size ,
7655
- uint32 max_memory_pages , char * error_buf ,
7656
- uint32 error_buf_size )
7656
+ const struct InstantiationArgs2 * args ,
7657
+ char * error_buf , uint32 error_buf_size )
7657
7658
{
7658
7659
bh_list * sub_module_inst_list = NULL ;
7659
7660
WASMRegisteredModule * sub_module_list_node = NULL ;
@@ -7681,8 +7682,7 @@ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
7681
7682
WASMModuleCommon * sub_module = sub_module_list_node -> module ;
7682
7683
WASMModuleInstanceCommon * sub_module_inst = NULL ;
7683
7684
sub_module_inst = wasm_runtime_instantiate_internal (
7684
- sub_module , NULL , NULL , stack_size , heap_size , max_memory_pages ,
7685
- error_buf , error_buf_size );
7685
+ sub_module , NULL , NULL , args , error_buf , error_buf_size );
7686
7686
if (!sub_module_inst ) {
7687
7687
LOG_DEBUG ("instantiate %s failed" ,
7688
7688
sub_module_list_node -> module_name );
0 commit comments