Skip to content
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

Implement return prioritization (2nd try) #1788

Closed
wants to merge 1 commit into from

Conversation

patrickbkr
Copy link
Member

In general, if a &return was called in a routine, we don't want any other code in exit handlers to interfere with that return from returning.

It's possible for exit handlers to escape normal control flow (e.g. via a &return). In that case instead of reaching the handler the unwind targets, we would return to the frame's return_address. To make things right, we tune the unwind target frame's return address to point to the handler. Also set that frames RETURNING flag and preserve the return value, getlexpayload can then pick it up again.

JIT implementation of lastexpayload is TBD.

Related to Raku/problem-solving#417

patrickbkr pushed a commit to patrickbkr/roast that referenced this pull request Jan 27, 2024
@patrickbkr patrickbkr force-pushed the return-prioritization2 branch from 86f74c4 to 6b5ac9a Compare January 27, 2024 16:58
@patrickbkr
Copy link
Member Author

I now have the JIT bits in place as well. I still fail to test it though (as in, I haven't managed to produce a test case that fails with the JIT bits left out).

In general, if a &return was called in a routine, we don't want any other
code in exit handlers to interfere with that return from returning.

It's possible for exit handlers to escape normal control flow (e.g. via a
&return). In that case instead of reaching the handler the unwind targets,
we would return to the frame's return_address. To make things right, we
tune the unwind target frame's return address to point to the handler.
Also set that frames RETURNING flag and preserve the return value,
getlexpayload can then pick it up again.

Related to Raku/problem-solving#417
@patrickbkr patrickbkr force-pushed the return-prioritization2 branch from 6b5ac9a to ce022a1 Compare February 15, 2024 20:58
patrickbkr pushed a commit to patrickbkr/roast that referenced this pull request May 21, 2024
@patrickbkr patrickbkr marked this pull request as ready for review May 26, 2024 19:51
patrickbkr pushed a commit to patrickbkr/roast that referenced this pull request May 28, 2024
@patrickbkr patrickbkr marked this pull request as draft May 28, 2024 21:38
@patrickbkr
Copy link
Member Author

I just found a case where this implementation fails. Thus this PR is draft again.
The return value of the original unwind is preserved, but the hijacking of the unwind via a &return inside a LEAVE still happens.
I have extended the tests in Raku/roast#851 respectively, which this PR thus fails.

@patrickbkr
Copy link
Member Author

Superseded by #1812

@patrickbkr patrickbkr closed this Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant