Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose cranelift nan canonicalization config via C API #4154

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/c-api/include/wasmtime/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ WASMTIME_CONFIG_PROP(wasmtime_error_t*, strategy, wasmtime_strategy_t)
*/
WASMTIME_CONFIG_PROP(void, cranelift_debug_verifier, bool)

/**
* \brief Configures whether Cranelift should perform a NaN-canonicalization pass.
*
* When Cranelift is used as a code generation backend this will configure
* it to replace NaNs with a single canonical value. This is useful for users
* requiring entirely deterministic WebAssembly computation.
*
* This is not required by the WebAssembly spec, so it is not enabled by default.
*
* The default value for this is `false`
*/
WASMTIME_CONFIG_PROP(void, cranelift_nan_canonicalization, bool)

/**
* \brief Configures Cranelift's optimization level for JIT code.
*
Expand Down
8 changes: 8 additions & 0 deletions crates/c-api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set(
c.config.cranelift_debug_verifier(enable);
}

#[no_mangle]
pub extern "C" fn wasmtime_config_cranelift_nan_canonicalization_set(
c: &mut wasm_config_t,
enable: bool,
) {
c.config.cranelift_nan_canonicalization(enable);
}

#[no_mangle]
pub extern "C" fn wasmtime_config_cranelift_opt_level_set(
c: &mut wasm_config_t,
Expand Down