Skip to content

Commit 8a8e87d

Browse files
authored
Gate synchronous future/stream read/write separately (#13217)
This commit renames the previous `wasm_component_model_async_builtins` feature to `wasm_component_model_more_async_builtins` and then moves synchronous future/stream reads/writes behind this feature. This is inspired by #13212 and corresponds to WebAssembly/component-model#641 plus bytecodealliance/wasm-tools#2507.
1 parent 42e4093 commit 8a8e87d

29 files changed

Lines changed: 256 additions & 146 deletions

File tree

‎Cargo.lock‎

Lines changed: 124 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,18 @@ wit-bindgen = { version = "0.57.0", default-features = false }
351351
wit-bindgen-rust-macro = { version = "0.57.0", default-features = false }
352352

353353
# wasm-tools family:
354-
wasmparser = { version = "0.247.0", default-features = false, features = ['simd'] }
355-
wat = "1.247.0"
356-
wast = "247.0.0"
357-
wasmprinter = "0.247.0"
358-
wasm-encoder = "0.247.0"
359-
wasm-smith = "0.247.0"
360-
wasm-mutate = "0.247.0"
361-
wit-parser = "0.247.0"
362-
wit-component = "0.247.0"
363-
wasm-wave = "0.247.0"
364-
wasm-compose = { version = "0.247.0", default-features = false }
365-
json-from-wast = "0.247.0"
354+
wasmparser = { version = "0.248.0", default-features = false, features = ['simd'] }
355+
wat = "1.248.0"
356+
wast = "248.0.0"
357+
wasmprinter = "0.248.0"
358+
wasm-encoder = "0.248.0"
359+
wasm-smith = "0.248.0"
360+
wasm-mutate = "0.248.0"
361+
wit-parser = "0.248.0"
362+
wit-component = "0.248.0"
363+
wasm-wave = "0.248.0"
364+
wasm-compose = { version = "0.248.0", default-features = false }
365+
json-from-wast = "0.248.0"
366366

367367
wstd = "0.6.5"
368368
wasip2 = "1.0"

‎ci/miri-provenance-test.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ compile() {
1919
-O memory-guard-size=0 \
2020
-O signals-based-traps=n \
2121
-D guest-debug=y \
22-
-W function-references,component-model-async,component-model-async-stackful,component-model-async-builtins,component-model-error-context
22+
-W function-references,component-model-async,component-model-async-stackful,component-model-more-async-builtins,component-model-error-context
2323
}
2424

2525
compile ./tests/all/pulley_provenance_test.wat

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,9 @@ WASMTIME_CONFIG_PROP(void, wasm_component_model_async, bool)
917917
* component model.
918918
*
919919
* For more information see the Rust documentation at
920-
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model_async_builtins.
920+
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model_more_async_builtins.
921921
*/
922-
WASMTIME_CONFIG_PROP(void, wasm_component_model_async_builtins, bool)
922+
WASMTIME_CONFIG_PROP(void, wasm_component_model_more_async_builtins, bool)
923923

924924
/**
925925
* \brief Configures whether stackful coroutine support is enabled for async

‎crates/c-api/include/wasmtime/config.hh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,11 @@ public:
697697
* \brief Configures whether async built-in intrinsics are enabled for the
698698
* component model.
699699
*
700-
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model_async_builtins
700+
* https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_component_model_more_async_builtins
701701
*/
702-
void wasm_component_model_async_builtins(bool enable) {
703-
wasmtime_config_wasm_component_model_async_builtins_set(ptr.get(), enable);
702+
void wasm_component_model_more_async_builtins(bool enable) {
703+
wasmtime_config_wasm_component_model_more_async_builtins_set(ptr.get(),
704+
enable);
704705
}
705706

706707
/**

‎crates/c-api/src/component/component.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ pub extern "C" fn wasmtime_config_wasm_component_model_async_set(
2929

3030
#[unsafe(no_mangle)]
3131
#[cfg(feature = "component-model-async")]
32-
pub extern "C" fn wasmtime_config_wasm_component_model_async_builtins_set(
32+
pub extern "C" fn wasmtime_config_wasm_component_model_more_async_builtins_set(
3333
c: &mut wasm_config_t,
3434
enable: bool,
3535
) {
36-
c.config.wasm_component_model_async_builtins(enable);
36+
c.config.wasm_component_model_more_async_builtins(enable);
3737
}
3838

3939
#[unsafe(no_mangle)]

‎crates/c-api/tests/component/async.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ using wasmtime::Store;
1313

1414
TEST(component_async, config) {
1515
Config config;
16-
wasmtime_config_wasm_component_model_async_set(config.capi(), true);
17-
wasmtime_config_wasm_component_model_async_builtins_set(config.capi(), true);
18-
wasmtime_config_wasm_component_model_async_stackful_set(config.capi(), true);
16+
config.wasm_component_model_async(true);
17+
config.wasm_component_model_more_async_builtins(true);
18+
config.wasm_component_model_async_stackful(true);
1919
Engine engine(std::move(config));
2020
}
2121

‎crates/cli-flags/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ wasmtime_option_group! {
417417
pub component_model_async: Option<bool>,
418418
/// Component model support for async lifting/lowering: this corresponds
419419
/// to the 🚝 emoji in the component model specification.
420-
pub component_model_async_builtins: Option<bool>,
420+
pub component_model_more_async_builtins: Option<bool>,
421421
/// Component model support for async lifting/lowering: this corresponds
422422
/// to the 🚟 emoji in the component model specification.
423423
pub component_model_async_stackful: Option<bool>,
@@ -1202,7 +1202,7 @@ impl CommonOptions {
12021202
handle_conditionally_compiled! {
12031203
("component-model", component_model, wasm_component_model)
12041204
("component-model-async", component_model_async, wasm_component_model_async)
1205-
("component-model-async", component_model_async_builtins, wasm_component_model_async_builtins)
1205+
("component-model-async", component_model_more_async_builtins, wasm_component_model_more_async_builtins)
12061206
("component-model-async", component_model_async_stackful, wasm_component_model_async_stackful)
12071207
("component-model-async", component_model_threading, wasm_component_model_threading)
12081208
("component-model", component_model_error_context, wasm_component_model_error_context)

‎crates/environ/src/component/translate.rs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,15 +1127,21 @@ impl<'a, 'data> Translator<'a, 'data> {
11271127
core_func_index += 1;
11281128
LocalInitializer::ErrorContextDrop { func }
11291129
}
1130-
wasmparser::CanonicalFunction::ContextGet(i) => {
1130+
wasmparser::CanonicalFunction::ContextGet { slot, ty } => {
1131+
if ty != wasmparser::ValType::I32 {
1132+
bail!("unsupported context.get type: {ty:?}");
1133+
}
11311134
let func = self.core_func_signature(core_func_index)?;
11321135
core_func_index += 1;
1133-
LocalInitializer::ContextGet { i, func }
1136+
LocalInitializer::ContextGet { i: slot, func }
11341137
}
1135-
wasmparser::CanonicalFunction::ContextSet(i) => {
1138+
wasmparser::CanonicalFunction::ContextSet { slot, ty } => {
1139+
if ty != wasmparser::ValType::I32 {
1140+
bail!("unsupported context.set type: {ty:?}");
1141+
}
11361142
let func = self.core_func_signature(core_func_index)?;
11371143
core_func_index += 1;
1138-
LocalInitializer::ContextSet { i, func }
1144+
LocalInitializer::ContextSet { i: slot, func }
11391145
}
11401146
wasmparser::CanonicalFunction::ThreadIndex => {
11411147
let func = self.core_func_signature(core_func_index)?;

‎crates/fuzzing/src/generators/config.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl Config {
139139
extended_const,
140140
wide_arithmetic,
141141
component_model_async,
142-
component_model_async_builtins,
142+
component_model_more_async_builtins,
143143
component_model_async_stackful,
144144
component_model_threading,
145145
component_model_error_context,
@@ -163,8 +163,8 @@ impl Config {
163163
self.module_config.function_references_enabled =
164164
function_references.or(gc).unwrap_or(false);
165165
self.module_config.component_model_async = component_model_async.unwrap_or(false);
166-
self.module_config.component_model_async_builtins =
167-
component_model_async_builtins.unwrap_or(false);
166+
self.module_config.component_model_more_async_builtins =
167+
component_model_more_async_builtins.unwrap_or(false);
168168
self.module_config.component_model_async_stackful =
169169
component_model_async_stackful.unwrap_or(false);
170170
self.module_config.component_model_threading = component_model_threading.unwrap_or(false);
@@ -304,8 +304,8 @@ impl Config {
304304
cfg.wasm.async_stack_zeroing = Some(self.wasmtime.async_stack_zeroing);
305305
cfg.wasm.bulk_memory = Some(self.module_config.config.bulk_memory_enabled);
306306
cfg.wasm.component_model_async = Some(self.module_config.component_model_async);
307-
cfg.wasm.component_model_async_builtins =
308-
Some(self.module_config.component_model_async_builtins);
307+
cfg.wasm.component_model_more_async_builtins =
308+
Some(self.module_config.component_model_more_async_builtins);
309309
cfg.wasm.component_model_async_stackful =
310310
Some(self.module_config.component_model_async_stackful);
311311
cfg.wasm.component_model_threading = Some(self.module_config.component_model_threading);

0 commit comments

Comments
 (0)