Stream: wamr

Topic: Stack and heap size with wasm-c-api


view this post on Zulip Tyler Zhang (Jul 14 2021 at 14:20):

Hi, I've been using the wasm-c-api of WAMR so I can use wasm_func_call to obtain wasm_trap_t values which I can use to inspect the stack trace on crash. This means I've also had to use the wasm-c-api functions for creating the instance (since I need to pass a wasm_func_t to wasm_func_call, which I can obtain only from a wasm_extern_t which I obtain from wasm_instance_exports which requires a wasm_instance_t). wasm_instance_t needs to be constructed with wasm_instance_new, which doesn't take stack size and heap size parameters, unlike wasm_runtime_instantiate, and instead hardcodes them to 32 * 1024.

Is there a way to obtain a wasm_instance_t, but edit the stack and heap sizes? If there isn't, perhaps the wasm_engine_new_with_config API could be used to provide configuration like this.

view this post on Zulip Tyler Zhang (Jul 14 2021 at 14:39):

If there is no way to provide this configuration would it be okay if I raise a PR to add the wasm_config_t functions to add this functionality?

view this post on Zulip Wenyong Huang (Jul 28 2021 at 23:16):

@Tyler Zhang More missing wasm-c-api APIs were implemented with latest patch and the following new API was added:
wasm_instance_t* wasm_instance_new_with_args(
wasm_store_t, const wasm_module_t, const wasm_extern_t *const imports[],
own wasm_trap_t**, const uint32_t stack_size, const uint32_t heap_size
);
Could you please use it to create the module instance instead of wasm_instance_new? Thanks.


Last updated: Nov 22 2024 at 16:03 UTC