Remove cancellable immediate from built-ins, relax subtask.cancel switching rules - #716
Open
lukewagner wants to merge 1 commit into
Open
Remove cancellable immediate from built-ins, relax subtask.cancel switching rules#716lukewagner wants to merge 1 commit into
cancellable immediate from built-ins, relax subtask.cancel switching rules#716lukewagner wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, the
cancellableimmediates of thethread.*andwaitable-set.*built-ins aren't emitted by producer toolchains. Also, although not released yet, the currently-specified/implemented behavior of the newthread.{suspend,yield}-then-{resume,promote}built-ins is a bit broken (the single1return code conflates 3 different cases guest code probably needs to distinguish: cancelled-before-switch, resumed-because-cancelled, cancelled-after-readied). Rather than fix/test these un-exercised paths, I think it'd be better to just removecancellablefor now and add it back once we need it to enable the "stackful" async ABI (🚟). (I'm also starting to think, when we do need to re-add it, there may be a better design than acancellableimmediate.)To avoid breaking any existing code (none of which uses
cancellable), the PR removescancellablefrom the text format, but keeps thecancellableimmediate in the binary format and just requires it to always be0.Lastly, this PR relaxes the rules for how
subtask.cancelresumes the cancelled callee: instead of forcing at-most-1 switch from caller-to-callee-to-caller, the PR replaces this with a plainthread.yieldwhich allows the host to nondeterministically switch to whoever before determining thatsubtask.cancelblocked. This allows the host to do smarter scheduling (in a way that matches what we allow elsewhere) but also, combined withcancellable-removal, significantly simplifies the rules for cancellation, making them rather easier to understand IMO. See CanonicalABI.md#-canon-subtaskcancel for more details.The PR updates the tests to not use the
cancellablecancellable immediate or expect the relaxed behavior ofsubtask.cancel, all of which passes on Wasmtime today. The only new test that fails in this PR is the simple binary validation tests intest/binary/binary.wast.