Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancement
Description
For AArch64 emit__GUARD_IS_TRUE_POP produces the following assembly code:
...
14: 54000041 b.ne 0x1c <_JIT_ENTRY+0x1c>
18: 14000002 b 0x20 <_JIT_ENTRY+0x20>
1c: 14000000 b 0x1c <_JIT_ENTRY+0x1c>
000000000000001c: R_AARCH64_JUMP26 _JIT_JUMP_TARGET
but it should, ideally, emit this:
14: 54000041 b.ne 0x14 <_JIT_ENTRY+0x14>
000000000000001c: R_AARCH64_CONDBR19 _JIT_JUMP_TARGET
This doesn't seem to be an issue for x86, possibly due to the way Clang is setup for AArch64, possibly just an artefact of llvm's code gen.
Either way, rather than rely on llvm eliminating these jumps we can do it in the JIT builder's assembly optimizer.
Currently we don't perform jump fusion, but it would be easy enough to do so.
Linked PRs
- GH-139757: JIT: Remove redundant branches to jumps in the assembly optimizer #140800
- gh-139757: Treat call specially in JIT assembly backend optimizer on x86-64 and AArch64 #142907
- gh-139757: Add _GUARD_NOS_COMPACT_ASCII for compact ascii optimization #143332
- gh-139757: Fix unintended bytecode specialization for non-ascii string #143352
- gh-139757: Add BINARY_OP_SUBSCR_USTR_INT #143389
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancement
Activity
GH-139757: Fix reference leaks introduced in GH-140800 (GH-142257)
pythonGH-139757: Fix reference leaks introduced in pythonGH-140800 (p…
GH-139757: JIT: Remove redundant branches to jumps in the assembly op…
Fidget-Spinner commentedon Dec 17, 2025
The introduction of
_remove_unreachablebroke the JIT + FT builds on x86-64.I get this error:
Commenting it out fixes it.
Fidget-Spinner commentedon Dec 17, 2025
Alright, I narrowed it down: for some stencils, there are more than one entry points, e.g. if
PyStackRef_CLOSEis outlined, then a stencil may have two entry points (one _JIT_ENTRY, one PyStackRef_CLOSE).The problem with that is that we don't treat
call PyStackRef_CLOSEas a jump to a live block. So this optimization breaks.A possible fix is to just treat all function entries as live.
gh-139757: Treat call specially in JIT assembly backend optimizer on …
pythongh-139757: Add _GUARD_NOS_COMPACT_ASCII for compact ascii optim…
Merge remote-tracking branch 'upstream/main' into pythongh-139757-gua…
gh-139757: Add _GUARD_NOS_COMPACT_ASCII for compact ascii optimization (
pythongh-139757: Fix unintended BINARY_OP_SUBSCR_STR_INT for non-ASCII
gh-139757: Fix unintended bytecode specialization for non-ascii string (
gh-139757: Add BINARY_OP_SUBSCR_USTR_INT (GH-143389)
pythongh-139757: Add _GUARD_NOS_COMPACT_ASCII for compact ascii optim…
pythongh-139757: Fix unintended bytecode specialization for non-ascii…
pythongh-139757: Add BINARY_OP_SUBSCR_USTR_INT (pythonGH-143389)
markshannon commentedon Mar 23, 2026
I think this is done