Add memory64 support to the Wasmtime CLI and C API (#3182)

Accidentally forgotten from #3153!
This commit is contained in:
Alex Crichton
2021-08-12 12:33:57 -05:00
committed by GitHub
parent e68aa99588
commit e0c8961333
4 changed files with 21 additions and 4 deletions

View File

@@ -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.
*

View File

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

View File

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

View File

@@ -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<wasmparser::WasmFeatures> {
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() {