A Tail of TwoTails: The Second Act
summary
TwoTails is a Scala compiler plugin that implements mutual tail recursion without trampolines by transforming mutually recursive methods into a single loop-based implementation. The first scheme inlines method bodies and hits the JVM method size limit (64KB) and JIT loss; the second scheme captures arguments into vars and emits a while loop to avoid huge methods at the cost of more complex transformations and extra allocations. Snapshot lacks by-name parameter support, offers options to favor smaller methods or fewer allocations, and is used in production—bug reports welcome.
AI-written summary · about
chapters (6)
- 0:00Start
- 1:19Overview
- 1:38Tail Recursion
- 2:10Neutral Tail Recursion
- 9:58Jvm Method Size Limit
- 13:34Compilation Options
related talks
37mTCO
51mHands-on Typelevel Scala
35mScala 2.12 & Beyond
30mTail Modulo Async/Await
40mJoy of Meta-Tracing Just-in-Time Compilation: More Than Just a VM Generator
45mFuture proofing Scala the TASTY intermediate rep
44mScala 2.12 & Java 8: More Fun Together!
36mHow does Incremental Compilation Work with Scala 3
