Skip to content

Commit e40e580

Browse files
Apply suggestions from code review
Co-authored-by: Brandt Bucher <[email protected]>
1 parent 69d14ef commit e40e580

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ def testfunc(n):
15751575
return x
15761576

15771577
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1578-
self.assertEqual(res, 1)
1578+
self.assertEqual(res, TIER2_THRESHOLD)
15791579
self.assertIsNotNone(ex)
15801580
uops = get_opnames(ex)
15811581
self.assertNotIn("_COMPARE_OP_INT", uops)

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5132,7 +5132,7 @@ dummy_func(
51325132
value = PyStackRef_FromPyObjectImmortal(ptr);
51335133
}
51345134

5135-
tier2 pure op (_POP_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, pop1, pop2 -- value)) {
5135+
tier2 pure op(_POP_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, pop1, pop2 -- value)) {
51365136
PyStackRef_CLOSE(pop2);
51375137
PyStackRef_CLOSE(pop1);
51385138
value = PyStackRef_FromPyObjectImmortal(ptr);

Python/optimizer_bytecodes.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,11 @@ dummy_func(void) {
457457
if (tmp == NULL) {
458458
goto error;
459459
}
460+
assert(PyBool_Check(tmp));
461+
assert(_Py_IsImmortal(tmp));
462+
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)tmp);
460463
res = sym_new_const(ctx, tmp);
461464
Py_DECREF(tmp);
462-
463-
if (_Py_IsImmortal(res)) {
464-
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)tmp);
465-
}
466-
else {
467-
res = sym_new_type(ctx, &PyBool_Type);
468-
}
469465
}
470466
else {
471467
res = sym_new_type(ctx, &PyBool_Type);

0 commit comments

Comments
 (0)