wamr_sys

Function wasm_runtime_load

Source
pub unsafe extern "C" fn wasm_runtime_load(
    buf: *mut u8,
    size: u32,
    error_buf: *mut c_char,
    error_buf_size: u32,
) -> wasm_module_t
Expand description

Load a WASM module from a specified byte buffer. The byte buffer can be WASM binary data when interpreter or JIT is enabled, or AOT binary data when AOT is enabled. If it is AOT binary data, it must be 4-byte aligned.

Note: In case of AOT XIP modules, the runtime doesn’t make modifications to the buffer. (Except the “Known issues” mentioned in doc/xip.md.) Otherwise, the runtime can make modifications to the buffer for its internal purposes. Thus, in general, it isn’t safe to create multiple modules from a single buffer.

@param buf the byte buffer which contains the WASM/AOT binary data, note that the byte buffer must be writable since runtime may change its content for footprint and performance purpose, and it must be referenceable until wasm_runtime_unload is called @param size the size of the buffer @param error_buf output of the exception info @param error_buf_size the size of the exception string

@return return WASM module loaded, NULL if failed