Skip to content

Commit e43ac58

Browse files
committed
add specialization failure kind stats
1 parent 1f48300 commit e43ac58

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Python/specialize.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, PyObject *consts,
581581
#define SPEC_FAIL_BINARY_OP_TRUE_DIVIDE_FLOAT 26
582582
#define SPEC_FAIL_BINARY_OP_TRUE_DIVIDE_OTHER 27
583583
#define SPEC_FAIL_BINARY_OP_XOR 28
584+
#define SPEC_FAIL_BINARY_OP_OR_INT 29
585+
#define SPEC_FAIL_BINARY_OP_OR_DIFFERENT_TYPES 30
586+
#define SPEC_FAIL_BINARY_OP_XOR_INT 31
587+
#define SPEC_FAIL_BINARY_OP_XOR_DIFFERENT_TYPES 32
584588

585589
/* Calls */
586590

@@ -2379,6 +2383,12 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
23792383
return SPEC_FAIL_BINARY_OP_MULTIPLY_OTHER;
23802384
case NB_OR:
23812385
case NB_INPLACE_OR:
2386+
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
2387+
return SPEC_FAIL_BINARY_OP_OR_DIFFERENT_TYPES;
2388+
}
2389+
if (PyLong_CheckExact(lhs)) {
2390+
return SPEC_FAIL_BINARY_OP_OR_INT;
2391+
}
23822392
return SPEC_FAIL_BINARY_OP_OR;
23832393
case NB_POWER:
23842394
case NB_INPLACE_POWER:
@@ -2406,6 +2416,12 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
24062416
return SPEC_FAIL_BINARY_OP_TRUE_DIVIDE_OTHER;
24072417
case NB_XOR:
24082418
case NB_INPLACE_XOR:
2419+
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
2420+
return SPEC_FAIL_BINARY_OP_XOR_DIFFERENT_TYPES;
2421+
}
2422+
if (PyLong_CheckExact(lhs)) {
2423+
return SPEC_FAIL_BINARY_OP_XOR_INT;
2424+
}
24092425
return SPEC_FAIL_BINARY_OP_XOR;
24102426
}
24112427
Py_UNREACHABLE();

0 commit comments

Comments
 (0)