Skip to content

Commit e0c8961

Browse files
authored
Add memory64 support to the Wasmtime CLI and C API (#3182)
Accidentally forgotten from #3153!
1 parent e68aa99 commit e0c8961

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

crates/c-api/include/wasmtime/config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ WASMTIME_CONFIG_PROP(void, wasm_multi_memory, bool)
192192
*/
193193
WASMTIME_CONFIG_PROP(void, wasm_module_linking, bool)
194194

195+
/**
196+
* \brief Configures whether the WebAssembly memory64 proposal is
197+
* enabled.
198+
*
199+
* This setting is `false` by default.
200+
*/
201+
WASMTIME_CONFIG_PROP(void, wasm_memory64, bool)
202+
195203
/**
196204
* \brief Configures how JIT code will be compiled.
197205
*

crates/c-api/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ pub extern "C" fn wasmtime_config_wasm_module_linking_set(c: &mut wasm_config_t,
100100
c.config.wasm_module_linking(enable);
101101
}
102102

103+
#[no_mangle]
104+
pub extern "C" fn wasmtime_config_wasm_memory64_set(c: &mut wasm_config_t, enable: bool) {
105+
c.config.wasm_memory64(enable);
106+
}
107+
103108
#[no_mangle]
104109
pub extern "C" fn wasmtime_config_strategy_set(
105110
c: &mut wasm_config_t,

docs/stability-wasm-proposals-support.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ vetted](./contributing-implementing-wasm-proposals.html).
2323
| **[Threads and Atomics]** | **In progress.** | `--enable-threads` | [`wasm_threads`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_threads) |
2424
| **[Multi-Memory]** | **Yes.** | `--enable-multi-memory`| [`wasm_multi_memory`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_multi_memory) |
2525
| **[Module Linking]** | **Yes.** | `--enable-module-linking` | [`wasm_module_linking`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_module_linking) |
26+
| **[Memory64]** | **Yes.** | `--enable-memory64` | [`wasm_memory64`](https://docs.rs/wasmtime/*/wasmtime/struct.Config.html#method.wasm_memory64) |
2627

2728
[config]: https://docs.rs/wasmtime/*/wasmtime/struct.Config.html
2829
[Multi-Value]: https://github.com/WebAssembly/spec/blob/master/proposals/multi-value/Overview.md
@@ -36,3 +37,4 @@ vetted](./contributing-implementing-wasm-proposals.html).
3637
[Threads and Atomics]: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md
3738
[Multi-Memory]: https://github.com/WebAssembly/multi-memory/blob/master/proposals/multi-memory/Overview.md
3839
[Module Linking]: https://github.com/WebAssembly/module-linking/blob/master/proposals/module-linking/Explainer.md
40+
[Memory64]: https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const SUPPORTED_WASM_FEATURES: &[(&str, &str)] = &[
4141
("reference-types", "enables support for reference types"),
4242
("simd", "enables support for proposed SIMD instructions"),
4343
("threads", "enables support for WebAssembly threads"),
44+
("memory64", "enables support for 64-bit memories"),
4445
];
4546

4647
const SUPPORTED_WASI_MODULES: &[(&str, &str)] = &[
@@ -437,7 +438,7 @@ fn parse_wasm_features(features: &str) -> Result<wasmparser::WasmFeatures> {
437438
deterministic_only: false,
438439
multi_memory: all.unwrap_or(values["multi-memory"].unwrap_or(false)),
439440
exceptions: false,
440-
memory64: false,
441+
memory64: all.unwrap_or(values["memory64"].unwrap_or(false)),
441442
})
442443
}
443444

@@ -561,7 +562,7 @@ mod test {
561562
assert!(!deterministic_only); // Not supported
562563
assert!(multi_memory);
563564
assert!(!exceptions); // Not supported
564-
assert!(!memory64); // Not supported
565+
assert!(memory64);
565566

566567
Ok(())
567568
}
@@ -603,7 +604,7 @@ mod test {
603604
fn test_multiple_features() -> Result<()> {
604605
let options = CommonOptions::from_iter_safe(vec![
605606
"foo",
606-
"--wasm-features=-reference-types,simd,multi-memory",
607+
"--wasm-features=-reference-types,simd,multi-memory,memory64",
607608
])?;
608609

609610
let wasmparser::WasmFeatures {
@@ -630,7 +631,7 @@ mod test {
630631
assert!(!deterministic_only); // Not supported
631632
assert!(multi_memory);
632633
assert!(!exceptions); // Not supported
633-
assert!(!memory64); // Not supported
634+
assert!(memory64);
634635

635636
Ok(())
636637
}
@@ -675,6 +676,7 @@ mod test {
675676
feature_test!(test_simd_feature, simd, "simd");
676677
feature_test!(test_threads_feature, threads, "threads");
677678
feature_test!(test_multi_memory_feature, multi_memory, "multi-memory");
679+
feature_test!(test_memory64_feature, memory64, "memory64");
678680

679681
#[test]
680682
fn test_default_modules() {

0 commit comments

Comments
 (0)