diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h index 356764e42a43..0150ee01a59a 100644 --- a/crates/c-api/include/wasmtime/config.h +++ b/crates/c-api/include/wasmtime/config.h @@ -192,6 +192,14 @@ WASMTIME_CONFIG_PROP(void, wasm_multi_memory, bool) */ WASMTIME_CONFIG_PROP(void, wasm_module_linking, bool) +/** + * \brief Configures whether the WebAssembly memory64 proposal is + * enabled. + * + * This setting is `false` by default. + */ +WASMTIME_CONFIG_PROP(void, wasm_memory64, bool) + /** * \brief Configures how JIT code will be compiled. * diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs index 40def6148ff2..6386ca6c9116 100644 --- a/crates/c-api/src/config.rs +++ b/crates/c-api/src/config.rs @@ -100,6 +100,11 @@ pub extern "C" fn wasmtime_config_wasm_module_linking_set(c: &mut wasm_config_t, c.config.wasm_module_linking(enable); } +#[no_mangle] +pub extern "C" fn wasmtime_config_wasm_memory64_set(c: &mut wasm_config_t, enable: bool) { + c.config.wasm_memory64(enable); +} + #[no_mangle] pub extern "C" fn wasmtime_config_strategy_set( c: &mut wasm_config_t, diff --git a/docs/stability-wasm-proposals-support.md b/docs/stability-wasm-proposals-support.md index 3080869774ac..13dbf978ae96 100644 --- a/docs/stability-wasm-proposals-support.md +++ b/docs/stability-wasm-proposals-support.md @@ -23,6 +23,7 @@ vetted](./contributing-implementing-wasm-proposals.html). | **[Threads and Atomics]** | **In progress.** | `--enable-threads` | [`wasm_threads`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_threads) | | **[Multi-Memory]** | **Yes.** | `--enable-multi-memory`| [`wasm_multi_memory`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_multi_memory) | | **[Module Linking]** | **Yes.** | `--enable-module-linking` | [`wasm_module_linking`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_module_linking) | +| **[Memory64]** | **Yes.** | `--enable-memory64` | [`wasm_memory64`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_memory64) | [config]: https://docs.rs/wasmtime/*/wasmtime/struct.Config.html [Multi-Value]: https://github.com/WebAssembly/spec/blob/master/proposals/multi-value/Overview.md @@ -36,3 +37,4 @@ vetted](./contributing-implementing-wasm-proposals.html). [Threads and Atomics]: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md [Multi-Memory]: https://github.com/WebAssembly/multi-memory/blob/master/proposals/multi-memory/Overview.md [Module Linking]: https://github.com/WebAssembly/module-linking/blob/master/proposals/module-linking/Explainer.md +[Memory64]: https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md diff --git a/src/lib.rs b/src/lib.rs index facb0383c283..b8630d5a13bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,7 @@ const SUPPORTED_WASM_FEATURES: &[(&str, &str)] = &[ ("reference-types", "enables support for reference types"), ("simd", "enables support for proposed SIMD instructions"), ("threads", "enables support for WebAssembly threads"), + ("memory64", "enables support for 64-bit memories"), ]; const SUPPORTED_WASI_MODULES: &[(&str, &str)] = &[ @@ -437,7 +438,7 @@ fn parse_wasm_features(features: &str) -> Result { deterministic_only: false, multi_memory: all.unwrap_or(values["multi-memory"].unwrap_or(false)), exceptions: false, - memory64: false, + memory64: all.unwrap_or(values["memory64"].unwrap_or(false)), }) } @@ -561,7 +562,7 @@ mod test { assert!(!deterministic_only); // Not supported assert!(multi_memory); assert!(!exceptions); // Not supported - assert!(!memory64); // Not supported + assert!(memory64); Ok(()) } @@ -603,7 +604,7 @@ mod test { fn test_multiple_features() -> Result<()> { let options = CommonOptions::from_iter_safe(vec![ "foo", - "--wasm-features=-reference-types,simd,multi-memory", + "--wasm-features=-reference-types,simd,multi-memory,memory64", ])?; let wasmparser::WasmFeatures { @@ -630,7 +631,7 @@ mod test { assert!(!deterministic_only); // Not supported assert!(multi_memory); assert!(!exceptions); // Not supported - assert!(!memory64); // Not supported + assert!(memory64); Ok(()) } @@ -675,6 +676,7 @@ mod test { feature_test!(test_simd_feature, simd, "simd"); feature_test!(test_threads_feature, threads, "threads"); feature_test!(test_multi_memory_feature, multi_memory, "multi-memory"); + feature_test!(test_memory64_feature, memory64, "memory64"); #[test] fn test_default_modules() {