Skip to content

Commit 47f21dd

Browse files
committed
test(opcache): update test_binary_op for wide int specialization
BINARY_OP_ADD_INT now specializes for non-compact int64-range operands (e.g. 10_000_000_000). Update the test accordingly: - Assert BINARY_OP_ADD_INT is used for wide int add - Keep the assertions that BINARY_OP_SUBTRACT_INT and BINARY_OP_MULTIPLY_INT are not used for non-compact ints
1 parent 957674b commit 47f21dd

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

Lib/test/test_opcache.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,20 +1375,28 @@ def binary_op_add_int():
13751375
self.assert_specialized(binary_op_add_int, "BINARY_OP_ADD_INT")
13761376
self.assert_no_opcode(binary_op_add_int, "BINARY_OP")
13771377

1378-
def binary_op_int_non_compact():
1378+
# Wide (non-compact) ints in the int64 range now specialize add.
1379+
def binary_op_int_wide_add():
13791380
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
13801381
a, b = 10000000000, 1
13811382
c = a + b
13821383
self.assertEqual(c, 10000000001)
1384+
1385+
binary_op_int_wide_add()
1386+
self.assert_specialized(binary_op_int_wide_add, "BINARY_OP_ADD_INT")
1387+
1388+
# Subtract and multiply are still compact-only.
1389+
def binary_op_int_non_compact_sub_mul():
1390+
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
1391+
a, b = 10000000000, 1
13831392
c = a - b
13841393
self.assertEqual(c, 9999999999)
13851394
c = a * b
13861395
self.assertEqual(c, 10000000000)
13871396

1388-
binary_op_int_non_compact()
1389-
self.assert_no_opcode(binary_op_int_non_compact, "BINARY_OP_ADD_INT")
1390-
self.assert_no_opcode(binary_op_int_non_compact, "BINARY_OP_SUBTRACT_INT")
1391-
self.assert_no_opcode(binary_op_int_non_compact, "BINARY_OP_MULTIPLY_INT")
1397+
binary_op_int_non_compact_sub_mul()
1398+
self.assert_no_opcode(binary_op_int_non_compact_sub_mul, "BINARY_OP_SUBTRACT_INT")
1399+
self.assert_no_opcode(binary_op_int_non_compact_sub_mul, "BINARY_OP_MULTIPLY_INT")
13921400

13931401
def binary_op_add_unicode():
13941402
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):

0 commit comments

Comments
 (0)