-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide parent pointers in ContinuationObjects, instead of FiberStacks #7
Conversation
1e92386
to
2c2c314
Compare
Please rebase again, then I will take a look :-) thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// TODO(frank-emrich): Check if parent is null. If so, we are at | ||
// the toplevel and simply have no handler for the given tag and must trap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I suppose the pseudocode is something like
if parent is null then trap "unhandled tag"
else suspend $tag [args...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's address this once we overhaul error handling in general.
let running = unsafe { | ||
running | ||
.as_ref() | ||
.expect("Calling suspend outside of a continuation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this error should be the same as if forwarding fails, e.g ."unhandled tag"
. I don't recall the exact message, but it is in the reference interpreter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can store the suspend arguments directly on the parent continuationobject instead of mangling with the VMContext
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should generally improve error handling, in particular trapping with an appropriate error code.
Regarding storing suspend arguments in continuation objects: You are right, the fact that we now have easy access to the currently running continuation object allows us to store the suspend arguments in there. However, there are a series of efficiency trade-offs: The "global" buffer currently used for suspend arguments can be re-used between different suspends, only being re-allocated whenever it is too small to hold the necessary number of suspend arguments. It also makes the current (rather naive) implementation of effect forwarding more efficient: While buffers local to continuation objects have to be handed over from parent to child (see the cont_obj_forward_tag_return_values_buffer
builtin), this is not the case with the global payload buffer in the VMContext
.
In total, I would suggest that we continue using the "global" buffer in the VMContext
for suspend arguments for the time being, and revisit a better design once we either optimised effect forwarding or implement some kind of pooling logic for continuation objects and/or the buffers therein.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to not mangle with the VMContext
too much. I agree that it would be more inefficient in the case of forwarding, but that's only because forwarding is implemented in a particularly naive way right now. Thus I don't worry about that at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, I am not suggesting we do this refactor as part of this PR.
This reverts commit ba59803.
I'll merge this one tomorrow |
2c2c314
to
9f53b6b
Compare
9f53b6b
to
0756270
Compare
Okay, I've addressed two of your comments, let's leave the remaining two as future improvements. |
This PR:
parent
field toContinuationObject
, pointing to the parentContinuationObject
or NULL.FiberStack
to the parentFiberStack
. As a result, the assembly in thefibre
crate for dealing with stack switching is now reverted to be identical to the one from thefiber
create.These changes also lead to some refactoring of the code for
Operator::Resume
incode_translator.rs
.