mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 09:25:20 +00:00
export_native_api.md: Partially revert "Relax the ground rule" (#1588)
And add some clarifications
This commit is contained in:
parent
826cf4f8e1
commit
e6c7125851
|
@ -189,12 +189,22 @@ void foo2(wasm_exec_env_t exec_env,
|
|||
|
||||
The runtime builder should ensure not broking the memory sandbox when exporting the native function to WASM.
|
||||
|
||||
A ground rule:
|
||||
|
||||
- Do the pointer address conversion in the native API if "$\*" is not used for the pointer in the function signature
|
||||
|
||||
A few recommendations:
|
||||
|
||||
- Never pass any structure/class object pointer to native (do data serialization instead)
|
||||
- Do the pointer address conversion in the native API if "$\*" is not used for the pointer in the function signature
|
||||
- Never pass a function pointer to the native
|
||||
|
||||
Note: while not recommended here, nothing prevents you from passing
|
||||
structure/function pointers as far as the native API is aware of
|
||||
and careful about the ABI used in the wasm module. For example,
|
||||
C function pointers are usually represented as table indexes which
|
||||
the native API can call with wasm_runtime_call_indirect() or similar.
|
||||
However, in this document, we don't recommend to implement your native
|
||||
API that way unless necessary because it needs extra carefulness.
|
||||
|
||||
|
||||
## Pass structured data or class object
|
||||
|
|
Loading…
Reference in New Issue
Block a user