ctiller opened PR #14644 from ctiller:fix/stack-switching-fuel to bytecodealliance:main:
When
consume_fuelis enabled,FuncEnvironmentcaches the in-flight fuel counter in a function-local Cranelift SSAVariable(self.fuel_var) and synchronizes it withVMStoreContext::fuel_consumedacross calls, returns, and exception handlers.Previously, stack-switching instructions (
resume,resume_throw,resume_throw_ref,suspend, andswitch) did not flush/saveself.fuel_varbefore switching stacks or reloadself.fuel_varupon returning or resuming, andtranslate_resume_impldid not reloadself.fuel_varat the entry ofsuspend_blockbefore dispatching to(on $tag $label)handler blocks. As a result, fuel consumed inside a continuation was overwritten whenever control switched back to the parent or target stack.Save
self.fuel_varinfuel_before_opprior toresume*,suspend, andswitch, reloadself.fuel_varinfuel_after_opon normal return/wake-up, and callenv.on_catch_block_entry(builder)at the start ofsuspend_block.Assisted-by: Gemini
ctiller requested cfallin for a review on PR #14644.
ctiller requested wasmtime-compiler-reviewers for a review on PR #14644.
ctiller requested wasmtime-core-reviewers for a review on PR #14644.
ctiller updated PR #14644.
:thumbs_up: cfallin submitted PR review.
cfallin added PR #14644 cranelift: preserve fuel across stack-switching instructions to the merge queue.
github-merge-queue[bot] removed PR #14644 cranelift: preserve fuel across stack-switching instructions from the merge queue.
Last updated: Oct 11 2026 at 04:10 UTC