Skip to content

Conversation

@CAG2Mark
Copy link
Contributor

@CAG2Mark CAG2Mark commented Dec 1, 2025

Implements tail recursion optimization. Also changed the lifter, handler lowering, and while loop rewriter to properly propagate functions' TermSymbols into calls.

Note that the lifter has been modified so only disambiguated references to BMS's are rewritten. This should not be a problem as all references to nested functions should be disambiguated. However, it may cause errors if passes before the lifter forget to propagate the disamb symbols.

Things that are not yet done:

  • Spread arguments in calls. Currently only supported when the spread arg is in the last position and the last argument of the target function is a spread.
  • Class methods are not yet optimized as they cannot yet be marked final.
  • In objects and modules, calls to functions with no parameter list are represented using Selections

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Awesome! I'm very excited to have this in, as it's a first step towars our eventual goal of KICE (Know In-order Call Elimination).

@CAG2Mark
Copy link
Contributor Author

CAG2Mark commented Dec 2, 2025

When did we establish this KICE name? 🤔

@LPTK
Copy link
Contributor

LPTK commented Dec 2, 2025

When did we establish this KICE name? 🤔

Just now 😎

@CAG2Mark CAG2Mark requested a review from LPTK December 5, 2025 10:32
@CAG2Mark
Copy link
Contributor Author

CAG2Mark commented Dec 5, 2025

OK, turns out I didn't recompile some of the other stuff. Please wait

EDIT: Should be good now

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Ok, I think this is almost ready to merge. But let's try to not create useless while loops (see comment below)!

@CAG2Mark
Copy link
Contributor Author

CAG2Mark commented Dec 5, 2025

Done

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Ok, LGTM now, thanks!

@LPTK LPTK merged commit 1f0b864 into hkust-taco:hkmc2 Dec 6, 2025
1 check passed
@LPTK LPTK deleted the tailrec branch December 6, 2025 07:26
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