introduce wasm_runtime_instantiate_ex2 (#4444)
* introduce wasm_runtime_instantiate_ex2 at this point, just a slightly inefficiant functionality equivalent of wasm_runtime_instantiate_ex. however, unlike wasm_runtime_instantiate_ex, this one is designed to be extendable without breaking the user-visible ABI. because the definition of InstantiationArgs2 is not exposed to users, we can safely add new members to it. this commit also makes wasm_runtime_instantiate_ex a wrapper of wasm_runtime_instantiate_ex2. if this goes well, maybe it's a good idea to apply a similar pattern to RuntimeInitArgs, LoadArgs, SharedHeapInitArgs, etc. i started with InstantiationArgs just because i happen to have a need to extend it for wasi-nn. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4364 https://github.com/bytecodealliance/wasm-micro-runtime/issues/4331 * product-mini/platforms/posix: use wasm_runtime_instantiate_ex2
This commit is contained in:
@ -289,6 +289,8 @@ typedef struct InstantiationArgs {
|
||||
} InstantiationArgs;
|
||||
#endif /* INSTANTIATION_ARGS_OPTION_DEFINED */
|
||||
|
||||
struct InstantiationArgs2;
|
||||
|
||||
#ifndef WASM_VALKIND_T_DEFINED
|
||||
#define WASM_VALKIND_T_DEFINED
|
||||
typedef uint8_t wasm_valkind_t;
|
||||
@ -733,6 +735,46 @@ wasm_runtime_instantiate_ex(const wasm_module_t module,
|
||||
const InstantiationArgs *args, char *error_buf,
|
||||
uint32_t error_buf_size);
|
||||
|
||||
/**
|
||||
* Create an InstantiationArgs2 object with default parameters.
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
|
||||
|
||||
/**
|
||||
* Dispose an InstantiationArgs2 object.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
|
||||
|
||||
/**
|
||||
* Setter functions for the InstantiationArgs2 object.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_default_stack_size(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_host_managed_heap_size(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_instantiation_args_set_max_memory_pages(
|
||||
struct InstantiationArgs2 *p, uint32_t v);
|
||||
|
||||
/**
|
||||
* Instantiate a WASM module, with specified instantiation arguments
|
||||
*
|
||||
* Same as wasm_runtime_instantiate_ex, but this version takes
|
||||
* InstantiationArgs2, which can be extended without breaking the ABI.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
|
||||
wasm_runtime_instantiate_ex2(const wasm_module_t module,
|
||||
const struct InstantiationArgs2 *args,
|
||||
char *error_buf, uint32_t error_buf_size);
|
||||
|
||||
/**
|
||||
* Set the running mode of a WASM module instance, override the
|
||||
* default running mode of the runtime. Note that it only makes sense when
|
||||
|
||||
Reference in New Issue
Block a user