Expose wasmtime cache configuration in the C API (#1606)
This adds a new `wasmtime_config_cache_config_load` C API function to allow enabling and configuring the cache via the API. This was originally requested over at bytecodealliance/wasmtime-py#3
This commit is contained in:
@@ -61,6 +61,8 @@ WASMTIME_CONFIG_PROP(void, cranelift_debug_verifier, bool)
|
|||||||
WASMTIME_CONFIG_PROP(void, cranelift_opt_level, wasmtime_opt_level_t)
|
WASMTIME_CONFIG_PROP(void, cranelift_opt_level, wasmtime_opt_level_t)
|
||||||
WASMTIME_CONFIG_PROP(wasmtime_error_t*, profiler, wasmtime_profiling_strategy_t)
|
WASMTIME_CONFIG_PROP(wasmtime_error_t*, profiler, wasmtime_profiling_strategy_t)
|
||||||
|
|
||||||
|
WASM_API_EXTERN wasmtime_error_t* wasmtime_config_cache_config_load(wasm_config_t*, const char*);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Converts from the text format of WebAssembly to to the binary format.
|
// Converts from the text format of WebAssembly to to the binary format.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
use crate::{handle_result, wasmtime_error_t};
|
use crate::{handle_result, wasmtime_error_t};
|
||||||
|
use std::ffi::CStr;
|
||||||
|
use std::os::raw::c_char;
|
||||||
use wasmtime::{Config, OptLevel, ProfilingStrategy, Strategy};
|
use wasmtime::{Config, OptLevel, ProfilingStrategy, Strategy};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@@ -126,3 +128,21 @@ pub extern "C" fn wasmtime_config_profiler_set(
|
|||||||
});
|
});
|
||||||
handle_result(result, |_cfg| {})
|
handle_result(result, |_cfg| {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wasmtime_config_cache_config_load(
|
||||||
|
c: &mut wasm_config_t,
|
||||||
|
filename: *const c_char,
|
||||||
|
) -> Option<Box<wasmtime_error_t>> {
|
||||||
|
handle_result(
|
||||||
|
if filename.is_null() {
|
||||||
|
c.config.cache_config_load_default()
|
||||||
|
} else {
|
||||||
|
match CStr::from_ptr(filename).to_str() {
|
||||||
|
Ok(s) => c.config.cache_config_load(s),
|
||||||
|
Err(e) => Err(e.into()),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|_cfg| {},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user