Copy and patch?
Copy and patch?
Posted Feb 27, 2025 9:37 UTC (Thu) by anton (subscriber, #25547)In reply to: Copy and patch? by nickodell
Parent article: Python interpreter adds tail calls
There is no copying, no patching, and no native-code (JIT) compiler. The CPython bytecode interpreter with this change is still something that everyone would call an interpreter.
The paper on copy-and-patch compilation also works with code snippets that, in the C source code, are functions with tail-calls, but in many cases the tail-calls are not among the copied code. IIRC it also works with clang and the GHC calling convention.
Posted Feb 27, 2025 13:40 UTC (Thu)
by daroc (editor, #160859)
[Link] (1 responses)
Posted Feb 27, 2025 15:33 UTC (Thu)
by nickodell (subscriber, #125165)
[Link]
The new JIT uses the same musttail + preserve_none trick to avoid generating function prologues and epilogues, yes. The stencil files it makes leave out the actual jumps, though, and instead just concatenate the different bytecode implementations directly, to make a big run of straight-line code. (Which is more friendly to the CPU than making indirect jumps)
That's actually why the new JIT had clang as a build requirement — at the time, it didn't work on GCC yet because they were still implementing the needed support. Now that GCC has, though, the build-time dependency on clang might go away again.
Copy and patch?
Copy and patch?