Skip to content

Commit 7dc07b3

Browse files
authored
Remove support for backpressure.set (#12130)
This canonical intrinsic which is part of component-model-async support is supplanted by `backpressure.{inc,dec}`. This wasn't removed when they were added to keep existing programs working, but that's no longer necessary.
1 parent 8992b99 commit 7dc07b3

File tree

11 files changed

+12
-68
lines changed

11 files changed

+12
-68
lines changed

crates/cranelift/src/compiler/component.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,6 @@ impl<'a> TrampolineCompiler<'a> {
204204
Trampoline::ResourceDrop { instance, ty } => {
205205
self.translate_resource_drop(*instance, *ty);
206206
}
207-
Trampoline::BackpressureSet { instance } => {
208-
self.translate_libcall(
209-
host::backpressure_set,
210-
TrapSentinel::Falsy,
211-
WasmArgs::InRegisters,
212-
|me, params| {
213-
params.push(me.index_value(*instance));
214-
},
215-
);
216-
}
217207
Trampoline::BackpressureInc { instance } => {
218208
self.translate_libcall(
219209
host::backpressure_modify,

crates/environ/src/component.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ macro_rules! foreach_builtin_component_function {
9999
resource_enter_call(vmctx: vmctx);
100100
resource_exit_call(vmctx: vmctx) -> bool;
101101

102-
#[cfg(feature = "component-model-async")]
103-
backpressure_set(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
104102
#[cfg(feature = "component-model-async")]
105103
backpressure_modify(vmctx: vmctx, caller_instance: u32, increment: u8) -> bool;
106104
#[cfg(feature = "component-model-async")]

crates/environ/src/component/dfg.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ pub enum Trampoline {
338338
instance: RuntimeComponentInstanceIndex,
339339
ty: TypeResourceTableIndex,
340340
},
341-
BackpressureSet {
342-
instance: RuntimeComponentInstanceIndex,
343-
},
344341
BackpressureInc {
345342
instance: RuntimeComponentInstanceIndex,
346343
},
@@ -959,9 +956,6 @@ impl LinearizeDfg<'_> {
959956
instance: *instance,
960957
ty: *ty,
961958
},
962-
Trampoline::BackpressureSet { instance } => info::Trampoline::BackpressureSet {
963-
instance: *instance,
964-
},
965959
Trampoline::BackpressureInc { instance } => info::Trampoline::BackpressureInc {
966960
instance: *instance,
967961
},

crates/environ/src/component/info.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,6 @@ pub enum Trampoline {
759759
ty: TypeResourceTableIndex,
760760
},
761761

762-
/// A `backpressure.set` intrinsic, which tells the host to enable or
763-
/// disable backpressure for the caller's instance.
764-
BackpressureSet {
765-
/// The specific component instance which is calling the intrinsic.
766-
instance: RuntimeComponentInstanceIndex,
767-
},
768-
769762
/// A `backpressure.inc` intrinsic.
770763
BackpressureInc {
771764
/// The specific component instance which is calling the intrinsic.
@@ -1206,7 +1199,6 @@ impl Trampoline {
12061199
ResourceNew { ty, .. } => format!("component-resource-new[{}]", ty.as_u32()),
12071200
ResourceRep { ty, .. } => format!("component-resource-rep[{}]", ty.as_u32()),
12081201
ResourceDrop { ty, .. } => format!("component-resource-drop[{}]", ty.as_u32()),
1209-
BackpressureSet { .. } => format!("backpressure-set"),
12101202
BackpressureInc { .. } => format!("backpressure-inc"),
12111203
BackpressureDec { .. } => format!("backpressure-dec"),
12121204
TaskReturn { .. } => format!("task-return"),

crates/environ/src/component/translate.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ enum LocalInitializer<'data> {
199199
ResourceRep(AliasableResourceId, ModuleInternedTypeIndex),
200200
ResourceDrop(AliasableResourceId, ModuleInternedTypeIndex),
201201

202-
BackpressureSet {
203-
func: ModuleInternedTypeIndex,
204-
},
205202
BackpressureInc {
206203
func: ModuleInternedTypeIndex,
207204
},
@@ -871,9 +868,7 @@ impl<'a, 'data> Translator<'a, 'data> {
871868
bail!("unsupported intrinsic")
872869
}
873870
wasmparser::CanonicalFunction::BackpressureSet => {
874-
let core_type = self.core_func_signature(core_func_index)?;
875-
core_func_index += 1;
876-
LocalInitializer::BackpressureSet { func: core_type }
871+
bail!("unsupported intrinsic")
877872
}
878873
wasmparser::CanonicalFunction::BackpressureInc => {
879874
let core_type = self.core_func_signature(core_func_index)?;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,6 @@ impl<'a> Inliner<'a> {
699699
));
700700
frame.funcs.push((*ty, dfg::CoreDef::Trampoline(index)));
701701
}
702-
BackpressureSet { func } => {
703-
let index = self.result.trampolines.push((
704-
*func,
705-
dfg::Trampoline::BackpressureSet {
706-
instance: frame.instance,
707-
},
708-
));
709-
frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
710-
}
711702
BackpressureInc { func } => {
712703
let index = self.result.trampolines.push((
713704
*func,

crates/test-programs/src/bin/async_backpressure_callee.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ impl Run for Component {
2020

2121
impl Backpressure for Component {
2222
fn set_backpressure(enabled: bool) {
23-
#[expect(deprecated, reason = "will replace with backpressure.inc/dec soon")]
24-
wit_bindgen::backpressure_set(enabled);
23+
if enabled {
24+
wit_bindgen::backpressure_inc();
25+
} else {
26+
wit_bindgen::backpressure_dec();
27+
}
2528
}
2629
fn inc_backpressure() {
2730
wit_bindgen::backpressure_inc();

crates/test-programs/src/bin/async_cancel_callee.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ enum State {
8080

8181
#[unsafe(export_name = "local:local/backpressure#set-backpressure")]
8282
unsafe extern "C" fn export_set_backpressure(enabled: bool) {
83-
#[expect(deprecated, reason = "will replace with backpressure.inc/dec soon")]
84-
wit_bindgen::backpressure_set(enabled);
83+
if enabled {
84+
wit_bindgen::backpressure_inc();
85+
} else {
86+
wit_bindgen::backpressure_dec();
87+
}
8588
}
8689

8790
#[unsafe(export_name = "local:local/backpressure#inc-backpressure")]

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4837,7 +4837,7 @@ impl ConcurrentState {
48374837
Ok(())
48384838
}
48394839

4840-
/// Implements the `backpressure.{set,inc,dec}` intrinsics.
4840+
/// Implements the `backpressure.{inc,dec}` intrinsics.
48414841
pub(crate) fn backpressure_modify(
48424842
&mut self,
48434843
caller_instance: RuntimeComponentInstanceIndex,

crates/wasmtime/src/runtime/vm/component/libcalls.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,6 @@ fn trap(_store: &mut dyn VMStore, _instance: Instance, code: u8) -> Result<()> {
669669
Err(wasmtime_environ::Trap::from_u8(code).unwrap().into())
670670
}
671671

672-
#[cfg(feature = "component-model-async")]
673-
fn backpressure_set(
674-
store: &mut dyn VMStore,
675-
_instance: Instance,
676-
caller_instance: u32,
677-
enabled: u32,
678-
) -> Result<()> {
679-
store.concurrent_state_mut().backpressure_modify(
680-
RuntimeComponentInstanceIndex::from_u32(caller_instance),
681-
|_| Some(if enabled != 0 { 1 } else { 0 }),
682-
)
683-
}
684-
685672
#[cfg(feature = "component-model-async")]
686673
fn backpressure_modify(
687674
store: &mut dyn VMStore,

0 commit comments

Comments
 (0)