mirror of
https://github.com/python/cpython.git
synced 2026-04-20 02:40:59 +00:00
gh-131798: split _CALL_BUILTIN_CLASS to smaller uops (#148094)
This commit is contained in:
parent
e007631e99
commit
8f17140fc1
10 changed files with 1299 additions and 1217 deletions
|
|
@ -4570,17 +4570,20 @@ dummy_func(
|
|||
DEAD(should_be_none);
|
||||
}
|
||||
|
||||
op(_CALL_BUILTIN_CLASS, (callable, self_or_null, args[oparg] -- res)) {
|
||||
op(_GUARD_CALLABLE_BUILTIN_CLASS, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
EXIT_IF(!PyType_Check(callable_o));
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
EXIT_IF(tp->tp_vectorcall == NULL);
|
||||
}
|
||||
|
||||
op(_CALL_BUILTIN_CLASS, (callable, self_or_null, args[oparg] -- res)) {
|
||||
int total_args = oparg;
|
||||
_PyStackRef *arguments = args;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
arguments--;
|
||||
total_args++;
|
||||
}
|
||||
EXIT_IF(tp->tp_vectorcall == NULL);
|
||||
STAT_INC(CALL, hit);
|
||||
PyObject *res_o = _Py_CallBuiltinClass_StackRefSteal(
|
||||
callable,
|
||||
|
|
@ -4597,6 +4600,7 @@ dummy_func(
|
|||
_RECORD_CALLABLE +
|
||||
unused/1 +
|
||||
unused/2 +
|
||||
_GUARD_CALLABLE_BUILTIN_CLASS +
|
||||
_CALL_BUILTIN_CLASS +
|
||||
_CHECK_PERIODIC_AT_END;
|
||||
|
||||
|
|
@ -4618,8 +4622,6 @@ dummy_func(
|
|||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
args--;
|
||||
}
|
||||
// CPython promises to check all non-vectorcall function calls.
|
||||
EXIT_IF(_Py_ReachedRecursionLimit(tstate));
|
||||
STAT_INC(CALL, hit);
|
||||
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable_o);
|
||||
_PyStackRef arg = args[0];
|
||||
|
|
@ -4640,6 +4642,7 @@ dummy_func(
|
|||
unused/1 +
|
||||
unused/2 +
|
||||
_GUARD_CALLABLE_BUILTIN_O +
|
||||
_CHECK_RECURSION_LIMIT +
|
||||
_CALL_BUILTIN_O +
|
||||
POP_TOP +
|
||||
POP_TOP +
|
||||
|
|
|
|||
40
Python/executor_cases.c.h
generated
40
Python/executor_cases.c.h
generated
|
|
@ -16455,6 +16455,29 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _GUARD_CALLABLE_BUILTIN_CLASS_r00: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef callable;
|
||||
oparg = CURRENT_OPARG();
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
if (!PyType_Check(callable_o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
if (tp->tp_vectorcall == NULL) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _CALL_BUILTIN_CLASS_r01: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
|
|
@ -16466,24 +16489,12 @@
|
|||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
if (!PyType_Check(callable_o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
int total_args = oparg;
|
||||
_PyStackRef *arguments = args;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
arguments--;
|
||||
total_args++;
|
||||
}
|
||||
if (tp->tp_vectorcall == NULL) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
STAT_INC(CALL, hit);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *res_o = _Py_CallBuiltinClass_StackRefSteal(
|
||||
|
|
@ -16558,11 +16569,6 @@
|
|||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
args--;
|
||||
}
|
||||
if (_Py_ReachedRecursionLimit(tstate)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
STAT_INC(CALL, hit);
|
||||
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable_o);
|
||||
_PyStackRef arg = args[0];
|
||||
|
|
|
|||
32
Python/generated_cases.c.h
generated
32
Python/generated_cases.c.h
generated
|
|
@ -2279,10 +2279,8 @@
|
|||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_BUILTIN_CLASS
|
||||
// _GUARD_CALLABLE_BUILTIN_CLASS
|
||||
{
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
if (!PyType_Check(callable_o)) {
|
||||
|
|
@ -2291,17 +2289,22 @@
|
|||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
if (tp->tp_vectorcall == NULL) {
|
||||
UPDATE_MISS_STATS(CALL);
|
||||
assert(_PyOpcode_Deopt[opcode] == (CALL));
|
||||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
}
|
||||
// _CALL_BUILTIN_CLASS
|
||||
{
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
int total_args = oparg;
|
||||
_PyStackRef *arguments = args;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
arguments--;
|
||||
total_args++;
|
||||
}
|
||||
if (tp->tp_vectorcall == NULL) {
|
||||
UPDATE_MISS_STATS(CALL);
|
||||
assert(_PyOpcode_Deopt[opcode] == (CALL));
|
||||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
STAT_INC(CALL, hit);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *res_o = _Py_CallBuiltinClass_StackRefSteal(
|
||||
|
|
@ -2532,6 +2535,14 @@
|
|||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
}
|
||||
// _CHECK_RECURSION_LIMIT
|
||||
{
|
||||
if (_Py_ReachedRecursionLimit(tstate)) {
|
||||
UPDATE_MISS_STATS(CALL);
|
||||
assert(_PyOpcode_Deopt[opcode] == (CALL));
|
||||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
}
|
||||
// _CALL_BUILTIN_O
|
||||
{
|
||||
args = &stack_pointer[-oparg];
|
||||
|
|
@ -2539,11 +2550,6 @@
|
|||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
args--;
|
||||
}
|
||||
if (_Py_ReachedRecursionLimit(tstate)) {
|
||||
UPDATE_MISS_STATS(CALL);
|
||||
assert(_PyOpcode_Deopt[opcode] == (CALL));
|
||||
JUMP_TO_PREDICTED(CALL);
|
||||
}
|
||||
STAT_INC(CALL, hit);
|
||||
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable_o);
|
||||
_PyStackRef arg = args[0];
|
||||
|
|
|
|||
|
|
@ -1284,6 +1284,19 @@ dummy_func(void) {
|
|||
none = sym_new_const(ctx, Py_None);
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_BUILTIN_CLASS, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {
|
||||
PyObject *callable_o = sym_get_const(ctx, callable);
|
||||
if (callable_o && sym_matches_type(callable, &PyType_Type)) {
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
if (tp->tp_vectorcall != NULL) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyType_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_BUILTIN_O, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
|
||||
PyObject *callable_o = sym_get_const(ctx, callable);
|
||||
if (callable_o && sym_matches_type(callable, &PyCFunction_Type) &&
|
||||
|
|
|
|||
16
Python/optimizer_cases.c.h
generated
16
Python/optimizer_cases.c.h
generated
|
|
@ -3920,6 +3920,22 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _GUARD_CALLABLE_BUILTIN_CLASS: {
|
||||
JitOptRef callable;
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
PyObject *callable_o = sym_get_const(ctx, callable);
|
||||
if (callable_o && sym_matches_type(callable, &PyType_Type)) {
|
||||
PyTypeObject *tp = (PyTypeObject *)callable_o;
|
||||
if (tp->tp_vectorcall != NULL) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyType_Type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case _CALL_BUILTIN_CLASS: {
|
||||
JitOptRef res;
|
||||
res = sym_new_not_null(ctx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue