Skip to content

Commit

Permalink
Expose cranelift nan canonicalization config via C API (#4154)
Browse files Browse the repository at this point in the history
* Add cranelift_nan_canonicalization to c api header

* Add cranelift_nan_canonicalization to capi/config.rs

* Fix func name
  • Loading branch information
ok-ul-ch committed May 14, 2022
1 parent 2e14a0e commit 8d7bcce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/c-api/include/wasmtime/config.h
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
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

0 comments on commit 8d7bcce

Please sign in to comment.