Browse Source
c-api: Expose image_range for modules (#7064)
We're using this to monitor the amount of executable memory each module
needs.
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
pull/7069/head
Tyler Rockwood
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
26 additions and
0 deletions
-
crates/c-api/include/wasmtime/module.h
-
crates/c-api/src/module.rs
|
|
@ -148,6 +148,21 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_deserialize_file( |
|
|
|
wasmtime_module_t **ret |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Returns the range of bytes in memory where this module’s compilation image resides. |
|
|
|
* |
|
|
|
* The compilation image for a module contains executable code, data, debug information, etc. |
|
|
|
* This is roughly the same as the wasmtime_module_serialize but not the exact same. |
|
|
|
* |
|
|
|
* For more details see: https://docs.wasmtime.dev/api/wasmtime/struct.Module.html#method.image_range
|
|
|
|
*/ |
|
|
|
WASM_API_EXTERN void wasmtime_module_image_range( |
|
|
|
const wasm_module_t *module, |
|
|
|
size_t *start, |
|
|
|
size_t *end |
|
|
|
); |
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
} // extern "C"
|
|
|
|
#endif |
|
|
|
|
|
@ -183,6 +183,17 @@ pub extern "C" fn wasmtime_module_serialize( |
|
|
|
handle_result(module.module.serialize(), |buf| ret.set_buffer(buf)) |
|
|
|
} |
|
|
|
|
|
|
|
#[no_mangle] |
|
|
|
pub extern "C" fn wasmtime_module_image_range( |
|
|
|
module: &wasmtime_module_t, |
|
|
|
start: &mut usize, |
|
|
|
end: &mut usize, |
|
|
|
) { |
|
|
|
let range = module.module.image_range(); |
|
|
|
*start = range.start; |
|
|
|
*end = range.end; |
|
|
|
} |
|
|
|
|
|
|
|
#[no_mangle] |
|
|
|
pub unsafe extern "C" fn wasmtime_module_deserialize( |
|
|
|
engine: &wasm_engine_t, |
|
|
|