Add a Module::deserialize_file method (#3266)
* Add a `Module::deserialize_file` method This commit adds a new method to the `wasmtime::Module` type, `deserialize_file`. This is intended to be the same as the `deserialize` method except for the serialized module is present as an on-disk file. This enables Wasmtime to internally use `mmap` to avoid copying bytes around and generally makes loading a module much faster. A C API is added in this commit as well for various bindings to use this accelerated path now as well. Another option perhaps for a Rust-based API is to have an API taking a `File` itself to allow for a custom file descriptor in one way or another, but for now that's left for a possible future refactoring if we find a use case. * Fix compat with main - handle readdonly mmap * wip * Try to fix Windows support
This commit is contained in:
@@ -165,6 +165,26 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_deserialize(
|
||||
wasmtime_module_t **ret
|
||||
);
|
||||
|
||||
/**
|
||||
* \brief Deserialize a module from an on-disk file.
|
||||
*
|
||||
* This function is the same as #wasmtime_module_deserialize except that it
|
||||
* reads the data for the serialized module from the path on disk. This can be
|
||||
* faster than the alternative which may require copying the data around.
|
||||
*
|
||||
* This function does not take ownership of any of its arguments, but the
|
||||
* returned error and module are owned by the caller.
|
||||
*
|
||||
* This function is not safe to receive arbitrary user input. See the Rust
|
||||
* documentation for more information on what inputs are safe to pass in here
|
||||
* (e.g. only that of #wasmtime_module_serialize)
|
||||
*/
|
||||
WASM_API_EXTERN wasmtime_error_t *wasmtime_module_deserialize_file(
|
||||
wasm_engine_t *engine,
|
||||
const char *path,
|
||||
wasmtime_module_t **ret
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user