Skip to content

Commit b8e3fbe

Browse files
authored
Update wasm-tools to the latest revision (#10314)
* Update wasm-tools to the latest revision * Update component async bits for new intrinsics * Ignore options for now * I truly, and fundamentally, do not understand `cargo vet` * Fix a test
1 parent 812dd1e commit b8e3fbe

File tree

21 files changed

+675
-321
lines changed

21 files changed

+675
-321
lines changed

Cargo.lock

Lines changed: 84 additions & 64 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
@@ -303,16 +303,16 @@ wit-bindgen = { version = "0.39.0", default-features = false }
303303
wit-bindgen-rust-macro = { version = "0.39.0", default-features = false }
304304

305305
# wasm-tools family:
306-
wasmparser = { version = "0.226.0", default-features = false, features = ['simd'] }
307-
wat = "1.226.0"
308-
wast = "226.0.0"
309-
wasmprinter = "0.226.0"
310-
wasm-encoder = "0.226.0"
311-
wasm-smith = "0.226.0"
312-
wasm-mutate = "0.226.0"
313-
wit-parser = "0.226.0"
314-
wit-component = "0.226.0"
315-
wasm-wave = "0.226.0"
306+
wasmparser = { version = "0.227.0", default-features = false, features = ['simd'] }
307+
wat = "1.227.0"
308+
wast = "227.0.0"
309+
wasmprinter = "0.227.0"
310+
wasm-encoder = "0.227.0"
311+
wasm-smith = "0.227.0"
312+
wasm-mutate = "0.227.0"
313+
wit-parser = "0.227.0"
314+
wit-component = "0.227.0"
315+
wasm-wave = "0.227.0"
316316

317317
# Non-Bytecode Alliance maintained dependencies:
318318
# --------------------------

crates/cranelift/src/compiler/component.rs

Lines changed: 84 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,36 @@ impl<'a> TrampolineCompiler<'a> {
103103
Trampoline::ResourceNew(ty) => self.translate_resource_new(*ty),
104104
Trampoline::ResourceRep(ty) => self.translate_resource_rep(*ty),
105105
Trampoline::ResourceDrop(ty) => self.translate_resource_drop(*ty),
106-
Trampoline::TaskBackpressure { instance } => {
107-
self.translate_task_backpressure_call(*instance)
106+
Trampoline::BackpressureSet { instance } => {
107+
self.translate_backpressure_set_call(*instance)
108108
}
109-
Trampoline::TaskReturn { results } => self.translate_task_return_call(*results),
110-
Trampoline::TaskWait {
109+
Trampoline::TaskReturn { results, options } => {
110+
self.translate_task_return_call(*results, options)
111+
}
112+
Trampoline::WaitableSetNew { instance } => self.translate_waitable_set_new(*instance),
113+
Trampoline::WaitableSetWait {
111114
instance,
112115
async_,
113116
memory,
114-
} => {
115-
self.translate_task_wait_or_poll_call(*instance, *async_, *memory, host::task_wait)
116-
}
117-
Trampoline::TaskPoll {
117+
} => self.translate_task_wait_or_poll_call(
118+
*instance,
119+
*async_,
120+
*memory,
121+
host::waitable_set_wait,
122+
),
123+
Trampoline::WaitableSetPoll {
118124
instance,
119125
async_,
120126
memory,
121-
} => {
122-
self.translate_task_wait_or_poll_call(*instance, *async_, *memory, host::task_poll)
123-
}
124-
Trampoline::TaskYield { async_ } => self.translate_task_yield_call(*async_),
127+
} => self.translate_task_wait_or_poll_call(
128+
*instance,
129+
*async_,
130+
*memory,
131+
host::waitable_set_poll,
132+
),
133+
Trampoline::WaitableSetDrop { instance } => self.translate_waitable_set_drop(*instance),
134+
Trampoline::WaitableJoin { instance } => self.translate_waitable_join(*instance),
135+
Trampoline::Yield { async_ } => self.translate_yield_call(*async_),
125136
Trampoline::SubtaskDrop { instance } => self.translate_subtask_drop_call(*instance),
126137
Trampoline::StreamNew { ty } => self.translate_future_or_stream_call(
127138
&[ty.as_u32()],
@@ -375,7 +386,9 @@ impl<'a> TrampolineCompiler<'a> {
375386
}
376387
}
377388

378-
fn translate_task_return_call(&mut self, results: TypeTupleIndex) {
389+
fn translate_task_return_call(&mut self, results: TypeTupleIndex, options: &CanonicalOptions) {
390+
// FIXME(#10338) shouldn't ignore options here.
391+
let _ = options;
379392
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
380393
let vmctx = args[0];
381394

@@ -394,6 +407,60 @@ impl<'a> TrampolineCompiler<'a> {
394407
);
395408
}
396409

410+
fn translate_waitable_set_new(&mut self, instance: RuntimeComponentInstanceIndex) {
411+
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
412+
let vmctx = args[0];
413+
414+
let instance = self
415+
.builder
416+
.ins()
417+
.iconst(ir::types::I32, i64::from(instance.as_u32()));
418+
419+
self.translate_intrinsic_libcall(
420+
vmctx,
421+
host::waitable_set_new,
422+
&[vmctx, instance],
423+
TrapSentinel::NegativeOne,
424+
);
425+
}
426+
427+
fn translate_waitable_set_drop(&mut self, instance: RuntimeComponentInstanceIndex) {
428+
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
429+
let vmctx = args[0];
430+
let set = args[2];
431+
432+
let instance = self
433+
.builder
434+
.ins()
435+
.iconst(ir::types::I32, i64::from(instance.as_u32()));
436+
437+
self.translate_intrinsic_libcall(
438+
vmctx,
439+
host::waitable_set_drop,
440+
&[vmctx, instance, set],
441+
TrapSentinel::Falsy,
442+
);
443+
}
444+
445+
fn translate_waitable_join(&mut self, instance: RuntimeComponentInstanceIndex) {
446+
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
447+
let vmctx = args[0];
448+
let set = args[2];
449+
let waitable = args[3];
450+
451+
let instance = self
452+
.builder
453+
.ins()
454+
.iconst(ir::types::I32, i64::from(instance.as_u32()));
455+
456+
self.translate_intrinsic_libcall(
457+
vmctx,
458+
host::waitable_join,
459+
&[vmctx, instance, set, waitable],
460+
TrapSentinel::Falsy,
461+
);
462+
}
463+
397464
fn translate_sync_enter(&mut self) {
398465
match self.abi {
399466
Abi::Wasm => {}
@@ -534,7 +601,7 @@ impl<'a> TrampolineCompiler<'a> {
534601
self.translate_intrinsic_libcall(vmctx, get_libcall, &callee_args, sentinel);
535602
}
536603

537-
fn translate_task_backpressure_call(&mut self, caller_instance: RuntimeComponentInstanceIndex) {
604+
fn translate_backpressure_set_call(&mut self, caller_instance: RuntimeComponentInstanceIndex) {
538605
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
539606
let vmctx = args[0];
540607

@@ -549,7 +616,7 @@ impl<'a> TrampolineCompiler<'a> {
549616

550617
self.translate_intrinsic_libcall(
551618
vmctx,
552-
host::task_backpressure,
619+
host::backpressure_set,
553620
&callee_args,
554621
TrapSentinel::Falsy,
555622
);
@@ -586,7 +653,7 @@ impl<'a> TrampolineCompiler<'a> {
586653
);
587654
}
588655

589-
fn translate_task_yield_call(&mut self, async_: bool) {
656+
fn translate_yield_call(&mut self, async_: bool) {
590657
let args = self.builder.func.dfg.block_params(self.block0).to_vec();
591658
let vmctx = args[0];
592659

@@ -597,12 +664,7 @@ impl<'a> TrampolineCompiler<'a> {
597664
.iconst(ir::types::I8, if async_ { 1 } else { 0 }),
598665
];
599666

600-
self.translate_intrinsic_libcall(
601-
vmctx,
602-
host::task_yield,
603-
&callee_args,
604-
TrapSentinel::Falsy,
605-
);
667+
self.translate_intrinsic_libcall(vmctx, host::yield_, &callee_args, TrapSentinel::Falsy);
606668
}
607669

608670
fn translate_subtask_drop_call(&mut self, caller_instance: RuntimeComponentInstanceIndex) {

crates/environ/src/component.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,21 @@ macro_rules! foreach_builtin_component_function {
8484
resource_exit_call(vmctx: vmctx) -> bool;
8585

8686
#[cfg(feature = "component-model-async")]
87-
task_backpressure(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
87+
backpressure_set(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
8888
#[cfg(feature = "component-model-async")]
8989
task_return(vmctx: vmctx, ty: u32, storage: ptr_u8, storage_len: size) -> bool;
9090
#[cfg(feature = "component-model-async")]
91-
task_wait(vmctx: vmctx, caller_instance: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
91+
waitable_set_new(vmctx: vmctx, caller_instance: u32) -> u64;
9292
#[cfg(feature = "component-model-async")]
93-
task_poll(vmctx: vmctx, caller_instance: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
93+
waitable_set_wait(vmctx: vmctx, caller_instance: u32, set: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
9494
#[cfg(feature = "component-model-async")]
95-
task_yield(vmctx: vmctx, async_: u8) -> bool;
95+
waitable_set_poll(vmctx: vmctx, caller_instance: u32, set: u32, async_: u8, memory: ptr_u8, payload: u32) -> u64;
96+
#[cfg(feature = "component-model-async")]
97+
waitable_set_drop(vmctx: vmctx, caller_instance: u32, set: u32) -> bool;
98+
#[cfg(feature = "component-model-async")]
99+
waitable_join(vmctx: vmctx, caller_instance: u32, set: u32, waitable: u32) -> bool;
100+
#[cfg(feature = "component-model-async")]
101+
yield_(vmctx: vmctx, async_: u8) -> bool;
96102
#[cfg(feature = "component-model-async")]
97103
subtask_drop(vmctx: vmctx, caller_instance: u32, task_id: u32) -> bool;
98104
#[cfg(feature = "component-model-async")]
@@ -116,7 +122,7 @@ macro_rules! foreach_builtin_component_function {
116122
#[cfg(feature = "component-model-async")]
117123
future_close_writable(vmctx: vmctx, ty: u32, err_ctx_ty: u32, writer: u32, error: u32) -> bool;
118124
#[cfg(feature = "component-model-async")]
119-
future_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
125+
future_close_readable(vmctx: vmctx, ty: u32, reader: u32, error: u32) -> bool;
120126
#[cfg(feature = "component-model-async")]
121127
stream_new(vmctx: vmctx, ty: u32) -> u64;
122128
#[cfg(feature = "component-model-async")]
@@ -130,7 +136,7 @@ macro_rules! foreach_builtin_component_function {
130136
#[cfg(feature = "component-model-async")]
131137
stream_close_writable(vmctx: vmctx, ty: u32, err_ctx_ty: u32, writer: u32, error: u32) -> bool;
132138
#[cfg(feature = "component-model-async")]
133-
stream_close_readable(vmctx: vmctx, ty: u32, reader: u32) -> bool;
139+
stream_close_readable(vmctx: vmctx, ty: u32, reader: u32, error: u32) -> bool;
134140
#[cfg(feature = "component-model-async")]
135141
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;
136142
#[cfg(feature = "component-model-async")]

crates/environ/src/component/dfg.rs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,23 +283,33 @@ pub enum Trampoline {
283283
ResourceNew(TypeResourceTableIndex),
284284
ResourceRep(TypeResourceTableIndex),
285285
ResourceDrop(TypeResourceTableIndex),
286-
TaskBackpressure {
286+
BackpressureSet {
287287
instance: RuntimeComponentInstanceIndex,
288288
},
289289
TaskReturn {
290290
results: TypeTupleIndex,
291+
options: CanonicalOptions,
292+
},
293+
WaitableSetNew {
294+
instance: RuntimeComponentInstanceIndex,
291295
},
292-
TaskWait {
296+
WaitableSetWait {
293297
instance: RuntimeComponentInstanceIndex,
294298
async_: bool,
295299
memory: MemoryId,
296300
},
297-
TaskPoll {
301+
WaitableSetPoll {
298302
instance: RuntimeComponentInstanceIndex,
299303
async_: bool,
300304
memory: MemoryId,
301305
},
302-
TaskYield {
306+
WaitableSetDrop {
307+
instance: RuntimeComponentInstanceIndex,
308+
},
309+
WaitableJoin {
310+
instance: RuntimeComponentInstanceIndex,
311+
},
312+
Yield {
303313
async_: bool,
304314
},
305315
SubtaskDrop {
@@ -772,31 +782,41 @@ impl LinearizeDfg<'_> {
772782
Trampoline::ResourceNew(ty) => info::Trampoline::ResourceNew(*ty),
773783
Trampoline::ResourceDrop(ty) => info::Trampoline::ResourceDrop(*ty),
774784
Trampoline::ResourceRep(ty) => info::Trampoline::ResourceRep(*ty),
775-
Trampoline::TaskBackpressure { instance } => info::Trampoline::TaskBackpressure {
785+
Trampoline::BackpressureSet { instance } => info::Trampoline::BackpressureSet {
776786
instance: *instance,
777787
},
778-
Trampoline::TaskReturn { results } => {
779-
info::Trampoline::TaskReturn { results: *results }
780-
}
781-
Trampoline::TaskWait {
788+
Trampoline::TaskReturn { results, options } => info::Trampoline::TaskReturn {
789+
results: *results,
790+
options: self.options(options),
791+
},
792+
Trampoline::WaitableSetNew { instance } => info::Trampoline::WaitableSetNew {
793+
instance: *instance,
794+
},
795+
Trampoline::WaitableSetWait {
782796
instance,
783797
async_,
784798
memory,
785-
} => info::Trampoline::TaskWait {
799+
} => info::Trampoline::WaitableSetWait {
786800
instance: *instance,
787801
async_: *async_,
788802
memory: self.runtime_memory(*memory),
789803
},
790-
Trampoline::TaskPoll {
804+
Trampoline::WaitableSetPoll {
791805
instance,
792806
async_,
793807
memory,
794-
} => info::Trampoline::TaskPoll {
808+
} => info::Trampoline::WaitableSetPoll {
795809
instance: *instance,
796810
async_: *async_,
797811
memory: self.runtime_memory(*memory),
798812
},
799-
Trampoline::TaskYield { async_ } => info::Trampoline::TaskYield { async_: *async_ },
813+
Trampoline::WaitableSetDrop { instance } => info::Trampoline::WaitableSetDrop {
814+
instance: *instance,
815+
},
816+
Trampoline::WaitableJoin { instance } => info::Trampoline::WaitableJoin {
817+
instance: *instance,
818+
},
819+
Trampoline::Yield { async_ } => info::Trampoline::Yield { async_: *async_ },
800820
Trampoline::SubtaskDrop { instance } => info::Trampoline::SubtaskDrop {
801821
instance: *instance,
802822
},

0 commit comments

Comments
 (0)