Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Remove support for `backpressure.set` (#12130)

Alex Crichton7dc07b3b30b7
diff --git a/crates/cranelift/src/compiler/component.rs b/crates/cranelift/src/compiler/component.rs
index 29ec6441e8..707e2cd7b7 100644
--- a/crates/cranelift/src/compiler/component.rs
+++ b/crates/cranelift/src/compiler/component.rs
@@ -204,16 +204,6 @@ impl<'a> TrampolineCompiler<'a> {
Trampoline::ResourceDrop { instance, ty } => {
self.translate_resource_drop(*instance, *ty);
}
- Trampoline::BackpressureSet { instance } => {
- self.translate_libcall(
- host::backpressure_set,
- TrapSentinel::Falsy,
- WasmArgs::InRegisters,
- |me, params| {
- params.push(me.index_value(*instance));
- },
- );
- }
Trampoline::BackpressureInc { instance } => {
self.translate_libcall(
host::backpressure_modify,
diff --git a/crates/environ/src/component.rs b/crates/environ/src/component.rs
index 0eed0d14ad..9b97c8b179 100644
--- a/crates/environ/src/component.rs
+++ b/crates/environ/src/component.rs
@@ -99,8 +99,6 @@ macro_rules! foreach_builtin_component_function {
resource_enter_call(vmctx: vmctx);
resource_exit_call(vmctx: vmctx) -> bool;
- #[cfg(feature = "component-model-async")]
- backpressure_set(vmctx: vmctx, caller_instance: u32, enabled: u32) -> bool;
#[cfg(feature = "component-model-async")]
backpressure_modify(vmctx: vmctx, caller_instance: u32, increment: u8) -> bool;
#[cfg(feature = "component-model-async")]
diff --git a/crates/environ/src/component/dfg.rs b/crates/environ/src/component/dfg.rs
index 30f87358af..7e1e89a64e 100644
--- a/crates/environ/src/component/dfg.rs
+++ b/crates/environ/src/component/dfg.rs
@@ -338,9 +338,6 @@ pub enum Trampoline {
instance: RuntimeComponentInstanceIndex,
ty: TypeResourceTableIndex,
},
- BackpressureSet {
- instance: RuntimeComponentInstanceIndex,
- },
BackpressureInc {
instance: RuntimeComponentInstanceIndex,
},
@@ -959,9 +956,6 @@ impl LinearizeDfg<'_> {
instance: *instance,
ty: *ty,
},
- Trampoline::BackpressureSet { instance } => info::Trampoline::BackpressureSet {
- instance: *instance,
- },
Trampoline::BackpressureInc { instance } => info::Trampoline::BackpressureInc {
instance: *instance,
},
diff --git a/crates/environ/src/component/info.rs b/crates/environ/src/component/info.rs
index b2254ae48d..5805e91b44 100644
--- a/crates/environ/src/component/info.rs
+++ b/crates/environ/src/component/info.rs
@@ -759,13 +759,6 @@ pub enum Trampoline {
ty: TypeResourceTableIndex,
},
- /// A `backpressure.set` intrinsic, which tells the host to enable or
- /// disable backpressure for the caller's instance.
- BackpressureSet {
- /// The specific component instance which is calling the intrinsic.
- instance: RuntimeComponentInstanceIndex,
- },
-
/// A `backpressure.inc` intrinsic.
BackpressureInc {
/// The specific component instance which is calling the intrinsic.
@@ -1206,7 +1199,6 @@ impl Trampoline {
ResourceNew { ty, .. } => format!("component-resource-new[{}]", ty.as_u32()),
ResourceRep { ty, .. } => format!("component-resource-rep[{}]", ty.as_u32()),
ResourceDrop { ty, .. } => format!("component-resource-drop[{}]", ty.as_u32()),
- BackpressureSet { .. } => format!("backpressure-set"),
BackpressureInc { .. } => format!("backpressure-inc"),
BackpressureDec { .. } => format!("backpressure-dec"),
TaskReturn { .. } => format!("task-return"),
diff --git a/crates/environ/src/component/translate.rs b/crates/environ/src/component/translate.rs
index 19d605634e..ed0a953ad7 100644
--- a/crates/environ/src/component/translate.rs
+++ b/crates/environ/src/component/translate.rs
@@ -199,9 +199,6 @@ enum LocalInitializer<'data> {
ResourceRep(AliasableResourceId, ModuleInternedTypeIndex),
ResourceDrop(AliasableResourceId, ModuleInternedTypeIndex),
- BackpressureSet {
- func: ModuleInternedTypeIndex,
- },
BackpressureInc {
func: ModuleInternedTypeIndex,
},
@@ -871,9 +868,7 @@ impl<'a, 'data> Translator<'a, 'data> {
bail!("unsupported intrinsic")
}
wasmparser::CanonicalFunction::BackpressureSet => {
- let core_type = self.core_func_signature(core_func_index)?;
- core_func_index += 1;
- LocalInitializer::BackpressureSet { func: core_type }
+ bail!("unsupported intrinsic")
}
wasmparser::CanonicalFunction::BackpressureInc => {
let core_type = self.core_func_signature(core_func_index)?;
diff --git a/crates/environ/src/component/translate/inline.rs b/crates/environ/src/component/translate/inline.rs
index 5b78fe7e3e..badbfd8e8d 100644
--- a/crates/environ/src/component/translate/inline.rs
+++ b/crates/environ/src/component/translate/inline.rs
@@ -699,15 +699,6 @@ impl<'a> Inliner<'a> {
));
frame.funcs.push((*ty, dfg::CoreDef::Trampoline(index)));
}
- BackpressureSet { func } => {
- let index = self.result.trampolines.push((
- *func,
- dfg::Trampoline::BackpressureSet {
- instance: frame.instance,
- },
- ));
- frame.funcs.push((*func, dfg::CoreDef::Trampoline(index)));
- }
BackpressureInc { func } => {
let index = self.result.trampolines.push((
*func,
diff --git a/crates/test-programs/src/bin/async_backpressure_callee.rs b/crates/test-programs/src/bin/async_backpressure_callee.rs
index 6dab442f5e..7f89a67d77 100644
--- a/crates/test-programs/src/bin/async_backpressure_callee.rs
+++ b/crates/test-programs/src/bin/async_backpressure_callee.rs
@@ -20,8 +20,11 @@ impl Run for Component {
impl Backpressure for Component {
fn set_backpressure(enabled: bool) {
- #[expect(deprecated, reason = "will replace with backpressure.inc/dec soon")]
- wit_bindgen::backpressure_set(enabled);
+ if enabled {
+ wit_bindgen::backpressure_inc();
+ } else {
+ wit_bindgen::backpressure_dec();
+ }
}
fn inc_backpressure() {
wit_bindgen::backpressure_inc();
diff --git a/crates/test-programs/src/bin/async_cancel_callee.rs b/crates/test-programs/src/bin/async_cancel_callee.rs
index 419124d927..f78d4c7b7a 100644
--- a/crates/test-programs/src/bin/async_cancel_callee.rs
+++ b/crates/test-programs/src/bin/async_cancel_callee.rs
@@ -80,8 +80,11 @@ enum State {
#[unsafe(export_name = "local:local/backpressure#set-backpressure")]
unsafe extern "C" fn export_set_backpressure(enabled: bool) {
- #[expect(deprecated, reason = "will replace with backpressure.inc/dec soon")]
- wit_bindgen::backpressure_set(enabled);
+ if enabled {
+ wit_bindgen::backpressure_inc();
+ } else {
+ wit_bindgen::backpressure_dec();
+ }
}
#[unsafe(export_name = "local:local/backpressure#inc-backpressure")]
diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs
index 1e93a4d138..b028e12b41 100644
--- a/crates/wasmtime/src/runtime/component/concurrent.rs
+++ b/crates/wasmtime/src/runtime/component/concurrent.rs
@@ -4837,7 +4837,7 @@ impl ConcurrentState {
Ok(())
}
- /// Implements the `backpressure.{set,inc,dec}` intrinsics.
+ /// Implements the `backpressure.{inc,dec}` intrinsics.
pub(crate) fn backpressure_modify(
&mut self,
caller_instance: RuntimeComponentInstanceIndex,
diff --git a/crates/wasmtime/src/runtime/vm/component/libcalls.rs b/crates/wasmtime/src/runtime/vm/component/libcalls.rs
index 41976d6a67..02f21b5833 100644
--- a/crates/wasmtime/src/runtime/vm/component/libcalls.rs
+++ b/crates/wasmtime/src/runtime/vm/component/libcalls.rs
@@ -669,19 +669,6 @@ fn trap(_store: &mut dyn VMStore, _instance: Instance, code: u8) -> Result<()> {
Err(wasmtime_environ::Trap::from_u8(code).unwrap().into())
}
-#[cfg(feature = "component-model-async")]
-fn backpressure_set(
- store: &mut dyn VMStore,
- _instance: Instance,
- caller_instance: u32,
- enabled: u32,
-) -> Result<()> {
- store.concurrent_state_mut().backpressure_modify(
- RuntimeComponentInstanceIndex::from_u32(caller_instance),
- |_| Some(if enabled != 0 { 1 } else { 0 }),
- )
-}
-
#[cfg(feature = "component-model-async")]
fn backpressure_modify(
store: &mut dyn VMStore,
diff --git a/tests/misc_testsuite/component-model/async/task-builtins.wast b/tests/misc_testsuite/component-model/async/task-builtins.wast
index 3420f4c912..93a74011d8 100644
--- a/tests/misc_testsuite/component-model/async/task-builtins.wast
+++ b/tests/misc_testsuite/component-model/async/task-builtins.wast
@@ -1,14 +1,5 @@
;;! component_model_async = true
-;; backpressure.set
-(component
- (core module $m
- (import "" "backpressure.set" (func $backpressure-set (param i32)))
- )
- (core func $backpressure-set (canon backpressure.set))
- (core instance $i (instantiate $m (with "" (instance (export "backpressure.set" (func $backpressure-set))))))
-)
-
;; backpressure.inc
(component
(core module $m