Skip to content

Commit 020727d

Browse files
Update wasm-tools dependencies (#12031)
* Change separator style * Update wasm-tools dependencies * Also update wit-bindgen * Drop `[async]` name prefixes * Plumb `async` as part of a function type Runtime handling of async functions and new traps are to be implemented in subsequent commits. This is just getting everything running again. * Run clang-format, also add test * Fix some more wast tests --------- Co-authored-by: Sy Brand <sy.brand@fastly.com>
1 parent 874da67 commit 020727d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+405
-364
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,22 @@ io-lifetimes = { version = "2.0.3", default-features = false }
333333
io-extras = "0.18.1"
334334
rustix = "1.0.8"
335335
# wit-bindgen:
336-
wit-bindgen = { version = "0.46.0", default-features = false }
337-
wit-bindgen-rust-macro = { version = "0.46.0", default-features = false }
336+
wit-bindgen = { version = "0.48.0", default-features = false }
337+
wit-bindgen-rust-macro = { version = "0.48.0", default-features = false }
338338

339339
# wasm-tools family:
340-
wasmparser = { version = "0.240.0", default-features = false, features = ['simd'] }
341-
wat = "1.240.0"
342-
wast = "240.0.0"
343-
wasmprinter = "0.240.0"
344-
wasm-encoder = "0.240.0"
345-
wasm-smith = "0.240.0"
346-
wasm-mutate = "0.240.0"
347-
wit-parser = "0.240.0"
348-
wit-component = "0.240.0"
349-
wasm-wave = "0.240.0"
350-
wasm-compose = "0.240.0"
351-
json-from-wast = "0.240.0"
340+
wasmparser = { version = "0.241.0", default-features = false, features = ['simd'] }
341+
wat = "1.241.0"
342+
wast = "241.0.0"
343+
wasmprinter = "0.241.0"
344+
wasm-encoder = "0.241.0"
345+
wasm-smith = "0.241.0"
346+
wasm-mutate = "0.241.0"
347+
wit-parser = "0.241.0"
348+
wit-component = "0.241.0"
349+
wasm-wave = "0.241.0"
350+
wasm-compose = "0.241.0"
351+
json-from-wast = "0.241.0"
352352

353353
# Non-Bytecode Alliance maintained dependencies:
354354
# --------------------------

crates/c-api/include/wasmtime/component/types/func.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ wasmtime_component_func_type_clone(const wasmtime_component_func_type_t *ty);
2929
WASM_API_EXTERN
3030
void wasmtime_component_func_type_delete(wasmtime_component_func_type_t *ty);
3131

32+
/// \brief Returns whether this is an async function.
33+
WASM_API_EXTERN
34+
bool wasmtime_component_func_type_async(
35+
const wasmtime_component_func_type_t *ty);
36+
3237
/// \brief Returns the number of parameters of a component function type.
3338
WASM_API_EXTERN
3439
size_t wasmtime_component_func_type_param_count(

crates/c-api/include/wasmtime/component/types/func.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class FuncType {
2626
return wasmtime_component_func_type_param_count(ptr.get());
2727
}
2828

29+
/// Returns whether this is an async function.
30+
bool async() const { return wasmtime_component_func_type_async(ptr.get()); }
31+
2932
/// Retrieves the nth parameter.
3033
std::optional<std::pair<std::string_view, ValType>>
3134
param_nth(size_t nth) const {

crates/c-api/src/component/types/func.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ type_wrapper! {
1111
delete: wasmtime_component_func_type_delete,
1212
}
1313

14+
#[unsafe(no_mangle)]
15+
pub extern "C" fn wasmtime_component_func_type_async(ty: &wasmtime_component_func_type_t) -> bool {
16+
ty.ty.async_()
17+
}
18+
1419
#[unsafe(no_mangle)]
1520
pub extern "C" fn wasmtime_component_func_type_param_count(
1621
ty: &wasmtime_component_func_type_t,

crates/c-api/tests/component/types.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ TEST(types, func_result) {
316316
auto f1 = *instance.get_func(store, f1_index);
317317
auto f2 = *instance.get_func(store, f2_index);
318318

319+
EXPECT_FALSE(f1.type(store).async());
319320
EXPECT_EQ(f1.type(store).param_count(), 0);
320321
EXPECT_FALSE(f1.type(store).result().has_value());
321322

crates/environ/src/component/info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub enum GlobalInitializer {
291291
/// from its `export` and stored into the `VMComponentContext` at the
292292
/// `index` specified. During this extraction, we will also capture the
293293
/// table's containing instance pointer to access the table at runtime. This
294-
/// extraction is useful for `thread.spawn_indirect`.
294+
/// extraction is useful for `thread.spawn-indirect`.
295295
ExtractTable(ExtractTable),
296296

297297
/// Declares a new defined resource within this component.
@@ -1137,7 +1137,7 @@ pub enum Trampoline {
11371137
/// Intrinsic used to implement the `thread.index` component model builtin.
11381138
ThreadIndex,
11391139

1140-
/// Intrinsic used to implement the `thread.new_indirect` component model builtin.
1140+
/// Intrinsic used to implement the `thread.new-indirect` component model builtin.
11411141
ThreadNewIndirect {
11421142
/// The specific component instance which is calling the intrinsic.
11431143
instance: RuntimeComponentInstanceIndex,

crates/environ/src/component/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ pub struct TypeComponentInstance {
550550
/// A component function type in the component model.
551551
#[derive(Serialize, Deserialize, Clone, Hash, Eq, PartialEq, Debug)]
552552
pub struct TypeFunc {
553+
/// Whether or not this is an async function.
554+
pub async_: bool,
553555
/// Names of parameters.
554556
pub param_names: Vec<String>,
555557
/// Parameters to the function represented as a tuple.

crates/environ/src/component/types_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ impl ComponentTypesBuilder {
254254
let params = self.new_tuple_type(params);
255255
let results = self.new_tuple_type(results);
256256
let ty = TypeFunc {
257+
async_: ty.async_,
257258
param_names,
258259
params,
259260
results,

crates/misc/component-async-tests/tests/scenario/round_trip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub async fn test_round_trip(
362362
linker
363363
.root()
364364
.instance("local:local/baz")?
365-
.func_new_concurrent("[async]foo", |_, _, params, results| {
365+
.func_new_concurrent("foo", |_, _, params, results| {
366366
Box::pin(async move {
367367
sleep(Duration::from_millis(10)).await;
368368
let Some(Val::String(s)) = params.into_iter().next() else {
@@ -380,11 +380,11 @@ pub async fn test_round_trip(
380380
.get_export_index(&mut store, None, "local:local/baz")
381381
.ok_or_else(|| anyhow!("can't find `local:local/baz` in instance"))?;
382382
let foo_function = instance
383-
.get_export_index(&mut store, Some(&baz_instance), "[async]foo")
384-
.ok_or_else(|| anyhow!("can't find `[async]foo` in instance"))?;
383+
.get_export_index(&mut store, Some(&baz_instance), "foo")
384+
.ok_or_else(|| anyhow!("can't find `foo` in instance"))?;
385385
let foo_function = instance
386386
.get_func(&mut store, foo_function)
387-
.ok_or_else(|| anyhow!("can't find `[async]foo` in instance"))?;
387+
.ok_or_else(|| anyhow!("can't find `foo` in instance"))?;
388388

389389
if call_style == 3 || !cfg!(miri) {
390390
store

0 commit comments

Comments
 (0)