Expose wasm_runtime_call_indirect (#1969)
The function has been there for long. While what it does look a bit unsafe as it calls a function which may be not wasm-wise exported explicitly, it's useful and widely used when implementing callback-taking APIs, including our pthread_create's implementation.
This commit is contained in:
@ -800,6 +800,31 @@ wasm_runtime_call_wasm_v(wasm_exec_env_t exec_env,
|
||||
uint32_t num_results, wasm_val_t results[],
|
||||
uint32_t num_args, ...);
|
||||
|
||||
/**
|
||||
* Call a function reference of a given WASM runtime instance with
|
||||
* arguments.
|
||||
*
|
||||
* Note: this can be used to call a function which is not exported
|
||||
* by the module explicitly. You might consider it as an abstraction
|
||||
* violation.
|
||||
*
|
||||
* @param exec_env the execution environment to call the function
|
||||
* which must be created from wasm_create_exec_env()
|
||||
* @param element_index the function reference index, usually
|
||||
* prvovided by the caller of a registed native function
|
||||
* @param argc the number of arguments
|
||||
* @param argv the arguments. If the function method has return value,
|
||||
* the first (or first two in case 64-bit return value) element of
|
||||
* argv stores the return value of the called WASM function after this
|
||||
* function returns.
|
||||
*
|
||||
* @return true if success, false otherwise and exception will be thrown,
|
||||
* the caller can call wasm_runtime_get_exception to get exception info.
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
wasm_runtime_call_indirect(wasm_exec_env_t exec_env, uint32_t element_index,
|
||||
uint32_t argc, uint32_t argv[]);
|
||||
|
||||
/**
|
||||
* Find the unique main function from a WASM module instance
|
||||
* and execute that function.
|
||||
|
||||
Reference in New Issue
Block a user