Skip to content

Commit 85a98b5

Browse files
committed
Address code review
1 parent 2625e09 commit 85a98b5

File tree

7 files changed

+53
-30
lines changed

7 files changed

+53
-30
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,8 +2484,9 @@ def testfunc(n):
24842484
self.assertEqual(res, 10)
24852485
self.assertIsNotNone(ex)
24862486
uops = get_opnames(ex)
2487-
self.assertIn("_POP_TOP_INT", uops)
2488-
self.assertNotIn("_POP_TOP_NOP", uops)
2487+
self.assertNotIn("_POP_TOP", uops)
2488+
self.assertNotIn("_POP_TOP_INT", uops)
2489+
self.assertIn("_POP_TOP_NOP", uops)
24892490

24902491
def test_attr_promotion_failure(self):
24912492
# We're not testing for any specific uops here, just

Python/bytecodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,9 @@ dummy_func(
11261126
macro(STORE_SUBSCR) = _SPECIALIZE_STORE_SUBSCR + _STORE_SUBSCR;
11271127

11281128
macro(STORE_SUBSCR_LIST_INT) =
1129-
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/1 + _STORE_SUBSCR_LIST_INT + POP_TOP + _POP_TOP_INT;
1129+
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/1 + _STORE_SUBSCR_LIST_INT + _POP_TOP_INT + POP_TOP;
11301130

1131-
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- ss, ls)) {
1131+
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- ls, ss)) {
11321132
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
11331133
PyObject *list = PyStackRef_AsPyObjectBorrow(list_st);
11341134

@@ -1152,8 +1152,8 @@ dummy_func(
11521152
assert(old_value != NULL);
11531153
UNLOCK_OBJECT(list); // unlock before decrefs!
11541154
INPUTS_DEAD();
1155-
ss = sub_st;
11561155
ls = list_st;
1156+
ss = sub_st;
11571157
Py_DECREF(old_value);
11581158
}
11591159

Python/executor_cases.c.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ dummy_func(void) {
103103
GETLOCAL(oparg) = value;
104104
}
105105

106+
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- ls, ss)) {
107+
(void)value;
108+
ls = list_st;
109+
ss = sub_st;
110+
}
111+
106112
op(_PUSH_NULL, (-- res)) {
107113
res = sym_new_null(ctx);
108114
}
@@ -529,6 +535,12 @@ dummy_func(void) {
529535
}
530536
}
531537

538+
op(_POP_TOP_INT, (value -- )) {
539+
if (PyJitRef_IsBorrowed(value)) {
540+
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
541+
}
542+
}
543+
532544
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
533545
assert(oparg > 0);
534546
top = bottom;

Python/optimizer_cases.c.h

Lines changed: 17 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)