Jank now has its own custom IR

· coding · Source ↗

TLDR

  • Jank, a Clojure dialect targeting native via LLVM, added a custom SSA-based IR to enable Clojure-semantic optimizations, cutting fibonacci runtime from 5,522ms toward JVM’s 200ms.

Key Takeaways

  • The new IR operates at Clojure’s semantic level (var derefs, dynamic calls, persistent data structures) rather than LLVM IR’s low-level primitives, enabling higher-level optimization passes.
  • IR is SSA-based and CFG-structured, stored as C++ data structures but renderable to Clojure EDN for debugging; no round-trip serialization yet.
  • Before IR optimizations, jank took 5,522ms on (fibonacci 35) vs Clojure JVM’s 200ms on OpenJDK 21 – a 27x gap the IR pipeline is designed to close.
  • First optimization target is inlining arithmetic: Clojure JVM inlines math via metadata; jank is reimplementing this properly after removing a prior hacky solution.
  • The IR took six weeks to design and implement, replacing AST-based C++ codegen; no optimization passes run yet – the merge prioritized pipeline stability over optimization depth.

Hacker News Comment Review

  • No substantive HN discussion yet.

Original | Discuss on HN