wasmtime: Remove redundant epoch check on function entry #8853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The epoch interruption implementation caches the current deadline in a register, and avoids reloading that cache until the cached deadline has passed.
However, the first epoch check happens immediately after the cache has been populated on function entry, so there's never a reason to reload the cache at that point. It only needs to be reloaded in loops. So this commit eliminates the double-check on function entry.
When Cranelift optimizations are enabled, the alias analysis pass correctly detected that this load was redundant, and the egraph pass optimized away the
icmp
as well. However, since we don't do conditional constant propagation, the branch couldn't be optimized away. On x86 this lowered to a redundantcmp
/jae
pair of instructions in every function entry, which this commit eliminates.To keep track of what code we're generating for epoch interruptions, I've also added disas tests with a trivial infinite loop.