@@ -175,6 +175,7 @@ print_spec_stats(FILE *out, OpcodeStats *stats)
175
175
/* Mark some opcodes as specializable for stats,
176
176
* even though we don't specialize them yet. */
177
177
fprintf (out , " opcode[%d].specializable : 1\n" , FOR_ITER );
178
+ fprintf (out , " opcode[%d].specializable : 1\n" , PRECALL_FUNCTION );
178
179
fprintf (out , " opcode[%d].specializable : 1\n" , UNPACK_SEQUENCE );
179
180
for (int i = 0 ; i < 256 ; i ++ ) {
180
181
if (adaptive_opcodes [i ]) {
@@ -556,14 +557,15 @@ initial_counter_value(void) {
556
557
#define SPEC_FAIL_CALL_BAD_CALL_FLAGS 17
557
558
#define SPEC_FAIL_CALL_CLASS 18
558
559
#define SPEC_FAIL_CALL_PYTHON_CLASS 19
559
- #define SPEC_FAIL_CALL_C_METHOD_CALL 20
560
+ #define SPEC_FAIL_CALL_METHOD_DESCRIPTOR 20
560
561
#define SPEC_FAIL_CALL_BOUND_METHOD 21
561
562
#define SPEC_FAIL_CALL_STR 22
562
563
#define SPEC_FAIL_CALL_CLASS_NO_VECTORCALL 23
563
564
#define SPEC_FAIL_CALL_CLASS_MUTABLE 24
564
565
#define SPEC_FAIL_CALL_KWNAMES 25
565
566
#define SPEC_FAIL_CALL_METHOD_WRAPPER 26
566
567
#define SPEC_FAIL_CALL_OPERATOR_WRAPPER 27
568
+ #define SPEC_FAIL_CALL_PYFUNCTION 28
567
569
568
570
/* COMPARE_OP */
569
571
#define SPEC_FAIL_COMPARE_OP_DIFFERENT_TYPES 12
@@ -1651,7 +1653,13 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs,
1651
1653
static int
1652
1654
call_fail_kind (PyObject * callable )
1653
1655
{
1654
- if (PyInstanceMethod_Check (callable )) {
1656
+ if (PyCFunction_CheckExact (callable )) {
1657
+ return SPEC_FAIL_CALL_PYCFUNCTION ;
1658
+ }
1659
+ else if (PyFunction_Check (callable )) {
1660
+ return SPEC_FAIL_CALL_PYFUNCTION ;
1661
+ }
1662
+ else if (PyInstanceMethod_Check (callable )) {
1655
1663
return SPEC_FAIL_CALL_INSTANCE_METHOD ;
1656
1664
}
1657
1665
else if (PyMethod_Check (callable )) {
@@ -1662,7 +1670,15 @@ call_fail_kind(PyObject *callable)
1662
1670
return SPEC_FAIL_CALL_CMETHOD ;
1663
1671
}
1664
1672
else if (PyType_Check (callable )) {
1665
- return SPEC_FAIL_CALL_CLASS ;
1673
+ if (((PyTypeObject * )callable )-> tp_new == PyBaseObject_Type .tp_new ) {
1674
+ return SPEC_FAIL_CALL_PYTHON_CLASS ;
1675
+ }
1676
+ else {
1677
+ return SPEC_FAIL_CALL_CLASS ;
1678
+ }
1679
+ }
1680
+ else if (Py_IS_TYPE (callable , & PyMethodDescr_Type )) {
1681
+ return SPEC_FAIL_CALL_METHOD_DESCRIPTOR ;
1666
1682
}
1667
1683
else if (Py_TYPE (callable ) == & PyWrapperDescr_Type ) {
1668
1684
return SPEC_FAIL_CALL_OPERATOR_WRAPPER ;
@@ -1905,6 +1921,8 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
1905
1921
adaptive -> counter = initial_counter_value ();
1906
1922
}
1907
1923
1924
+ #ifdef Py_STATS
1925
+
1908
1926
int
1909
1927
_PySpecialization_ClassifyIterator (PyObject * iter )
1910
1928
{
@@ -1966,3 +1984,11 @@ _PySpecialization_ClassifySequence(PyObject *seq)
1966
1984
}
1967
1985
return SPEC_FAIL_OTHER ;
1968
1986
}
1987
+
1988
+ int
1989
+ _PySpecialization_ClassifyCallable (PyObject * callable )
1990
+ {
1991
+ return call_fail_kind (callable );
1992
+ }
1993
+
1994
+ #endif
0 commit comments