Skip to content

Commit 53d1e22

Browse files
authored
Rename task.yield to yield (bytecodealliance#2066)
Catching up to WebAssembly/component-model#438 a bit
1 parent 1dae3da commit 53d1e22

File tree

21 files changed

+68
-72
lines changed

21 files changed

+68
-72
lines changed

crates/wasm-encoder/src/component/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ impl ComponentBuilder {
408408
}
409409

410410
/// Declares a new `task.yield` intrinsic.
411-
pub fn task_yield(&mut self, async_: bool) -> u32 {
412-
self.canonical_functions().task_yield(async_);
411+
pub fn yield_(&mut self, async_: bool) -> u32 {
412+
self.canonical_functions().yield_(async_);
413413
inc(&mut self.core_funcs)
414414
}
415415

crates/wasm-encoder/src/component/canonicals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl CanonicalFunctionSection {
204204
/// are able to make progress, if any.
205205
///
206206
/// If `async_` is true, the caller instance may be reentered.
207-
pub fn task_yield(&mut self, async_: bool) -> &mut Self {
207+
pub fn yield_(&mut self, async_: bool) -> &mut Self {
208208
self.bytes.push(0x0c);
209209
self.bytes.push(if async_ { 1 } else { 0 });
210210
self.num_added += 1;

crates/wasm-encoder/src/reencode/component.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,8 @@ pub mod component_utils {
969969
options.iter().map(|o| reencoder.canonical_option(*o)),
970970
);
971971
}
972-
wasmparser::CanonicalFunction::TaskYield { async_ } => {
973-
section.task_yield(async_);
972+
wasmparser::CanonicalFunction::Yield { async_ } => {
973+
section.yield_(async_);
974974
}
975975
wasmparser::CanonicalFunction::SubtaskDrop => {
976976
section.subtask_drop();

crates/wasmparser/src/readers/component/canonicals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub enum CanonicalFunction {
9292
},
9393
/// A function which yields control to the host so that other tasks are able
9494
/// to make progress, if any.
95-
TaskYield {
95+
Yield {
9696
/// If `true`, indicates the caller instance maybe reentered.
9797
async_: bool,
9898
},
@@ -282,7 +282,7 @@ impl<'a> FromReader<'a> for CanonicalFunction {
282282
result: crate::read_resultlist(reader)?,
283283
options: read_opts(reader)?,
284284
},
285-
0x0c => CanonicalFunction::TaskYield {
285+
0x0c => CanonicalFunction::Yield {
286286
async_: reader.read()?,
287287
},
288288
0x0d => CanonicalFunction::SubtaskDrop,

crates/wasmparser/src/validator/component.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,7 @@ impl ComponentState {
997997
CanonicalFunction::TaskReturn { result, options } => {
998998
self.task_return(&result, &options, types, offset, features)
999999
}
1000-
CanonicalFunction::TaskYield { async_ } => {
1001-
self.task_yield(async_, types, offset, features)
1002-
}
1000+
CanonicalFunction::Yield { async_ } => self.yield_(async_, types, offset, features),
10031001
CanonicalFunction::SubtaskDrop => self.subtask_drop(types, offset, features),
10041002
CanonicalFunction::StreamNew { ty } => self.stream_new(ty, types, offset, features),
10051003
CanonicalFunction::StreamRead { ty, options } => {
@@ -1249,18 +1247,15 @@ impl ComponentState {
12491247
Ok(())
12501248
}
12511249

1252-
fn task_yield(
1250+
fn yield_(
12531251
&mut self,
12541252
_async_: bool,
12551253
types: &mut TypeAlloc,
12561254
offset: usize,
12571255
features: &WasmFeatures,
12581256
) -> Result<()> {
12591257
if !features.component_model_async() {
1260-
bail!(
1261-
offset,
1262-
"`task.yield` requires the component model async feature"
1263-
)
1258+
bail!(offset, "`yield` requires the component model async feature")
12641259
}
12651260

12661261
self.core_funcs

crates/wasmprinter/src/component.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl Printer<'_, '_> {
800800
self.print_idx(&state.core.func_names, *idx)?;
801801
self.end_group()?;
802802
}
803-
CanonicalOption::Async => self.result.write_str("async")?,
803+
CanonicalOption::Async => self.print_type_keyword("async")?,
804804
CanonicalOption::Callback(idx) => {
805805
self.start_group("callback ")?;
806806
self.print_idx(&state.core.func_names, *idx)?;
@@ -928,10 +928,10 @@ impl Printer<'_, '_> {
928928
Ok(())
929929
})?;
930930
}
931-
CanonicalFunction::TaskYield { async_ } => {
932-
self.print_intrinsic(state, "canon task.yield", &|me, _| {
931+
CanonicalFunction::Yield { async_ } => {
932+
self.print_intrinsic(state, "canon yield", &|me, _| {
933933
if async_ {
934-
me.result.write_str(" async")?;
934+
me.print_type_keyword(" async")?;
935935
}
936936
Ok(())
937937
})?;
@@ -960,7 +960,7 @@ impl Printer<'_, '_> {
960960
self.print_intrinsic(state, "canon stream.cancel-read ", &|me, state| {
961961
me.print_idx(&state.component.type_names, ty)?;
962962
if async_ {
963-
me.result.write_str(" async")?;
963+
me.print_type_keyword(" async")?;
964964
}
965965
Ok(())
966966
})?;
@@ -969,7 +969,7 @@ impl Printer<'_, '_> {
969969
self.print_intrinsic(state, "canon stream.cancel-write ", &|me, state| {
970970
me.print_idx(&state.component.type_names, ty)?;
971971
if async_ {
972-
me.result.write_str(" async")?;
972+
me.print_type_keyword(" async")?;
973973
}
974974
Ok(())
975975
})?;
@@ -1005,7 +1005,7 @@ impl Printer<'_, '_> {
10051005
self.print_intrinsic(state, "canon future.cancel-read ", &|me, state| {
10061006
me.print_idx(&state.component.type_names, ty)?;
10071007
if async_ {
1008-
me.result.write_str(" async")?;
1008+
me.print_type_keyword(" async")?;
10091009
}
10101010
Ok(())
10111011
})?;
@@ -1014,7 +1014,7 @@ impl Printer<'_, '_> {
10141014
self.print_intrinsic(state, "canon future.cancel-write ", &|me, state| {
10151015
me.print_idx(&state.component.type_names, ty)?;
10161016
if async_ {
1017-
me.result.write_str(" async")?;
1017+
me.print_type_keyword(" async")?;
10181018
}
10191019
Ok(())
10201020
})?;

crates/wast/src/component/binary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ impl<'a> Encoder<'a> {
370370
info.opts.iter().map(Into::into),
371371
);
372372
}
373-
CanonicalFuncKind::TaskYield(info) => {
373+
CanonicalFuncKind::Yield(info) => {
374374
self.core_func_names.push(name);
375-
self.funcs.task_yield(info.async_);
375+
self.funcs.yield_(info.async_);
376376
}
377377
CanonicalFuncKind::SubtaskDrop => {
378378
self.core_func_names.push(name);

crates/wast/src/component/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ impl<'a> Expander<'a> {
330330
name: func.name,
331331
kind: CanonicalFuncKind::TaskReturn(info),
332332
}),
333-
CoreFuncKind::TaskYield(info) => ComponentField::CanonicalFunc(CanonicalFunc {
333+
CoreFuncKind::Yield(info) => ComponentField::CanonicalFunc(CanonicalFunc {
334334
span: func.span,
335335
id: func.id,
336336
name: func.name,
337-
kind: CanonicalFuncKind::TaskYield(info),
337+
kind: CanonicalFuncKind::Yield(info),
338338
}),
339339
CoreFuncKind::SubtaskDrop => ComponentField::CanonicalFunc(CanonicalFunc {
340340
span: func.span,

crates/wast/src/component/func.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub enum CoreFuncKind<'a> {
5555
ThreadAvailableParallelism(CanonThreadAvailableParallelism),
5656
BackpressureSet,
5757
TaskReturn(CanonTaskReturn<'a>),
58-
TaskYield(CanonTaskYield),
58+
Yield(CanonYield),
5959
SubtaskDrop,
6060
StreamNew(CanonStreamNew<'a>),
6161
StreamRead(CanonStreamRead<'a>),
@@ -110,8 +110,8 @@ impl<'a> Parse<'a> for CoreFuncKind<'a> {
110110
Ok(CoreFuncKind::BackpressureSet)
111111
} else if l.peek::<kw::task_return>()? {
112112
Ok(CoreFuncKind::TaskReturn(parser.parse()?))
113-
} else if l.peek::<kw::task_yield>()? {
114-
Ok(CoreFuncKind::TaskYield(parser.parse()?))
113+
} else if l.peek::<kw::yield_>()? {
114+
Ok(CoreFuncKind::Yield(parser.parse()?))
115115
} else if l.peek::<kw::subtask_drop>()? {
116116
parser.parse::<kw::subtask_drop>()?;
117117
Ok(CoreFuncKind::SubtaskDrop)
@@ -357,7 +357,7 @@ pub enum CanonicalFuncKind<'a> {
357357

358358
BackpressureSet,
359359
TaskReturn(CanonTaskReturn<'a>),
360-
TaskYield(CanonTaskYield),
360+
Yield(CanonYield),
361361
SubtaskDrop,
362362
StreamNew(CanonStreamNew<'a>),
363363
StreamRead(CanonStreamRead<'a>),
@@ -611,15 +611,15 @@ impl<'a> Parse<'a> for CanonWaitableSetPoll<'a> {
611611

612612
/// Information relating to the `task.yield` intrinsic.
613613
#[derive(Debug)]
614-
pub struct CanonTaskYield {
614+
pub struct CanonYield {
615615
/// If true, the component instance may be reentered during a call to this
616616
/// intrinsic.
617617
pub async_: bool,
618618
}
619619

620-
impl<'a> Parse<'a> for CanonTaskYield {
620+
impl<'a> Parse<'a> for CanonYield {
621621
fn parse(parser: Parser<'a>) -> Result<Self> {
622-
parser.parse::<kw::task_yield>()?;
622+
parser.parse::<kw::yield_>()?;
623623
let async_ = parser.parse::<Option<kw::r#async>>()?.is_some();
624624

625625
Ok(Self { async_ })

crates/wast/src/component/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'a> Resolver<'a> {
388388
}
389389
CanonicalFuncKind::ThreadAvailableParallelism(_)
390390
| CanonicalFuncKind::BackpressureSet
391-
| CanonicalFuncKind::TaskYield(_)
391+
| CanonicalFuncKind::Yield(_)
392392
| CanonicalFuncKind::SubtaskDrop
393393
| CanonicalFuncKind::ErrorContextDrop => {}
394394
CanonicalFuncKind::TaskReturn(info) => {
@@ -971,7 +971,7 @@ impl<'a> ComponentState<'a> {
971971
| CanonicalFuncKind::ThreadAvailableParallelism(_)
972972
| CanonicalFuncKind::BackpressureSet
973973
| CanonicalFuncKind::TaskReturn(_)
974-
| CanonicalFuncKind::TaskYield(_)
974+
| CanonicalFuncKind::Yield(_)
975975
| CanonicalFuncKind::SubtaskDrop
976976
| CanonicalFuncKind::StreamNew(_)
977977
| CanonicalFuncKind::StreamRead(_)

0 commit comments

Comments
 (0)