GH-139757: JIT: Remove redundant branches to jumps in the assembly optimizer (GH-140800)

JIT: Remove redundant branches to jump in the assembly optimizer

* Refactor JIT assembly optimizer making instructions instances not just strings
* Remove redundant jumps and branches where legal to do so
* Modifies _BINARY_OP_SUBSCR_STR_INT to avoid excessive inlining depth
This commit is contained in:
Mark Shannon 2025-12-08 17:57:11 +00:00 committed by GitHub
parent 37988c57ea
commit e0451ceef8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 220 additions and 74 deletions

View file

@ -1502,11 +1502,12 @@
UOP_STAT_INC(uopcode, miss);
JUMP_TO_JUMP_TARGET();
}
Py_UCS4 c = PyUnicode_READ_CHAR(str, index);
if (Py_ARRAY_LENGTH(_Py_SINGLETON(strings).ascii) <= c) {
if (!PyUnicode_IS_COMPACT_ASCII(str)) {
UOP_STAT_INC(uopcode, miss);
JUMP_TO_JUMP_TARGET();
}
uint8_t c = PyUnicode_1BYTE_DATA(str)[index];
assert(c < 128);
STAT_INC(BINARY_OP, hit);
PyObject *res_o = (PyObject*)&_Py_SINGLETON(strings).ascii[c];
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);