mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
GH-131798: Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW (GH-134268)
This commit is contained in:
parent
1fbb0603a8
commit
a7f317d730
8 changed files with 121 additions and 53 deletions
|
@ -5342,6 +5342,15 @@ dummy_func(
|
|||
value = PyStackRef_FromPyObjectImmortal(ptr);
|
||||
}
|
||||
|
||||
tier2 pure op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop1, pop2 -- value)) {
|
||||
PyStackRef_CLOSE(pop2);
|
||||
PyStackRef_CLOSE(pop1);
|
||||
(void)null; // Silence compiler warnings about unused variables
|
||||
DEAD(null);
|
||||
PyStackRef_CLOSE(callable);
|
||||
value = PyStackRef_FromPyObjectImmortal(ptr);
|
||||
}
|
||||
|
||||
tier2 op(_CHECK_FUNCTION, (func_version/2 -- )) {
|
||||
assert(PyStackRef_FunctionCheck(frame->f_funcobj));
|
||||
PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
|
||||
|
|
34
Python/executor_cases.c.h
generated
34
Python/executor_cases.c.h
generated
|
@ -7103,6 +7103,40 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW: {
|
||||
_PyStackRef pop2;
|
||||
_PyStackRef pop1;
|
||||
_PyStackRef null;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef value;
|
||||
pop2 = stack_pointer[-1];
|
||||
pop1 = stack_pointer[-2];
|
||||
null = stack_pointer[-3];
|
||||
callable = stack_pointer[-4];
|
||||
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);
|
||||
(void)null;
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(callable);
|
||||
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));
|
||||
|
|
|
@ -550,6 +550,10 @@ dummy_func(void) {
|
|||
value = sym_new_const(ctx, ptr);
|
||||
}
|
||||
|
||||
op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, unused, unused -- value)) {
|
||||
value = sym_new_const(ctx, ptr);
|
||||
}
|
||||
|
||||
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
|
||||
assert(oparg > 0);
|
||||
top = bottom;
|
||||
|
@ -901,12 +905,12 @@ dummy_func(void) {
|
|||
// known types, meaning we can deduce either True or False
|
||||
|
||||
// The below check is equivalent to PyObject_TypeCheck(inst, cls)
|
||||
PyObject *out = Py_False;
|
||||
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
|
||||
sym_set_const(res, Py_True);
|
||||
}
|
||||
else {
|
||||
sym_set_const(res, Py_False);
|
||||
out = Py_True;
|
||||
}
|
||||
sym_set_const(res, out);
|
||||
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
18
Python/optimizer_cases.c.h
generated
18
Python/optimizer_cases.c.h
generated
|
@ -2143,12 +2143,12 @@
|
|||
PyTypeObject *inst_type = sym_get_type(instance);
|
||||
PyTypeObject *cls_o = (PyTypeObject *)sym_get_const(ctx, cls);
|
||||
if (inst_type && cls_o && sym_matches_type(cls, &PyType_Type)) {
|
||||
PyObject *out = Py_False;
|
||||
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
|
||||
sym_set_const(res, Py_True);
|
||||
}
|
||||
else {
|
||||
sym_set_const(res, Py_False);
|
||||
out = Py_True;
|
||||
}
|
||||
sym_set_const(res, out);
|
||||
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
|
||||
}
|
||||
stack_pointer[-4] = res;
|
||||
stack_pointer += -3;
|
||||
|
@ -2556,6 +2556,16 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW: {
|
||||
JitOptSymbol *value;
|
||||
PyObject *ptr = (PyObject *)this_instr->operand0;
|
||||
value = sym_new_const(ctx, ptr);
|
||||
stack_pointer[-4] = value;
|
||||
stack_pointer += -3;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _CHECK_FUNCTION: {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue