|
@@ -1623,41 +1623,45 @@ wasm_runtime_get_max_mem(uint32 max_memory_pages, uint32 module_init_page_count,
|
|
|
WASMModuleInstanceCommon *
|
|
WASMModuleInstanceCommon *
|
|
|
wasm_runtime_instantiate_internal(WASMModuleCommon *module,
|
|
wasm_runtime_instantiate_internal(WASMModuleCommon *module,
|
|
|
WASMModuleInstanceCommon *parent,
|
|
WASMModuleInstanceCommon *parent,
|
|
|
- WASMExecEnv *exec_env_main, uint32 stack_size,
|
|
|
|
|
- uint32 heap_size, uint32 max_memory_pages,
|
|
|
|
|
|
|
+ WASMExecEnv *exec_env_main,
|
|
|
|
|
+ const struct InstantiationArgs2 *args,
|
|
|
char *error_buf, uint32 error_buf_size)
|
|
char *error_buf, uint32 error_buf_size)
|
|
|
{
|
|
{
|
|
|
#if WASM_ENABLE_INTERP != 0
|
|
#if WASM_ENABLE_INTERP != 0
|
|
|
if (module->module_type == Wasm_Module_Bytecode)
|
|
if (module->module_type == Wasm_Module_Bytecode)
|
|
|
return (WASMModuleInstanceCommon *)wasm_instantiate(
|
|
return (WASMModuleInstanceCommon *)wasm_instantiate(
|
|
|
(WASMModule *)module, (WASMModuleInstance *)parent, exec_env_main,
|
|
(WASMModule *)module, (WASMModuleInstance *)parent, exec_env_main,
|
|
|
- stack_size, heap_size, max_memory_pages, error_buf, error_buf_size);
|
|
|
|
|
|
|
+ args, error_buf, error_buf_size);
|
|
|
#endif
|
|
#endif
|
|
|
#if WASM_ENABLE_AOT != 0
|
|
#if WASM_ENABLE_AOT != 0
|
|
|
if (module->module_type == Wasm_Module_AoT)
|
|
if (module->module_type == Wasm_Module_AoT)
|
|
|
return (WASMModuleInstanceCommon *)aot_instantiate(
|
|
return (WASMModuleInstanceCommon *)aot_instantiate(
|
|
|
(AOTModule *)module, (AOTModuleInstance *)parent, exec_env_main,
|
|
(AOTModule *)module, (AOTModuleInstance *)parent, exec_env_main,
|
|
|
- stack_size, heap_size, max_memory_pages, error_buf, error_buf_size);
|
|
|
|
|
|
|
+ args, error_buf, error_buf_size);
|
|
|
#endif
|
|
#endif
|
|
|
set_error_buf(error_buf, error_buf_size,
|
|
set_error_buf(error_buf, error_buf_size,
|
|
|
"Instantiate module failed, invalid module type");
|
|
"Instantiate module failed, invalid module type");
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_instantiation_args_set_defaults(struct InstantiationArgs2 *args)
|
|
|
|
|
+{
|
|
|
|
|
+ memset(args, 0, sizeof(*args));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
WASMModuleInstanceCommon *
|
|
WASMModuleInstanceCommon *
|
|
|
wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size,
|
|
wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size,
|
|
|
uint32 heap_size, char *error_buf,
|
|
uint32 heap_size, char *error_buf,
|
|
|
uint32 error_buf_size)
|
|
uint32 error_buf_size)
|
|
|
{
|
|
{
|
|
|
- return wasm_runtime_instantiate_internal(module, NULL, NULL, stack_size,
|
|
|
|
|
- heap_size, 0, error_buf,
|
|
|
|
|
- error_buf_size);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void
|
|
|
|
|
-instantiation_args_set_defaults(struct InstantiationArgs2 *args)
|
|
|
|
|
-{
|
|
|
|
|
- memset(args, 0, sizeof(*args));
|
|
|
|
|
|
|
+ struct InstantiationArgs2 args;
|
|
|
|
|
+ wasm_runtime_instantiation_args_set_defaults(&args);
|
|
|
|
|
+ wasm_runtime_instantiation_args_set_default_stack_size(&args, stack_size);
|
|
|
|
|
+ wasm_runtime_instantiation_args_set_host_managed_heap_size(&args,
|
|
|
|
|
+ heap_size);
|
|
|
|
|
+ return wasm_runtime_instantiate_internal(module, NULL, NULL, &args,
|
|
|
|
|
+ error_buf, error_buf_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WASMModuleInstanceCommon *
|
|
WASMModuleInstanceCommon *
|
|
@@ -1666,7 +1670,7 @@ wasm_runtime_instantiate_ex(WASMModuleCommon *module,
|
|
|
uint32 error_buf_size)
|
|
uint32 error_buf_size)
|
|
|
{
|
|
{
|
|
|
struct InstantiationArgs2 v2;
|
|
struct InstantiationArgs2 v2;
|
|
|
- instantiation_args_set_defaults(&v2);
|
|
|
|
|
|
|
+ wasm_runtime_instantiation_args_set_defaults(&v2);
|
|
|
v2.v1 = *args;
|
|
v2.v1 = *args;
|
|
|
return wasm_runtime_instantiate_ex2(module, &v2, error_buf, error_buf_size);
|
|
return wasm_runtime_instantiate_ex2(module, &v2, error_buf, error_buf_size);
|
|
|
}
|
|
}
|
|
@@ -1678,7 +1682,7 @@ wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p)
|
|
|
if (args == NULL) {
|
|
if (args == NULL) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- instantiation_args_set_defaults(args);
|
|
|
|
|
|
|
+ wasm_runtime_instantiation_args_set_defaults(args);
|
|
|
*p = args;
|
|
*p = args;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -1715,10 +1719,8 @@ wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
|
|
|
const struct InstantiationArgs2 *args,
|
|
const struct InstantiationArgs2 *args,
|
|
|
char *error_buf, uint32 error_buf_size)
|
|
char *error_buf, uint32 error_buf_size)
|
|
|
{
|
|
{
|
|
|
- return wasm_runtime_instantiate_internal(
|
|
|
|
|
- module, NULL, NULL, args->v1.default_stack_size,
|
|
|
|
|
- args->v1.host_managed_heap_size, args->v1.max_memory_pages, error_buf,
|
|
|
|
|
- error_buf_size);
|
|
|
|
|
|
|
+ return wasm_runtime_instantiate_internal(module, NULL, NULL, args,
|
|
|
|
|
+ error_buf, error_buf_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void
|
|
void
|
|
@@ -7666,9 +7668,8 @@ delete_loading_module:
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
|
|
wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
|
|
|
WASMModuleInstanceCommon *module_inst,
|
|
WASMModuleInstanceCommon *module_inst,
|
|
|
- uint32 stack_size, uint32 heap_size,
|
|
|
|
|
- uint32 max_memory_pages, char *error_buf,
|
|
|
|
|
- uint32 error_buf_size)
|
|
|
|
|
|
|
+ const struct InstantiationArgs2 *args,
|
|
|
|
|
+ char *error_buf, uint32 error_buf_size)
|
|
|
{
|
|
{
|
|
|
bh_list *sub_module_inst_list = NULL;
|
|
bh_list *sub_module_inst_list = NULL;
|
|
|
WASMRegisteredModule *sub_module_list_node = NULL;
|
|
WASMRegisteredModule *sub_module_list_node = NULL;
|
|
@@ -7696,8 +7697,7 @@ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
|
|
|
WASMModuleCommon *sub_module = sub_module_list_node->module;
|
|
WASMModuleCommon *sub_module = sub_module_list_node->module;
|
|
|
WASMModuleInstanceCommon *sub_module_inst = NULL;
|
|
WASMModuleInstanceCommon *sub_module_inst = NULL;
|
|
|
sub_module_inst = wasm_runtime_instantiate_internal(
|
|
sub_module_inst = wasm_runtime_instantiate_internal(
|
|
|
- sub_module, NULL, NULL, stack_size, heap_size, max_memory_pages,
|
|
|
|
|
- error_buf, error_buf_size);
|
|
|
|
|
|
|
+ sub_module, NULL, NULL, args, error_buf, error_buf_size);
|
|
|
if (!sub_module_inst) {
|
|
if (!sub_module_inst) {
|
|
|
LOG_DEBUG("instantiate %s failed",
|
|
LOG_DEBUG("instantiate %s failed",
|
|
|
sub_module_list_node->module_name);
|
|
sub_module_list_node->module_name);
|