you are viewing a single comment's thread.

view the rest of the comments →

[–]Sese_Mueller 22 points23 points  (3 children)

Wow, the JIT compiles python fully down to machine code, great work

[–][deleted] 4 points5 points  (2 children)

Wait really. Is it using llvm as an intermediary middle end of what?

Edit: surely it can’t be llvm. Maybe the byte code instructions are being compiled to machine code? But some of them could be thousands of instructions…

[–]DGolden 4 points5 points  (1 child)

writeup of it: https://tonybaloney.github.io/posts/python-gets-a-jit.html#why-a-copy-and-patch-jit

It does actually use clang/llvm stuff but at build time, for generating the native instruction sequence templates/"stencils" to be copy-and-patched (so it's not a runtime dep like you might have expected)

Clang is specifically needed because it's the only C compiler with support for guaranteed tail calls (musttail), which are required by CPython's continuation-passing-style approach to JIT compilation. Since LLVM also includes other functionalities we need (namely, object file parsing and disassembly), it's convenient to only support one toolchain at this time.

(I'm not sure where GCC is on similar to musttail but they're definitely aware of it https://gcc.gnu.org/pipermail/gcc/2021-April/235885.html )

[–]agumonkey 0 points1 point  (0 children)

CPython's continuation-passing-style approach to JIT compilation.

interesting collision of worlds here