Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
Fidget-Spinner committed Jun 20, 2025
commit ca6e42ccf882adafc4516547ee3512f7c872d88b
13 changes: 13 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,6 +2408,19 @@ def testfunc(n):

self.assertIn("_POP_TOP_UNICODE", uops)

def test_store_pop_top_specialize_none(self):
def testfunc(n):
for _ in range(n):
global_identity(None)

testfunc(TIER2_THRESHOLD)

ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
uops = get_opnames(ex)

self.assertIn("_POP_TOP_NOP", uops)



def global_identity(x):
Expand Down
4 changes: 0 additions & 4 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,22 @@ dummy_func(
}

op(_POP_TOP_NOP, (value --)) {
// TODO (gh-134584): Consider moving this to a function pointer table and replicate.
assert(!PyStackRef_RefcountOnObject(value) ||
_Py_IsImmortal((PyStackRef_AsPyObjectBorrow(value))));
DEAD(value);
}

op(_POP_TOP_INT, (value --)) {
// TODO (gh-134584): Consider moving this to a function pointer table and replicate.
assert(PyLong_CheckExact(PyStackRef_AsPyObjectBorrow(value)));
PyStackRef_CLOSE_SPECIALIZED(value, _PyLong_ExactDealloc);
}

op(_POP_TOP_FLOAT, (value --)) {
// TODO (gh-134584): Consider moving this to a function pointer table and replicate.
assert(PyFloat_CheckExact(PyStackRef_AsPyObjectBorrow(value)));
PyStackRef_CLOSE_SPECIALIZED(value, _PyFloat_ExactDealloc);
}

op(_POP_TOP_UNICODE, (value --)) {
// TODO (gh-134584): Consider moving this to a function pointer table and replicate.
assert(PyUnicode_CheckExact(PyStackRef_AsPyObjectBorrow(value)));
PyStackRef_CLOSE_SPECIALIZED(value, _PyUnicode_ExactDealloc);
}
Expand Down
6 changes: 2 additions & 4 deletions Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ dummy_func(void) {
PyTypeObject *typ = sym_get_type(value);
PyObject *const_val = sym_get_const(ctx, value);
if (PyJitRef_IsBorrowed(value) ||
(const_val != NULL && _Py_IsImmortal(const_val))) {
sym_is_immortal(value) ||
sym_is_null(value)) {
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
}
else if (typ == &PyLong_Type) {
Expand All @@ -578,9 +579,6 @@ dummy_func(void) {
else if (typ == &PyUnicode_Type) {
REPLACE_OP(this_instr, _POP_TOP_UNICODE, 0, 0);
}
else if (typ == &PyBool_Type) {
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
}
}

op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
Expand Down
6 changes: 2 additions & 4 deletions Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.