Skip to content

Commit c7e092d

Browse files
abrownalexcrichton
andauthored
Update wasm-tools crates to 1.228.0 (#10501)
* Update wasm-tools crates to 1.228.0 * Add missing canonical builtins * Add new component model feature flags * Vet wasm-tool dependencies using wildcard * Fix tests hidden behind new CM features Several CM-async tests were failing due to upstream changes to the canonical builtins. Here we add some new Wasmtime flags for enabling these new features, `wasm_component_model_async_builtins` and `wasm_component_model_async_stackful`, and propagate that far enough to enable the features for these tests. This also involved removing all the error context details from these builtins. Co-authored-by: Alex Crichton <[email protected]> * Add some additional plumbing for fuzz configuration prtest:full --------- Co-authored-by: Alex Crichton <[email protected]>
1 parent 4ca5ea6 commit c7e092d

File tree

23 files changed

+352
-258
lines changed

23 files changed

+352
-258
lines changed

Cargo.lock

Lines changed: 123 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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,16 @@ wit-bindgen = { version = "0.41.0", default-features = false }
309309
wit-bindgen-rust-macro = { version = "0.41.0", default-features = false }
310310

311311
# wasm-tools family:
312-
wasmparser = { version = "0.227.0", default-features = false, features = ['simd'] }
313-
wat = "1.227.0"
314-
wast = "227.0.0"
315-
wasmprinter = "0.227.0"
316-
wasm-encoder = "0.227.0"
317-
wasm-smith = "0.227.0"
318-
wasm-mutate = "0.227.0"
319-
wit-parser = "0.227.0"
320-
wit-component = "0.227.0"
321-
wasm-wave = "0.227.0"
312+
wasmparser = { version = "0.228.0", default-features = false, features = ['simd'] }
313+
wat = "1.228.0"
314+
wast = "228.0.0"
315+
wasmprinter = "0.228.0"
316+
wasm-encoder = "0.228.0"
317+
wasm-smith = "0.228.0"
318+
wasm-mutate = "0.228.0"
319+
wit-parser = "0.228.0"
320+
wit-component = "0.228.0"
321+
wasm-wave = "0.228.0"
322322

323323
# Non-Bytecode Alliance maintained dependencies:
324324
# --------------------------

crates/cli-flags/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ wasmtime_option_group! {
364364
pub component_model: Option<bool>,
365365
/// Component model support for async lifting/lowering.
366366
pub component_model_async: Option<bool>,
367+
/// Component model support for async lifting/lowering: this corresponds
368+
/// to the 🚝 emoji in the component model specification.
369+
pub component_model_async_builtins: Option<bool>,
370+
/// Component model support for async lifting/lowering: this corresponds
371+
/// to the 🚟 emoji in the component model specification.
372+
pub component_model_async_stackful: Option<bool>,
367373
/// Configure support for the function-references proposal.
368374
pub function_references: Option<bool>,
369375
/// Configure support for the GC proposal.
@@ -994,6 +1000,8 @@ impl CommonOptions {
9941000
handle_conditionally_compiled! {
9951001
("component-model", component_model, wasm_component_model)
9961002
("component-model-async", component_model_async, wasm_component_model_async)
1003+
("component-model-async", component_model_async_builtins, wasm_component_model_async_builtins)
1004+
("component-model-async", component_model_async_stackful, wasm_component_model_async_stackful)
9971005
("threads", threads, wasm_threads)
9981006
("gc", gc, wasm_gc)
9991007
("gc", reference_types, wasm_reference_types)

crates/cranelift/src/compiler/component.rs

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,8 @@ impl<'a> TrampolineCompiler<'a> {
140140
host::stream_new,
141141
TrapSentinel::NegativeOne,
142142
),
143-
Trampoline::StreamRead {
144-
ty,
145-
err_ctx_ty,
146-
options,
147-
} => {
148-
let tys = &[ty.as_u32(), err_ctx_ty.as_u32()];
143+
Trampoline::StreamRead { ty, options } => {
144+
let tys = &[ty.as_u32()];
149145
if let Some(info) = self.flat_stream_element_info(*ty).cloned() {
150146
self.translate_flat_stream_call(tys, options, host::flat_stream_read, &info)
151147
} else {
@@ -182,25 +178,20 @@ impl<'a> TrampolineCompiler<'a> {
182178
host::stream_close_readable,
183179
TrapSentinel::Falsy,
184180
),
185-
Trampoline::StreamCloseWritable { ty, err_ctx_ty } => self
186-
.translate_future_or_stream_call(
187-
&[ty.as_u32(), err_ctx_ty.as_u32()],
188-
None,
189-
host::stream_close_writable,
190-
TrapSentinel::Falsy,
191-
),
181+
Trampoline::StreamCloseWritable { ty } => self.translate_future_or_stream_call(
182+
&[ty.as_u32()],
183+
None,
184+
host::stream_close_writable,
185+
TrapSentinel::Falsy,
186+
),
192187
Trampoline::FutureNew { ty } => self.translate_future_or_stream_call(
193188
&[ty.as_u32()],
194189
None,
195190
host::future_new,
196191
TrapSentinel::NegativeOne,
197192
),
198-
Trampoline::FutureRead {
199-
ty,
200-
err_ctx_ty,
201-
options,
202-
} => self.translate_future_or_stream_call(
203-
&[ty.as_u32(), err_ctx_ty.as_u32()],
193+
Trampoline::FutureRead { ty, options } => self.translate_future_or_stream_call(
194+
&[ty.as_u32()],
204195
Some(&options),
205196
host::future_read,
206197
TrapSentinel::NegativeOne,
@@ -223,13 +214,12 @@ impl<'a> TrampolineCompiler<'a> {
223214
host::future_close_readable,
224215
TrapSentinel::Falsy,
225216
),
226-
Trampoline::FutureCloseWritable { ty, err_ctx_ty } => self
227-
.translate_future_or_stream_call(
228-
&[ty.as_u32(), err_ctx_ty.as_u32()],
229-
None,
230-
host::future_close_writable,
231-
TrapSentinel::Falsy,
232-
),
217+
Trampoline::FutureCloseWritable { ty } => self.translate_future_or_stream_call(
218+
&[ty.as_u32()],
219+
None,
220+
host::future_close_writable,
221+
TrapSentinel::Falsy,
222+
),
233223
Trampoline::ErrorContextNew { ty, options } => self.translate_error_context_call(
234224
*ty,
235225
options,
@@ -246,12 +236,12 @@ impl<'a> TrampolineCompiler<'a> {
246236
Trampoline::ErrorContextDrop { ty } => self.translate_error_context_drop_call(*ty),
247237
Trampoline::ResourceTransferOwn => {
248238
self.translate_host_libcall(host::resource_transfer_own, |me, rets| {
249-
rets[0] = me.raise_if_negative_one(rets[0]);
239+
rets[0] = me.raise_if_negative_one_and_truncate(rets[0]);
250240
})
251241
}
252242
Trampoline::ResourceTransferBorrow => {
253243
self.translate_host_libcall(host::resource_transfer_borrow, |me, rets| {
254-
rets[0] = me.raise_if_negative_one(rets[0]);
244+
rets[0] = me.raise_if_negative_one_and_truncate(rets[0]);
255245
})
256246
}
257247
Trampoline::ResourceEnterCall => {
@@ -277,17 +267,17 @@ impl<'a> TrampolineCompiler<'a> {
277267
),
278268
Trampoline::FutureTransfer => {
279269
self.translate_host_libcall(host::future_transfer, |me, rets| {
280-
rets[0] = me.raise_if_negative_one(rets[0]);
270+
rets[0] = me.raise_if_negative_one_and_truncate(rets[0]);
281271
})
282272
}
283273
Trampoline::StreamTransfer => {
284274
self.translate_host_libcall(host::stream_transfer, |me, rets| {
285-
rets[0] = me.raise_if_negative_one(rets[0]);
275+
rets[0] = me.raise_if_negative_one_and_truncate(rets[0]);
286276
})
287277
}
288278
Trampoline::ErrorContextTransfer => {
289279
self.translate_host_libcall(host::error_context_transfer, |me, rets| {
290-
rets[0] = me.raise_if_negative_one(rets[0]);
280+
rets[0] = me.raise_if_negative_one_and_truncate(rets[0]);
291281
})
292282
}
293283
}
@@ -373,12 +363,22 @@ impl<'a> TrampolineCompiler<'a> {
373363
let call = self.call_libcall(vmctx, get_libcall, args);
374364

375365
let result = self.builder.func.dfg.inst_results(call)[0];
366+
let result_ty = self.builder.func.dfg.value_type(result);
367+
let expected = &self.builder.func.signature.returns;
376368
match sentinel {
377369
TrapSentinel::NegativeOne => {
378-
let result = self.raise_if_negative_one(result);
370+
assert_eq!(expected.len(), 1);
371+
let result = match (result_ty, expected[0].value_type) {
372+
(ir::types::I64, ir::types::I32) => {
373+
self.raise_if_negative_one_and_truncate(result)
374+
}
375+
(ir::types::I64, ir::types::I64) => self.raise_if_negative_one(result),
376+
other => panic!("unsupported NegativeOne combo {other:?}"),
377+
};
379378
self.abi_store_results(&[result]);
380379
}
381380
TrapSentinel::Falsy => {
381+
assert_eq!(expected.len(), 0);
382382
self.raise_if_host_trapped(result);
383383
self.builder.ins().return_(&[]);
384384
}
@@ -887,7 +887,7 @@ impl<'a> TrampolineCompiler<'a> {
887887
);
888888
let call = self.call_libcall(vmctx, host::resource_new32, &host_args);
889889
let result = self.builder.func.dfg.inst_results(call)[0];
890-
let result = self.raise_if_negative_one(result);
890+
let result = self.raise_if_negative_one_and_truncate(result);
891891
self.abi_store_results(&[result]);
892892
}
893893

@@ -916,7 +916,7 @@ impl<'a> TrampolineCompiler<'a> {
916916
);
917917
let call = self.call_libcall(vmctx, host::resource_rep32, &host_args);
918918
let result = self.builder.func.dfg.inst_results(call)[0];
919-
let result = self.raise_if_negative_one(result);
919+
let result = self.raise_if_negative_one_and_truncate(result);
920920
self.abi_store_results(&[result]);
921921
}
922922

@@ -1423,11 +1423,16 @@ impl<'a> TrampolineCompiler<'a> {
14231423
self.raise_if_host_trapped(succeeded);
14241424
}
14251425

1426+
fn raise_if_negative_one_and_truncate(&mut self, ret: ir::Value) -> ir::Value {
1427+
let ret = self.raise_if_negative_one(ret);
1428+
self.builder.ins().ireduce(ir::types::I32, ret)
1429+
}
1430+
14261431
fn raise_if_negative_one(&mut self, ret: ir::Value) -> ir::Value {
14271432
let minus_one = self.builder.ins().iconst(ir::types::I64, -1);
14281433
let succeeded = self.builder.ins().icmp(IntCC::NotEqual, ret, minus_one);
14291434
self.raise_if_host_trapped(succeeded);
1430-
self.builder.ins().ireduce(ir::types::I32, ret)
1435+
ret
14311436
}
14321437

14331438
fn call_libcall(

crates/environ/src/component.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,33 @@ macro_rules! foreach_builtin_component_function {
114114
#[cfg(feature = "component-model-async")]
115115
future_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, future: u32, address: u32) -> u64;
116116
#[cfg(feature = "component-model-async")]
117-
future_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, err_ctx_ty: u32, future: u32, address: u32) -> u64;
117+
future_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, future: u32, address: u32) -> u64;
118118
#[cfg(feature = "component-model-async")]
119119
future_cancel_write(vmctx: vmctx, ty: u32, async_: u8, writer: u32) -> u64;
120120
#[cfg(feature = "component-model-async")]
121121
future_cancel_read(vmctx: vmctx, ty: u32, async_: u8, reader: u32) -> u64;
122122
#[cfg(feature = "component-model-async")]
123-
future_close_writable(vmctx: vmctx, ty: u32, err_ctx_ty: u32, writer: u32, error: u32) -> bool;
123+
future_close_writable(vmctx: vmctx, ty: u32, writer: u32) -> bool;
124124
#[cfg(feature = "component-model-async")]
125-
future_close_readable(vmctx: vmctx, ty: u32, reader: u32, error: u32) -> bool;
125+
future_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
126126
#[cfg(feature = "component-model-async")]
127127
stream_new(vmctx: vmctx, ty: u32) -> u64;
128128
#[cfg(feature = "component-model-async")]
129129
stream_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, stream: u32, address: u32, count: u32) -> u64;
130130
#[cfg(feature = "component-model-async")]
131-
stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, err_ctx_ty: u32, stream: u32, address: u32, count: u32) -> u64;
131+
stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, stream: u32, address: u32, count: u32) -> u64;
132132
#[cfg(feature = "component-model-async")]
133133
stream_cancel_write(vmctx: vmctx, ty: u32, async_: u8, writer: u32) -> u64;
134134
#[cfg(feature = "component-model-async")]
135135
stream_cancel_read(vmctx: vmctx, ty: u32, async_: u8, reader: u32) -> u64;
136136
#[cfg(feature = "component-model-async")]
137-
stream_close_writable(vmctx: vmctx, ty: u32, err_ctx_ty: u32, writer: u32, error: u32) -> bool;
137+
stream_close_writable(vmctx: vmctx, ty: u32, writer: u32) -> bool;
138138
#[cfg(feature = "component-model-async")]
139-
stream_close_readable(vmctx: vmctx, ty: u32, reader: u32, error: u32) -> bool;
139+
stream_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
140140
#[cfg(feature = "component-model-async")]
141141
flat_stream_write(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, ty: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
142142
#[cfg(feature = "component-model-async")]
143-
flat_stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, ty: u32, err_ctx_ty: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
143+
flat_stream_read(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, ty: u32, payload_size: u32, payload_align: u32, stream: u32, address: u32, count: u32) -> u64;
144144
#[cfg(feature = "component-model-async")]
145145
error_context_new(vmctx: vmctx, memory: ptr_u8, realloc: ptr_u8, string_encoding: u8, ty: u32, debug_msg_address: u32, debug_msg_len: u32) -> u64;
146146
#[cfg(feature = "component-model-async")]

crates/environ/src/component/dfg.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ pub enum Trampoline {
321321
},
322322
StreamRead {
323323
ty: TypeStreamTableIndex,
324-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
325324
options: CanonicalOptions,
326325
},
327326
StreamWrite {
@@ -341,14 +340,12 @@ pub enum Trampoline {
341340
},
342341
StreamCloseWritable {
343342
ty: TypeStreamTableIndex,
344-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
345343
},
346344
FutureNew {
347345
ty: TypeFutureTableIndex,
348346
},
349347
FutureRead {
350348
ty: TypeFutureTableIndex,
351-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
352349
options: CanonicalOptions,
353350
},
354351
FutureWrite {
@@ -368,7 +365,6 @@ pub enum Trampoline {
368365
},
369366
FutureCloseWritable {
370367
ty: TypeFutureTableIndex,
371-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
372368
},
373369
ErrorContextNew {
374370
ty: TypeComponentLocalErrorContextTableIndex,
@@ -825,13 +821,8 @@ impl LinearizeDfg<'_> {
825821
instance: *instance,
826822
},
827823
Trampoline::StreamNew { ty } => info::Trampoline::StreamNew { ty: *ty },
828-
Trampoline::StreamRead {
829-
ty,
830-
err_ctx_ty,
831-
options,
832-
} => info::Trampoline::StreamRead {
824+
Trampoline::StreamRead { ty, options } => info::Trampoline::StreamRead {
833825
ty: *ty,
834-
err_ctx_ty: *err_ctx_ty,
835826
options: self.options(options),
836827
},
837828
Trampoline::StreamWrite { ty, options } => info::Trampoline::StreamWrite {
@@ -849,20 +840,12 @@ impl LinearizeDfg<'_> {
849840
Trampoline::StreamCloseReadable { ty } => {
850841
info::Trampoline::StreamCloseReadable { ty: *ty }
851842
}
852-
Trampoline::StreamCloseWritable { ty, err_ctx_ty } => {
853-
info::Trampoline::StreamCloseWritable {
854-
ty: *ty,
855-
err_ctx_ty: *err_ctx_ty,
856-
}
843+
Trampoline::StreamCloseWritable { ty } => {
844+
info::Trampoline::StreamCloseWritable { ty: *ty }
857845
}
858846
Trampoline::FutureNew { ty } => info::Trampoline::FutureNew { ty: *ty },
859-
Trampoline::FutureRead {
860-
ty,
861-
err_ctx_ty,
862-
options,
863-
} => info::Trampoline::FutureRead {
847+
Trampoline::FutureRead { ty, options } => info::Trampoline::FutureRead {
864848
ty: *ty,
865-
err_ctx_ty: *err_ctx_ty,
866849
options: self.options(options),
867850
},
868851
Trampoline::FutureWrite { ty, options } => info::Trampoline::FutureWrite {
@@ -880,11 +863,8 @@ impl LinearizeDfg<'_> {
880863
Trampoline::FutureCloseReadable { ty } => {
881864
info::Trampoline::FutureCloseReadable { ty: *ty }
882865
}
883-
Trampoline::FutureCloseWritable { ty, err_ctx_ty } => {
884-
info::Trampoline::FutureCloseWritable {
885-
ty: *ty,
886-
err_ctx_ty: *err_ctx_ty,
887-
}
866+
Trampoline::FutureCloseWritable { ty } => {
867+
info::Trampoline::FutureCloseWritable { ty: *ty }
888868
}
889869
Trampoline::ErrorContextNew { ty, options } => info::Trampoline::ErrorContextNew {
890870
ty: *ty,

crates/environ/src/component/info.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,6 @@ pub enum Trampoline {
787787
/// The table index for the specific `stream` type and caller instance.
788788
ty: TypeStreamTableIndex,
789789

790-
/// The table index for the `error-context` type in the caller instance.
791-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
792-
793790
/// Any options (e.g. string encoding) to use when storing values to
794791
/// memory.
795792
options: CanonicalOptions,
@@ -836,9 +833,6 @@ pub enum Trampoline {
836833
StreamCloseWritable {
837834
/// The table index for the specific `stream` type and caller instance.
838835
ty: TypeStreamTableIndex,
839-
840-
/// The table index for the `error-context` type in the caller instance.
841-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
842836
},
843837

844838
/// A `future.new` intrinsic to create a new `future` handle of the
@@ -853,9 +847,6 @@ pub enum Trampoline {
853847
/// The table index for the specific `future` type and caller instance.
854848
ty: TypeFutureTableIndex,
855849

856-
/// The table index for the `error-context` type in the caller instance.
857-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
858-
859850
/// Any options (e.g. string encoding) to use when storing values to
860851
/// memory.
861852
options: CanonicalOptions,
@@ -902,9 +893,6 @@ pub enum Trampoline {
902893
FutureCloseWritable {
903894
/// The table index for the specific `future` type and caller instance.
904895
ty: TypeFutureTableIndex,
905-
906-
/// The table index for the `error-context` type in the caller instance.
907-
err_ctx_ty: TypeComponentLocalErrorContextTableIndex,
908896
},
909897

910898
/// A `error-context.new` intrinsic to create a new `error-context` with a

0 commit comments

Comments
 (0)