Skip to content

Commit e689291

Browse files
Fix tests and check
1 parent ed4381c commit e689291

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def testfunc(n):
666666
self.assertLessEqual(len(guard_nos_float_count), 1)
667667
# TODO gh-115506: this assertion may change after propagating constants.
668668
# We'll also need to verify that propagation actually occurs.
669-
self.assertIn("_BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS", uops)
669+
self.assertIn("_POP_TOP_NOP", uops)
670670

671671
def test_float_subtract_constant_propagation(self):
672672
def testfunc(n):
@@ -688,7 +688,7 @@ def testfunc(n):
688688
self.assertLessEqual(len(guard_nos_float_count), 1)
689689
# TODO gh-115506: this assertion may change after propagating constants.
690690
# We'll also need to verify that propagation actually occurs.
691-
self.assertIn("_BINARY_OP_SUBTRACT_FLOAT__NO_DECREF_INPUTS", uops)
691+
self.assertIn("_POP_TOP_NOP", uops)
692692

693693
def test_float_multiply_constant_propagation(self):
694694
def testfunc(n):
@@ -710,7 +710,7 @@ def testfunc(n):
710710
self.assertLessEqual(len(guard_nos_float_count), 1)
711711
# TODO gh-115506: this assertion may change after propagating constants.
712712
# We'll also need to verify that propagation actually occurs.
713-
self.assertIn("_BINARY_OP_MULTIPLY_FLOAT__NO_DECREF_INPUTS", uops)
713+
self.assertIn("_POP_TOP_NOP", uops)
714714

715715
def test_add_unicode_propagation(self):
716716
def testfunc(n):
@@ -2409,7 +2409,7 @@ def testfunc(args):
24092409
self.assertAlmostEqual(res, TIER2_THRESHOLD * (0.1 + 0.1))
24102410
self.assertIsNotNone(ex)
24112411
uops = get_opnames(ex)
2412-
self.assertIn("_BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS", uops)
2412+
self.assertIn("_POP_TOP_NOP", uops)
24132413

24142414
def test_remove_guard_for_slice_list(self):
24152415
def f(n):

Python/optimizer_analysis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ incorrect_keys(PyObject *obj, uint32_t version)
140140

141141

142142
#define STACK_LEVEL() ((int)(stack_pointer - ctx->frame->stack))
143-
#define STACK_SIZE() ((int)(ctx->frame->stack_len))
143+
#define STACK_SIZE() ((int)(ctx->frame->stack_len) + MAX_CACHED_REGISTER)
144144

145145
#define CURRENT_FRAME_IS_INIT_SHIM() (ctx->frame->code == ((PyCodeObject *)&_Py_InitCleanup))
146146

@@ -312,7 +312,7 @@ _Py_opt_assert_within_stack_bounds(
312312
fflush(stdout);
313313
abort();
314314
}
315-
int size = (int)(frame->stack_len);
315+
int size = (int)(frame->stack_len) + MAX_CACHED_REGISTER;
316316
if (level > size) {
317317
printf("Stack overflow (depth = %d) at %s:%d\n", level, filename, lineno);
318318
fflush(stdout);

Python/optimizer_bytecodes.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,14 @@ dummy_func(void) {
523523
}
524524
}
525525

526+
op(_POP_TOP_FLOAT, (value -- )) {
527+
if (PyJitRef_IsBorrowed(value) ||
528+
sym_is_immortal(PyJitRef_Unwrap(value)) ||
529+
sym_is_null(value)) {
530+
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
531+
}
532+
}
533+
526534
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
527535
assert(oparg > 0);
528536
top = bottom;

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)