Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Naive effect forwarding #57

Merged
merged 14 commits into from
Aug 31, 2023

Conversation

frank-emrich
Copy link

This PR implements naive effect forwarding:

When generating code for resume, we ensure that when asked to handle an effect not considered by the resume instruction under consideration, we simply suspend and let our own parent handle the unknown effect. Once resuming from that we use a back edge to the code that invokes resume on the current fiber (i.e., after moving up in the handler chain to find a handler, we move down in the chain back to where the original suspend of the unknown effect happened).

Payloads are handled as follows:

  1. When moving "up", we don't need to consider payloads: They are stored in the "payload buffer" of the VMContext and left untouched while moving upwards in the handler chain until the right handler is found and accesses the data.
  2. When moving down, we need to deal with the "tag return payloads" that were provided via resume or cont.bind further up in the chain. These payloads are stored in continuation objects directly. Before resuming into our own child, we thus swap the payload pointers of the current continuation object and the child.

@frank-emrich frank-emrich requested a review from dhil August 19, 2023 20:06
Copy link

@dhil dhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dhil dhil merged commit 7825da3 into effect-handlers:typed-continuations Aug 31, 2023
4 checks passed
@frank-emrich frank-emrich deleted the forwarding branch October 24, 2023 13:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants