Skip to content

Commit c6c1f31

Browse files
committed
Use CALL_NON_PY_GENERAL in more cases when otherwise failing to specialize
1 parent b54b271 commit c6c1f31

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Python/specialize.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
17871787
return -1;
17881788
}
17891789
if (Py_TYPE(tp) != &PyType_Type) {
1790-
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_METACLASS);
1791-
return -1;
1790+
goto generic;
17921791
}
17931792
if (tp->tp_new == PyBaseObject_Type.tp_new) {
17941793
PyFunctionObject *init = get_init_for_simple_managed_python_class(tp);
@@ -1805,10 +1804,10 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
18051804
_Py_SET_OPCODE(*instr, CALL_ALLOC_AND_ENTER_INIT);
18061805
return 0;
18071806
}
1808-
return -1;
18091807
}
1810-
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_CLASS_MUTABLE);
1811-
return -1;
1808+
generic:
1809+
instr->op.code = CALL_NON_PY_GENERAL;
1810+
return 0;
18121811
}
18131812

18141813
#ifdef Py_STATS
@@ -1899,8 +1898,8 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr,
18991898
return 0;
19001899
}
19011900
}
1902-
SPECIALIZATION_FAIL(CALL, meth_descr_call_fail_kind(descr->d_method->ml_flags));
1903-
return -1;
1901+
instr->op.code = CALL_NON_PY_GENERAL;
1902+
return 0;
19041903
}
19051904

19061905
static int
@@ -1934,7 +1933,6 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs,
19341933
}
19351934
else {
19361935
instr->op.code = bound_method ? CALL_BOUND_METHOD_GENERAL : CALL_PY_GENERAL;
1937-
return 0;
19381936
}
19391937
return 0;
19401938
}
@@ -1943,6 +1941,7 @@ static int
19431941
specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
19441942
{
19451943
if (PyCFunction_GET_FUNCTION(callable) == NULL) {
1944+
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OTHER);
19461945
return 1;
19471946
}
19481947
switch (PyCFunction_GET_FLAGS(callable) &

0 commit comments

Comments
 (0)