Skip to content

Commit ca6e42c

Browse files
Address review
1 parent 4b415f5 commit ca6e42c

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,19 @@ def testfunc(n):
24082408

24092409
self.assertIn("_POP_TOP_UNICODE", uops)
24102410

2411+
def test_store_pop_top_specialize_none(self):
2412+
def testfunc(n):
2413+
for _ in range(n):
2414+
global_identity(None)
2415+
2416+
testfunc(TIER2_THRESHOLD)
2417+
2418+
ex = get_first_executor(testfunc)
2419+
self.assertIsNotNone(ex)
2420+
uops = get_opnames(ex)
2421+
2422+
self.assertIn("_POP_TOP_NOP", uops)
2423+
24112424

24122425

24132426
def global_identity(x):

Python/bytecodes.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,26 +346,22 @@ dummy_func(
346346
}
347347

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

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

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

367364
op(_POP_TOP_UNICODE, (value --)) {
368-
// TODO (gh-134584): Consider moving this to a function pointer table and replicate.
369365
assert(PyUnicode_CheckExact(PyStackRef_AsPyObjectBorrow(value)));
370366
PyStackRef_CLOSE_SPECIALIZED(value, _PyUnicode_ExactDealloc);
371367
}

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ dummy_func(void) {
566566
PyTypeObject *typ = sym_get_type(value);
567567
PyObject *const_val = sym_get_const(ctx, value);
568568
if (PyJitRef_IsBorrowed(value) ||
569-
(const_val != NULL && _Py_IsImmortal(const_val))) {
569+
sym_is_immortal(value) ||
570+
sym_is_null(value)) {
570571
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
571572
}
572573
else if (typ == &PyLong_Type) {
@@ -578,9 +579,6 @@ dummy_func(void) {
578579
else if (typ == &PyUnicode_Type) {
579580
REPLACE_OP(this_instr, _POP_TOP_UNICODE, 0, 0);
580581
}
581-
else if (typ == &PyBool_Type) {
582-
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
583-
}
584582
}
585583

586584
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)