Interpreter: fix fiber's resumable property#14252
Merged
straight-shoota merged 6 commits intocrystal-lang:masterfrom Jan 31, 2024
Merged
Interpreter: fix fiber's resumable property#14252straight-shoota merged 6 commits intocrystal-lang:masterfrom
straight-shoota merged 6 commits intocrystal-lang:masterfrom
Conversation
Fibers in the interpreted code are backed by real fibers run by the interpreter. The fiber context is thus fake in the interpreted code, and the resumable property should directly target the real fiber's context. Also explains why we call `Fiber#resume`.
Member
beta-ziliani
left a comment
There was a problem hiding this comment.
Is it possible to have a test that should break in the current HEAD but work with this patch?
The spec fails with the interpreter for the current crystal (1.11), but succeeds with this patch (or when compiled with any older version).
straight-shoota
approved these changes
Jan 24, 2024
Collaborator
Author
|
@beta-ziliani I just added a test. It fails with the interpreter of crystal 1.11 but succeeds otherwise (this patch, or when compiled). |
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
ysbaddaden
commented
Jan 24, 2024
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
beta-ziliani
approved these changes
Jan 30, 2024
1 task
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.
The
resumableproperty of fiber contexts was wrong in interpreted code: it was never reset to0.This patch lets the interpreted fiber read the resumable property of the interpreter's fiber (the real one) though a new primitive. The interpreter is now responsible from reporting the value properly. This avoids having to manipulate
resumablein the interpreted code, and allows to act on the actual state.Alternative: the interpreter could set the
resumableproperties of the fibers in theinterpreter_swapcontextprimitive, it would be fake but probably not critical (the interpreter's scheduler would still act on the real property), but we don't have references back into the interpreted fibers (we could add it when interpreted) + I don't know how the interpreter updates values into an interpreted type (I could learn).