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

Fix dup/drop inference pass #104

Merged
merged 43 commits into from
Aug 25, 2022
Merged

Fix dup/drop inference pass #104

merged 43 commits into from
Aug 25, 2022

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented Aug 25, 2022

No description provided.

sedwards-lab and others added 30 commits August 19, 2022 19:45
…e multi-argument function. pause1 example only leaking myevent now
@j-hui j-hui marked this pull request as ready for review August 25, 2022 22:30
@j-hui
Copy link
Contributor Author

j-hui commented Aug 25, 2022

This PR completes work started by Yiming to fix the insertion of ref counting primitives. It turns out, several bigger changes were needed to stick strictly with caller-dup/callee-drop and get things working completely. In particular, we realized that:

  • Variables almost always need to be duped whenever they are referenced
  • Primitives also need to abide by the callee-drop part of our paradigm, so I insert additional drop calls in the codegen phase to reflect this.
  • Intermediate closure values were leaking for a little while. To fix that, we insisted on dropping intermediate values aggressively at the codegen phase.

In the updated compilation pass, pattern matches are the one exception to the dup-every-var rule, because we essentially elided the drop from after the match with the dup from before it.

To make dups and drops easier to insert and reason with, they are now functional rather than sequential; dups now behave as identity functions that have the side effect of incrementing the reference count of its argument, while drops are now scoped, so drop e x will evaluate e, then drop x.

This PR now enables reference counting by default.

Note that there's still an issue with newnew1, flagged in #105

@j-hui j-hui merged commit 027826d into main Aug 25, 2022
@j-hui j-hui deleted the dup-drop branch August 25, 2022 23:17
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.

2 participants