GH-130415: Optimize constant comparison in JIT builds (GH-131489)

This commit is contained in:
Savannah Ostrowski 2025-03-21 11:23:12 -07:00 committed by GitHub
parent 0de5e0c544
commit b92ee14b80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 142 additions and 35 deletions

View file

@ -6925,6 +6925,30 @@
break;
}
case _POP_TWO_LOAD_CONST_INLINE_BORROW: {
_PyStackRef pop2;
_PyStackRef pop1;
_PyStackRef value;
pop2 = stack_pointer[-1];
pop1 = stack_pointer[-2];
PyObject *ptr = (PyObject *)CURRENT_OPERAND0();
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
PyStackRef_CLOSE(pop2);
stack_pointer = _PyFrame_GetStackPointer(frame);
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
_PyFrame_SetStackPointer(frame, stack_pointer);
PyStackRef_CLOSE(pop1);
stack_pointer = _PyFrame_GetStackPointer(frame);
value = PyStackRef_FromPyObjectImmortal(ptr);
stack_pointer[0] = value;
stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
break;
}
case _CHECK_FUNCTION: {
uint32_t func_version = (uint32_t)CURRENT_OPERAND0();
assert(PyStackRef_FunctionCheck(frame->f_funcobj));