Skip to content

Commit d2fbd2d

Browse files
Update to wasm-tools 245 (#12571)
* Intrinsics updates * Remove ds_store * Update to wasm-tools 245 * Add vets * Fixup tests * Add missing feature for `indexmap` --------- Co-authored-by: Sy Brand <sy.brand@fastly.com>
1 parent 8ec3ff3 commit d2fbd2d

25 files changed

Lines changed: 702 additions & 388 deletions

File tree

Cargo.lock

Lines changed: 155 additions & 82 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
@@ -343,18 +343,18 @@ wit-bindgen = { version = "0.51.0", default-features = false }
343343
wit-bindgen-rust-macro = { version = "0.51.0", default-features = false }
344344

345345
# wasm-tools family:
346-
wasmparser = { version = "0.244.0", default-features = false, features = ['simd'] }
347-
wat = "1.244.0"
348-
wast = "244.0.0"
349-
wasmprinter = "0.244.0"
350-
wasm-encoder = "0.244.0"
351-
wasm-smith = "0.244.0"
352-
wasm-mutate = "0.244.0"
353-
wit-parser = "0.244.0"
354-
wit-component = "0.244.0"
355-
wasm-wave = "0.244.0"
356-
wasm-compose = "0.244.0"
357-
json-from-wast = "0.244.0"
346+
wasmparser = { version = "0.245.0", default-features = false, features = ['simd'] }
347+
wat = "1.245.0"
348+
wast = "245.0.0"
349+
wasmprinter = "0.245.0"
350+
wasm-encoder = "0.245.0"
351+
wasm-smith = "0.245.0"
352+
wasm-mutate = "0.245.0"
353+
wit-parser = "0.245.0"
354+
wit-component = "0.245.0"
355+
wasm-wave = "0.245.0"
356+
wasm-compose = "0.245.0"
357+
json-from-wast = "0.245.0"
358358

359359
# Non-Bytecode Alliance maintained dependencies:
360360
# --------------------------

crates/cranelift/src/compiler/component.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,30 @@ impl<'a> TrampolineCompiler<'a> {
767767
},
768768
);
769769
}
770-
Trampoline::ThreadSwitchTo {
770+
Trampoline::ThreadSuspendToSuspended {
771771
instance,
772772
cancellable,
773773
} => {
774774
self.translate_libcall(
775-
host::thread_switch_to,
775+
host::thread_suspend_to_suspended,
776+
TrapSentinel::NegativeOne,
777+
WasmArgs::InRegisters,
778+
|me, params| {
779+
params.push(me.index_value(*instance));
780+
params.push(
781+
me.builder
782+
.ins()
783+
.iconst(ir::types::I8, i64::from(*cancellable)),
784+
);
785+
},
786+
);
787+
}
788+
Trampoline::ThreadSuspendTo {
789+
instance,
790+
cancellable,
791+
} => {
792+
self.translate_libcall(
793+
host::thread_suspend_to,
776794
TrapSentinel::NegativeOne,
777795
WasmArgs::InRegisters,
778796
|me, params| {
@@ -803,22 +821,22 @@ impl<'a> TrampolineCompiler<'a> {
803821
},
804822
);
805823
}
806-
Trampoline::ThreadResumeLater { instance } => {
824+
Trampoline::ThreadUnsuspend { instance } => {
807825
self.translate_libcall(
808-
host::thread_resume_later,
826+
host::thread_unsuspend,
809827
TrapSentinel::Falsy,
810828
WasmArgs::InRegisters,
811829
|me, params| {
812830
params.push(me.index_value(*instance));
813831
},
814832
);
815833
}
816-
Trampoline::ThreadYieldTo {
834+
Trampoline::ThreadYieldToSuspended {
817835
instance,
818836
cancellable,
819837
} => {
820838
self.translate_libcall(
821-
host::thread_yield_to,
839+
host::thread_yield_to_suspended,
822840
TrapSentinel::NegativeOne,
823841
WasmArgs::InRegisters,
824842
|me, params| {
@@ -1472,11 +1490,12 @@ impl<'a> TrampolineCompiler<'a> {
14721490
| Trampoline::WaitableSetDrop { instance }
14731491
| Trampoline::WaitableJoin { instance }
14741492
| Trampoline::ThreadYield { instance, .. }
1475-
| Trampoline::ThreadSwitchTo { instance, .. }
14761493
| Trampoline::ThreadNewIndirect { instance, .. }
14771494
| Trampoline::ThreadSuspend { instance, .. }
1478-
| Trampoline::ThreadResumeLater { instance }
1479-
| Trampoline::ThreadYieldTo { instance, .. }
1495+
| Trampoline::ThreadSuspendToSuspended { instance, .. }
1496+
| Trampoline::ThreadSuspendTo { instance, .. }
1497+
| Trampoline::ThreadUnsuspend { instance, .. }
1498+
| Trampoline::ThreadYieldToSuspended { instance, .. }
14801499
| Trampoline::SubtaskDrop { instance }
14811500
| Trampoline::SubtaskCancel { instance, .. }
14821501
| Trampoline::ErrorContextNew { instance, .. }

crates/environ/src/component.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,15 @@ macro_rules! foreach_builtin_component_function {
194194
#[cfg(feature = "component-model-async")]
195195
thread_new_indirect(vmctx: vmctx, caller_instance: u32, func_ty_id: u32, func_table_idx: u32, func_idx: u32, context: u32) -> u64;
196196
#[cfg(feature = "component-model-async")]
197-
thread_switch_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
197+
thread_suspend_to_suspended(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
198+
#[cfg(feature = "component-model-async")]
199+
thread_suspend_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
198200
#[cfg(feature = "component-model-async")]
199201
thread_suspend(vmctx: vmctx, caller_instance: u32, cancellable: u8) -> u32;
200202
#[cfg(feature = "component-model-async")]
201-
thread_resume_later(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> bool;
203+
thread_unsuspend(vmctx: vmctx, caller_instance: u32, thread_idx: u32) -> bool;
202204
#[cfg(feature = "component-model-async")]
203-
thread_yield_to(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
205+
thread_yield_to_suspended(vmctx: vmctx, caller_instance: u32, cancellable: u8, thread_idx: u32) -> u32;
204206

205207
trap(vmctx: vmctx, code: u32) -> bool;
206208

crates/environ/src/component/dfg.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,22 @@ pub enum Trampoline {
490490
start_func_ty_idx: ComponentTypeIndex,
491491
start_func_table_id: TableId,
492492
},
493-
ThreadSwitchTo {
493+
ThreadSuspendToSuspended {
494494
instance: RuntimeComponentInstanceIndex,
495495
cancellable: bool,
496496
},
497497
ThreadSuspend {
498498
instance: RuntimeComponentInstanceIndex,
499499
cancellable: bool,
500500
},
501-
ThreadResumeLater {
501+
ThreadSuspendTo {
502+
instance: RuntimeComponentInstanceIndex,
503+
cancellable: bool,
504+
},
505+
ThreadUnsuspend {
502506
instance: RuntimeComponentInstanceIndex,
503507
},
504-
ThreadYieldTo {
508+
ThreadYieldToSuspended {
505509
instance: RuntimeComponentInstanceIndex,
506510
cancellable: bool,
507511
},
@@ -1181,10 +1185,17 @@ impl LinearizeDfg<'_> {
11811185
start_func_ty_idx: *start_func_ty_idx,
11821186
start_func_table_idx: self.runtime_table(*start_func_table_id),
11831187
},
1184-
Trampoline::ThreadSwitchTo {
1188+
Trampoline::ThreadSuspendToSuspended {
1189+
instance,
1190+
cancellable,
1191+
} => info::Trampoline::ThreadSuspendToSuspended {
1192+
instance: *instance,
1193+
cancellable: *cancellable,
1194+
},
1195+
Trampoline::ThreadSuspendTo {
11851196
instance,
11861197
cancellable,
1187-
} => info::Trampoline::ThreadSwitchTo {
1198+
} => info::Trampoline::ThreadSuspendTo {
11881199
instance: *instance,
11891200
cancellable: *cancellable,
11901201
},
@@ -1195,13 +1206,13 @@ impl LinearizeDfg<'_> {
11951206
instance: *instance,
11961207
cancellable: *cancellable,
11971208
},
1198-
Trampoline::ThreadResumeLater { instance } => info::Trampoline::ThreadResumeLater {
1209+
Trampoline::ThreadUnsuspend { instance } => info::Trampoline::ThreadUnsuspend {
11991210
instance: *instance,
12001211
},
1201-
Trampoline::ThreadYieldTo {
1212+
Trampoline::ThreadYieldToSuspended {
12021213
instance,
12031214
cancellable,
1204-
} => info::Trampoline::ThreadYieldTo {
1215+
} => info::Trampoline::ThreadYieldToSuspended {
12051216
instance: *instance,
12061217
cancellable: *cancellable,
12071218
},

crates/environ/src/component/info.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,17 @@ pub enum Trampoline {
11441144
start_func_table_idx: RuntimeTableIndex,
11451145
},
11461146

1147-
/// Intrinsic used to implement the `thread.switch-to` component model builtin.
1148-
ThreadSwitchTo {
1147+
/// Intrinsic used to implement the `thread.suspend-to-suspended` component model builtin.
1148+
ThreadSuspendToSuspended {
1149+
/// The specific component instance which is calling the intrinsic.
1150+
instance: RuntimeComponentInstanceIndex,
1151+
/// If `true`, indicates the caller instance may receive notification
1152+
/// of task cancellation.
1153+
cancellable: bool,
1154+
},
1155+
1156+
/// Intrinsic used to implement the `thread.suspend-to` component model builtin.
1157+
ThreadSuspendTo {
11491158
/// The specific component instance which is calling the intrinsic.
11501159
instance: RuntimeComponentInstanceIndex,
11511160
/// If `true`, indicates the caller instance may receive notification
@@ -1162,14 +1171,14 @@ pub enum Trampoline {
11621171
cancellable: bool,
11631172
},
11641173

1165-
/// Intrinsic used to implement the `thread.resume-later` component model builtin.
1166-
ThreadResumeLater {
1174+
/// Intrinsic used to implement the `thread.unsuspend` component model builtin.
1175+
ThreadUnsuspend {
11671176
/// The specific component instance which is calling the intrinsic.
11681177
instance: RuntimeComponentInstanceIndex,
11691178
},
11701179

1171-
/// Intrinsic used to implement the `thread.yield-to` component model builtin.
1172-
ThreadYieldTo {
1180+
/// Intrinsic used to implement the `thread.yield-to-suspended` component model builtin.
1181+
ThreadYieldToSuspended {
11731182
/// The specific component instance which is calling the intrinsic.
11741183
instance: RuntimeComponentInstanceIndex,
11751184
/// If `true`, indicates the caller instance may receive notification
@@ -1242,10 +1251,11 @@ impl Trampoline {
12421251
ContextSet { .. } => format!("context-set"),
12431252
ThreadIndex => format!("thread-index"),
12441253
ThreadNewIndirect { .. } => format!("thread-new-indirect"),
1245-
ThreadSwitchTo { .. } => format!("thread-switch-to"),
1254+
ThreadSuspendToSuspended { .. } => format!("thread-suspend-to-suspended"),
1255+
ThreadSuspendTo { .. } => format!("thread-suspend-to"),
12461256
ThreadSuspend { .. } => format!("thread-suspend"),
1247-
ThreadResumeLater { .. } => format!("thread-resume-later"),
1248-
ThreadYieldTo { .. } => format!("thread-yield-to"),
1257+
ThreadUnsuspend { .. } => format!("thread-unsuspend"),
1258+
ThreadYieldToSuspended { .. } => format!("thread-yield-to-suspended"),
12491259
}
12501260
}
12511261
}

crates/environ/src/component/translate.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,22 @@ enum LocalInitializer<'data> {
319319
start_func_ty: ComponentTypeIndex,
320320
start_func_table_index: TableIndex,
321321
},
322-
ThreadSwitchTo {
322+
ThreadSuspendToSuspended {
323323
func: ModuleInternedTypeIndex,
324324
cancellable: bool,
325325
},
326326
ThreadSuspend {
327327
func: ModuleInternedTypeIndex,
328328
cancellable: bool,
329329
},
330-
ThreadResumeLater {
330+
ThreadSuspendTo {
331+
func: ModuleInternedTypeIndex,
332+
cancellable: bool,
333+
},
334+
ThreadUnsuspend {
331335
func: ModuleInternedTypeIndex,
332336
},
333-
ThreadYieldTo {
337+
ThreadYieldToSuspended {
334338
func: ModuleInternedTypeIndex,
335339
cancellable: bool,
336340
},
@@ -1150,25 +1154,30 @@ impl<'a, 'data> Translator<'a, 'data> {
11501154
start_func_table_index: TableIndex::from_u32(table_index),
11511155
}
11521156
}
1153-
wasmparser::CanonicalFunction::ThreadSwitchTo { cancellable } => {
1157+
wasmparser::CanonicalFunction::ThreadSuspendToSuspended { cancellable } => {
11541158
let func = self.core_func_signature(core_func_index)?;
11551159
core_func_index += 1;
1156-
LocalInitializer::ThreadSwitchTo { func, cancellable }
1160+
LocalInitializer::ThreadSuspendToSuspended { func, cancellable }
11571161
}
11581162
wasmparser::CanonicalFunction::ThreadSuspend { cancellable } => {
11591163
let func = self.core_func_signature(core_func_index)?;
11601164
core_func_index += 1;
11611165
LocalInitializer::ThreadSuspend { func, cancellable }
11621166
}
1163-
wasmparser::CanonicalFunction::ThreadResumeLater => {
1167+
wasmparser::CanonicalFunction::ThreadSuspendTo { cancellable } => {
1168+
let func = self.core_func_signature(core_func_index)?;
1169+
core_func_index += 1;
1170+
LocalInitializer::ThreadSuspendTo { func, cancellable }
1171+
}
1172+
wasmparser::CanonicalFunction::ThreadUnsuspend => {
11641173
let func = self.core_func_signature(core_func_index)?;
11651174
core_func_index += 1;
1166-
LocalInitializer::ThreadResumeLater { func }
1175+
LocalInitializer::ThreadUnsuspend { func }
11671176
}
1168-
wasmparser::CanonicalFunction::ThreadYieldTo { cancellable } => {
1177+
wasmparser::CanonicalFunction::ThreadYieldToSuspended { cancellable } => {
11691178
let func = self.core_func_signature(core_func_index)?;
11701179
core_func_index += 1;
1171-
LocalInitializer::ThreadYieldTo { func, cancellable }
1180+
LocalInitializer::ThreadYieldToSuspended { func, cancellable }
11721181
}
11731182
};
11741183
self.result.initializers.push(init);

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,10 +1123,20 @@ impl<'a> Inliner<'a> {
11231123
));
11241124
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
11251125
}
1126-
ThreadSwitchTo { func, cancellable } => {
1126+
ThreadSuspendToSuspended { func, cancellable } => {
11271127
let index = self.result.trampolines.push((
11281128
*func,
1129-
dfg::Trampoline::ThreadSwitchTo {
1129+
dfg::Trampoline::ThreadSuspendToSuspended {
1130+
instance: frame.instance,
1131+
cancellable: *cancellable,
1132+
},
1133+
));
1134+
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
1135+
}
1136+
ThreadSuspendTo { func, cancellable } => {
1137+
let index = self.result.trampolines.push((
1138+
*func,
1139+
dfg::Trampoline::ThreadSuspendTo {
11301140
instance: frame.instance,
11311141
cancellable: *cancellable,
11321142
},
@@ -1143,19 +1153,19 @@ impl<'a> Inliner<'a> {
11431153
));
11441154
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
11451155
}
1146-
ThreadResumeLater { func } => {
1156+
ThreadUnsuspend { func } => {
11471157
let index = self.result.trampolines.push((
11481158
*func,
1149-
dfg::Trampoline::ThreadResumeLater {
1159+
dfg::Trampoline::ThreadUnsuspend {
11501160
instance: frame.instance,
11511161
},
11521162
));
11531163
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
11541164
}
1155-
ThreadYieldTo { func, cancellable } => {
1165+
ThreadYieldToSuspended { func, cancellable } => {
11561166
let index = self.result.trampolines.push((
11571167
*func,
1158-
dfg::Trampoline::ThreadYieldTo {
1168+
dfg::Trampoline::ThreadYieldToSuspended {
11591169
instance: frame.instance,
11601170
cancellable: *cancellable,
11611171
},

crates/environ/src/component/types_builder.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl ComponentTypesBuilder {
458458
ComponentDefinedType::Stream(ty) => {
459459
InterfaceType::Stream(self.stream_table_type(types, ty)?)
460460
}
461-
ComponentDefinedType::FixedSizeList(ty, size) => {
461+
ComponentDefinedType::FixedLengthList(ty, size) => {
462462
InterfaceType::FixedLengthList(self.fixed_length_list_type(types, ty, *size)?)
463463
}
464464
ComponentDefinedType::Map(..) => {
@@ -536,11 +536,6 @@ impl ComponentTypesBuilder {
536536
.cases
537537
.iter()
538538
.map(|(name, case)| {
539-
// FIXME: need to implement `refines`, not sure what that
540-
// is at this time.
541-
if case.refines.is_some() {
542-
bail!("refines is not supported at this time");
543-
}
544539
Ok((
545540
name.to_string(),
546541
match &case.ty.as_ref() {

crates/test-util/src/wast.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,17 @@ impl WastTest {
441441
return true;
442442
}
443443

444+
// These tests in the `component-model` submodule have not yet been
445+
// updated to account for the recent threading-related intrinsic
446+
// changes
447+
let unsupported = [
448+
"test/async/same-component-stream-future.wast",
449+
"test/async/trap-if-block-and-sync.wast",
450+
];
451+
if unsupported.iter().any(|part| self.path.ends_with(part)) {
452+
return true;
453+
}
454+
444455
// Some tests are known to fail with the pooling allocator
445456
if config.pooling {
446457
let unsupported = [

0 commit comments

Comments
 (0)