Skip to content

Commit c857f68

Browse files
authored
Add plumbing for error-context component model feature (#10807)
This commit adds plumbing in locations for the `error-context` feature of the component model. This is porting some minor changes from the wasip3-prototyping repository back to the main repo.
1 parent b2b4e21 commit c857f68

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

crates/cli-flags/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ wasmtime_option_group! {
372372
/// Component model support for async lifting/lowering: this corresponds
373373
/// to the 🚟 emoji in the component model specification.
374374
pub component_model_async_stackful: Option<bool>,
375+
/// Component model support for `error-context`: this corresponds
376+
/// to the 📝 emoji in the component model specification.
377+
pub component_model_error_context: Option<bool>,
375378
/// Configure support for the function-references proposal.
376379
pub function_references: Option<bool>,
377380
/// Configure support for the GC proposal.
@@ -1015,6 +1018,7 @@ impl CommonOptions {
10151018
("component-model-async", component_model_async, wasm_component_model_async)
10161019
("component-model-async", component_model_async_builtins, wasm_component_model_async_builtins)
10171020
("component-model-async", component_model_async_stackful, wasm_component_model_async_stackful)
1021+
("component-model", component_model_error_context, wasm_component_model_error_context)
10181022
("threads", threads, wasm_threads)
10191023
("gc", gc, wasm_gc)
10201024
("gc", reference_types, wasm_reference_types)

crates/fuzzing/src/generators/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl Config {
142142
component_model_async,
143143
component_model_async_builtins,
144144
component_model_async_stackful,
145+
component_model_error_context,
145146
simd,
146147
exceptions,
147148
legacy_exceptions,
@@ -160,6 +161,8 @@ impl Config {
160161
component_model_async_builtins.unwrap_or(false);
161162
self.module_config.component_model_async_stackful =
162163
component_model_async_stackful.unwrap_or(false);
164+
self.module_config.component_model_error_context =
165+
component_model_error_context.unwrap_or(false);
163166
self.module_config.legacy_exceptions = legacy_exceptions.unwrap_or(false);
164167

165168
// Enable/disable proposals that wasm-smith has knobs for which will be
@@ -285,6 +288,8 @@ impl Config {
285288
Some(self.module_config.component_model_async_builtins);
286289
cfg.wasm.component_model_async_stackful =
287290
Some(self.module_config.component_model_async_stackful);
291+
cfg.wasm.component_model_error_context =
292+
Some(self.module_config.component_model_error_context);
288293
cfg.wasm.custom_page_sizes = Some(self.module_config.config.custom_page_sizes_enabled);
289294
cfg.wasm.epoch_interruption = Some(self.wasmtime.epoch_interruption);
290295
cfg.wasm.extended_const = Some(self.module_config.config.extended_const_enabled);

crates/fuzzing/src/generators/module.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct ModuleConfig {
1919
pub component_model_async: bool,
2020
pub component_model_async_builtins: bool,
2121
pub component_model_async_stackful: bool,
22+
pub component_model_error_context: bool,
2223
pub legacy_exceptions: bool,
2324
}
2425

@@ -68,6 +69,7 @@ impl<'a> Arbitrary<'a> for ModuleConfig {
6869
component_model_async: false,
6970
component_model_async_builtins: false,
7071
component_model_async_stackful: false,
72+
component_model_error_context: false,
7173
legacy_exceptions: false,
7274
function_references_enabled: config.gc_enabled,
7375
config,

crates/test-util/src/wasmtime_wast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
4040
component_model_async,
4141
component_model_async_builtins,
4242
component_model_async_stackful,
43+
component_model_error_context,
4344
nan_canonicalization,
4445
simd,
4546
exceptions,
@@ -63,6 +64,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
6364
let component_model_async = component_model_async.unwrap_or(false);
6465
let component_model_async_builtins = component_model_async_builtins.unwrap_or(false);
6566
let component_model_async_stackful = component_model_async_stackful.unwrap_or(false);
67+
let component_model_error_context = component_model_error_context.unwrap_or(false);
6668
let nan_canonicalization = nan_canonicalization.unwrap_or(false);
6769
let relaxed_simd = relaxed_simd.unwrap_or(false);
6870
let exceptions = exceptions.unwrap_or(false);
@@ -94,6 +96,7 @@ pub fn apply_test_config(config: &mut Config, test_config: &wast::TestConfig) {
9496
.wasm_component_model_async(component_model_async)
9597
.wasm_component_model_async_builtins(component_model_async_builtins)
9698
.wasm_component_model_async_stackful(component_model_async_stackful)
99+
.wasm_component_model_error_context(component_model_error_context)
97100
.wasm_exceptions(exceptions)
98101
.cranelift_nan_canonicalization(nan_canonicalization);
99102
#[expect(deprecated, reason = "forwarding legacy-exceptions")]

crates/test-util/src/wast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ macro_rules! foreach_config_option {
243243
component_model_async
244244
component_model_async_builtins
245245
component_model_async_stackful
246+
component_model_error_context
246247
simd
247248
gc_types
248249
exceptions

crates/wasmtime/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,18 @@ impl Config {
11591159
self
11601160
}
11611161

1162+
/// This corresponds to the 📝 emoji in the component model specification.
1163+
///
1164+
/// Please note that Wasmtime's support for this feature is _very_
1165+
/// incomplete.
1166+
///
1167+
/// [proposal]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md
1168+
#[cfg(feature = "component-model")]
1169+
pub fn wasm_component_model_error_context(&mut self, enable: bool) -> &mut Self {
1170+
self.wasm_feature(WasmFeatures::CM_ERROR_CONTEXT, enable);
1171+
self
1172+
}
1173+
11621174
#[doc(hidden)] // FIXME(#3427) - if/when implemented then un-hide this
11631175
pub fn wasm_exceptions(&mut self, enable: bool) -> &mut Self {
11641176
self.wasm_feature(WasmFeatures::EXCEPTIONS, enable);

0 commit comments

Comments
 (0)