wasi configurations in wasm_module_t
wasm_runtime_set_wasi_args / wasm_runtime_set_wasi_args_ex sets wasi configurations on wasm_module_t.
it isn't intuitive because those configuartions logically belong to wasm_module_inst_t.
ideally it would be nice to allow to instantiate multiple wasm_module_inst_t from a single wasm_module_t.
one way to fix it is to make them a part of InstantiationArgs.
it's unfortunate InstantiationArgs is defined in a way which can't be extended without breaking the ABI.
(i thought i filed this issue long time ago. but i couldn't find it. sorry if it's duplicated.)
You are right. The current design doesn't accommodate usage scenarios like varying WASI contexts for multiple instances (either continuously in one thread or parallelly across multiple threads) of a module.
I prefer to add a new API like wasm_runtime_instantiate_with_wasi(wasm_module_t, InstantiationArgs*, WasiConfigArgs*, char*, uint32_t) and a new set of helpers for building WasiConfigArgs.
#4256
oh, was it this May? i thought it was at least a few years ago. it seems my memory is severely broken.
You are right. The current design doesn't accommodate usage scenarios like varying WASI contexts for multiple instances (either continuously in one thread or parallelly across multiple threads) of a module.
I prefer to add a new API like
wasm_runtime_instantiate_with_wasi(wasm_module_t, InstantiationArgs*, WasiConfigArgs*, char*, uint32_t)and a new set of helpers for buildingWasiConfigArgs.
how about:
struct InstantiationArgs2;
bool
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
void
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
void
wasm_runtime_instantiation_args_set_default_stack_size(
struct InstantiationArgs2 *p, uint32 v);
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);
this way we can add wasm_runtime_instantiation_args_set_xxx without breaking api/abi.
Looks good to me. Let's see how it goes.