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

Draft: Basic scaffolding for Closure-Passing Style #54

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

maplant
Copy link
Owner

@maplant maplant commented Jan 2, 2025

Converting our AST into a Closure-Passing Style IR is an absolute must for this project to be at all useful in any real context. Therefore, with a lot of the core functions implemented, I think now is as good of a time as any to start working on this.

The first goal should be to get CPS compiling to IR in a not-very-optimized but completely functional way. I.e., all functions are compiled, but there are no significant optimizations done on the IR, the functions always return thunks, and trampolining is done in Rust. Not exactly sure how that is going to work with async, maybe I just ignore functions that
await for now.

Poorly optimized CPS is still likely to be faster than the interpreter, and will have the added benefit of allowing continuations to be implemented mechanically, rather than manually. The goal primary goal of this branch is to eliminate the continuation.rs module entirely.

Once that is done, I will have more confidence moving forward implementing the rest of R6RS. Then the fun part - optimizing the crap out of everything.

Things to do in the process of completing this:

  • another round of alpha-conversion to get unique names for each variable ref.
  • perform escape analysis to determine which functions need closures and which do not. as a first pass, every function will be considered escaping.
  • write the conversion of AST -> CPS.
  • write the conversion of CPS + analysis -> LLVM IR.

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