fix(wasmtime):Config methods should be idempotent (#4252)
This commit refactored `Config` to use a seperate `CompilerConfig` field instead of operating on `CompilerBuilder` directly to make all its methods idempotent. Fixes #4189
This commit is contained in:
@@ -201,7 +201,7 @@ WASMTIME_CONFIG_PROP(void, wasm_memory64, bool)
|
||||
* If the compilation strategy selected could not be enabled then an error is
|
||||
* returned.
|
||||
*/
|
||||
WASMTIME_CONFIG_PROP(wasmtime_error_t*, strategy, wasmtime_strategy_t)
|
||||
WASMTIME_CONFIG_PROP(void, strategy, wasmtime_strategy_t)
|
||||
|
||||
/**
|
||||
* \brief Configures whether Cranelift's debug verifier is enabled.
|
||||
@@ -238,7 +238,7 @@ WASMTIME_CONFIG_PROP(void, cranelift_opt_level, wasmtime_opt_level_t)
|
||||
*
|
||||
* This setting in #WASMTIME_PROFILING_STRATEGY_NONE by default.
|
||||
*/
|
||||
WASMTIME_CONFIG_PROP(wasmtime_error_t*, profiler, wasmtime_profiling_strategy_t)
|
||||
WASMTIME_CONFIG_PROP(void, profiler, wasmtime_profiling_strategy_t)
|
||||
|
||||
/**
|
||||
* \brief Configures the maximum size for memory to be considered "static"
|
||||
|
||||
@@ -103,13 +103,12 @@ pub extern "C" fn wasmtime_config_wasm_memory64_set(c: &mut wasm_config_t, enabl
|
||||
pub extern "C" fn wasmtime_config_strategy_set(
|
||||
c: &mut wasm_config_t,
|
||||
strategy: wasmtime_strategy_t,
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
) {
|
||||
use wasmtime_strategy_t::*;
|
||||
let result = c.config.strategy(match strategy {
|
||||
c.config.strategy(match strategy {
|
||||
WASMTIME_STRATEGY_AUTO => Strategy::Auto,
|
||||
WASMTIME_STRATEGY_CRANELIFT => Strategy::Cranelift,
|
||||
});
|
||||
handle_result(result, |_cfg| {})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -145,13 +144,12 @@ pub extern "C" fn wasmtime_config_cranelift_opt_level_set(
|
||||
pub extern "C" fn wasmtime_config_profiler_set(
|
||||
c: &mut wasm_config_t,
|
||||
strategy: wasmtime_profiling_strategy_t,
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
) {
|
||||
use wasmtime_profiling_strategy_t::*;
|
||||
let result = c.config.profiler(match strategy {
|
||||
c.config.profiler(match strategy {
|
||||
WASMTIME_PROFILING_STRATEGY_NONE => ProfilingStrategy::None,
|
||||
WASMTIME_PROFILING_STRATEGY_JITDUMP => ProfilingStrategy::JitDump,
|
||||
});
|
||||
handle_result(result, |_cfg| {})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user