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:
Pure White
2022-06-13 21:54:31 +08:00
committed by GitHub
parent 5f344ae7aa
commit 258dc9de42
13 changed files with 248 additions and 162 deletions

View File

@@ -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]