Pyston: a Python JIT on LLVM

Hi all,

I’ve been lurking on the list for a bit, and I’m excited to finally talk about what I’m working on: Pyston, a JIT for Python. It’s still extremely early on, but I’m happy that I can open source the code for viewing and discussion.

It contains experimental but working implementations of a few things that I thought might be interesting to the community; they are certainly not production-quality implementations, but I hope they can be at least a data point for people interested in the functionality:

  • It contains a working cross-module inliner, which can be necessary for doing inlining with MCJIT.
  • It has a build system that allows compiling a runtime file both into the JIT itself, as well as into the stdlib bitcode file for inlining into JIT’d code.
  • It contains a working inline cache system that uses the llvm.experimental.patchpoint() intrinsic. It also has some new support for using the PreserveAll calling convention so that the inline cache fastpaths can often avoid spilling registers.
  • It has a few optimization passes that are optimized for Pyston, but could be applicable to other dynamic languages; in particular it has an escape analysis for GC’d memory that helps lower GC’d memory to registers if the variable is local (something that is probably rare in static languages, but very common in Python).
  • Some perf debugging tools, ex for getting instruction-level profiles of JIT’d code.

There’s still a very, very long way to go for Pyston, but it couldn’t have even started without LLVM, so I hope I can give something back!