Skip to content

Commit 562176e

Browse files
committed
add component-model-async/lift.wast test
This is another piece of #9582 which I'm splitting out to make review easier. This test includes two components: one which exports a function using the async-with-callback ABI, and another which uses the async-without-callback ABI. It doesn't actually instantiate or run either component yet. The rest of the changes fill in some TODOs to make the test pass. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent ca95576 commit 562176e

17 files changed

Lines changed: 802 additions & 20 deletions

File tree

crates/fuzzing/src/generators/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl Config {
139139
extended_const,
140140
wide_arithmetic,
141141
component_model_more_flags,
142+
component_model_async,
142143
simd,
143144

144145
hogs_memory: _,
@@ -151,6 +152,7 @@ impl Config {
151152
self.module_config.function_references_enabled =
152153
function_references.or(gc).unwrap_or(false);
153154
self.module_config.component_model_more_flags = component_model_more_flags.unwrap_or(false);
155+
self.module_config.component_model_async = component_model_async.unwrap_or(false);
154156

155157
// Enable/disable proposals that wasm-smith has knobs for which will be
156158
// read when creating `wasmtime::Config`.
@@ -266,6 +268,7 @@ impl Config {
266268
.wasm_wide_arithmetic(self.module_config.config.wide_arithmetic_enabled)
267269
.wasm_extended_const(self.module_config.config.extended_const_enabled)
268270
.wasm_component_model_more_flags(self.module_config.component_model_more_flags)
271+
.wasm_component_model_async(self.module_config.component_model_async)
269272
.native_unwind_info(cfg!(target_os = "windows") || self.wasmtime.native_unwind_info)
270273
.cranelift_nan_canonicalization(self.wasmtime.canonicalize_nans)
271274
.cranelift_opt_level(self.wasmtime.opt_level.to_wasmtime())

crates/fuzzing/src/generators/module.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct ModuleConfig {
1616
// config-to-`wasmtime::Config` translation.
1717
pub function_references_enabled: bool,
1818
pub component_model_more_flags: bool,
19+
pub component_model_async: bool,
1920
}
2021

2122
impl<'a> Arbitrary<'a> for ModuleConfig {
@@ -62,6 +63,7 @@ impl<'a> Arbitrary<'a> for ModuleConfig {
6263

6364
Ok(ModuleConfig {
6465
component_model_more_flags: false,
66+
component_model_async: false,
6567
function_references_enabled: config.gc_enabled,
6668
config,
6769
})

crates/misc/component-test-util/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111
env_logger = { workspace = true }
1212
anyhow = { workspace = true }
1313
arbitrary = { workspace = true, features = ["derive"] }
14-
wasmtime = { workspace = true, features = ["component-model", "async"] }
14+
wasmtime = { workspace = true, features = ["component-model", "async", "component-model-async"] }
1515
wasmtime-environ = { workspace = true }
1616
wasmtime-wast-util = { path = '../../wast-util' }
1717
target-lexicon = { workspace = true }

crates/misc/component-test-util/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wasmtime_wast_util::
166166
extended_const,
167167
wide_arithmetic,
168168
component_model_more_flags,
169+
component_model_async,
169170
nan_canonicalization,
170171
simd,
171172

@@ -184,6 +185,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wasmtime_wast_util::
184185
let extended_const = extended_const.unwrap_or(false);
185186
let wide_arithmetic = wide_arithmetic.unwrap_or(false);
186187
let component_model_more_flags = component_model_more_flags.unwrap_or(false);
188+
let component_model_async = component_model_async.unwrap_or(false);
187189
let nan_canonicalization = nan_canonicalization.unwrap_or(false);
188190
let relaxed_simd = relaxed_simd.unwrap_or(false);
189191

@@ -210,5 +212,6 @@ pub fn apply_test_config(config: &mut Config, test_config: &wasmtime_wast_util::
210212
.wasm_extended_const(extended_const)
211213
.wasm_wide_arithmetic(wide_arithmetic)
212214
.wasm_component_model_more_flags(component_model_more_flags)
215+
.wasm_component_model_async(component_model_async)
213216
.cranelift_nan_canonicalization(nan_canonicalization);
214217
}

crates/wasmtime/src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,19 @@ impl Config {
11031103
self
11041104
}
11051105

1106+
/// Configures whether components support the async ABI [proposal] for
1107+
/// lifting and lowering functions, as well as `stream`, `future`, and
1108+
/// `error-context` types.
1109+
///
1110+
/// Please note that Wasmtime's support for this feature is _very_ incomplete.
1111+
///
1112+
/// [proposal]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md
1113+
#[cfg(feature = "component-model-async")]
1114+
pub fn wasm_component_model_async(&mut self, enable: bool) -> &mut Self {
1115+
self.wasm_feature(WasmFeatures::COMPONENT_MODEL_ASYNC, enable);
1116+
self
1117+
}
1118+
11061119
/// Configures which compilation strategy will be used for wasm modules.
11071120
///
11081121
/// This method can be used to configure which compiler is used for wasm

crates/wasmtime/src/engine/serialization.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct WasmFeatures {
202202
custom_page_sizes: bool,
203203
component_model_more_flags: bool,
204204
component_model_multiple_returns: bool,
205+
component_model_async: bool,
205206
gc_types: bool,
206207
wide_arithmetic: bool,
207208
}
@@ -253,7 +254,6 @@ impl Metadata<'_> {
253254
assert!(!shared_everything_threads);
254255
assert!(!legacy_exceptions);
255256
assert!(!stack_switching);
256-
assert!(!component_model_async);
257257

258258
Metadata {
259259
target: engine.compiler().triple().to_string(),
@@ -278,6 +278,7 @@ impl Metadata<'_> {
278278
custom_page_sizes,
279279
component_model_more_flags,
280280
component_model_multiple_returns,
281+
component_model_async,
281282
gc_types,
282283
wide_arithmetic,
283284
},
@@ -488,6 +489,7 @@ impl Metadata<'_> {
488489
custom_page_sizes,
489490
component_model_more_flags,
490491
component_model_multiple_returns,
492+
component_model_async,
491493
gc_types,
492494
wide_arithmetic,
493495
} = self.features;
@@ -574,6 +576,11 @@ impl Metadata<'_> {
574576
other.contains(F::COMPONENT_MODEL_MULTIPLE_RETURNS),
575577
"WebAssembly component model support for multiple returns",
576578
)?;
579+
Self::check_bool(
580+
component_model_async,
581+
other.contains(F::COMPONENT_MODEL_ASYNC),
582+
"WebAssembly component model support for async lifts/lowers, futures, streams, and errors",
583+
)?;
577584
Self::check_cfg_bool(
578585
cfg!(feature = "gc"),
579586
"gc",

0 commit comments

Comments
 (0)