GH-137959: Replace shim code in jitted code with a single trampoline function. by markshannon · Pull Request #137961 · python/cpython
Conversation
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things I observed. Correct me if I'm wrong:
- This actually splits out the tier 2 interpreter from the tier 1 interpreter. Which is likely a significant saving for our tier 2 debug build time and tier 2 interpreter. Nice!
- The shim/trampoline is only compiled once lazily and reused across the whole runtime. Then reused across all JIT functions. We currently do two jumps (one into the shim/trampoline, one into the exec->jit_code). You need to lock this with a mutex in case multiple threads try to compile the shim at the same time.
If my understanding above is correct, then this is alright to me.
Some things I observed. Correct me if I'm wrong:
- This actually splits out the tier 2 interpreter from the tier 1 interpreter. Which is likely a significant saving for our tier 2 debug build time and tier 2 interpreter. Nice!
- The shim/trampoline is only compiled once lazily and reused across the whole runtime. Then reused across all JIT functions. We currently do two jumps (one into the shim/trampoline, one into the exec->jit_code). You need to lock this with a mutex in case multiple threads try to compile the shim at the same time.
If my understanding above is correct, then this is alright to me.
That is all correct. I'll add a comment explaining it.
Nice, sorry I wasn't able to review in time, but it looks mostly good (love the unification of the two JIT execution engines).
Two notes:
- I prefer the old name "shim" throughout to the new name "trampoline". Trampoline already has another meaning in the JIT compiler, and we renamed this to "shim" a while back to make the distinction clearer.
- I don't love that we leak the shim code when the runtime is finalized. We should free it in
Py_Finalizeor whatever.
This was referenced
This was referenced
This was referenced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters