Skip to content
Prev Previous commit
Next Next commit
Fix tests and check
  • Loading branch information
Fidget-Spinner committed Dec 11, 2025
commit e6892913c5b508d5ad4b11c38dcabadb30557594
8 changes: 4 additions & 4 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def testfunc(n):
self.assertLessEqual(len(guard_nos_float_count), 1)
# TODO gh-115506: this assertion may change after propagating constants.
# We'll also need to verify that propagation actually occurs.
self.assertIn("_BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS", uops)
self.assertIn("_POP_TOP_NOP", uops)

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

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

def test_add_unicode_propagation(self):
def testfunc(n):
Expand Down Expand Up @@ -2409,7 +2409,7 @@ def testfunc(args):
self.assertAlmostEqual(res, TIER2_THRESHOLD * (0.1 + 0.1))
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS", uops)
self.assertIn("_POP_TOP_NOP", uops)

def test_remove_guard_for_slice_list(self):
def f(n):
Expand Down
4 changes: 2 additions & 2 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ incorrect_keys(PyObject *obj, uint32_t version)


#define STACK_LEVEL() ((int)(stack_pointer - ctx->frame->stack))
#define STACK_SIZE() ((int)(ctx->frame->stack_len))
Comment thread
Fidget-Spinner marked this conversation as resolved.
#define STACK_SIZE() ((int)(ctx->frame->stack_len) + MAX_CACHED_REGISTER)

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

Expand Down Expand Up @@ -312,7 +312,7 @@ _Py_opt_assert_within_stack_bounds(
fflush(stdout);
abort();
}
int size = (int)(frame->stack_len);
int size = (int)(frame->stack_len) + MAX_CACHED_REGISTER;
if (level > size) {
printf("Stack overflow (depth = %d) at %s:%d\n", level, filename, lineno);
fflush(stdout);
Expand Down
8 changes: 8 additions & 0 deletions Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ dummy_func(void) {
}
}

op(_POP_TOP_FLOAT, (value -- )) {
if (PyJitRef_IsBorrowed(value) ||
sym_is_immortal(PyJitRef_Unwrap(value)) ||
sym_is_null(value)) {
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
}
}

op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
assert(oparg > 0);
top = bottom;
Expand Down
7 changes: 7 additions & 0 deletions Python/optimizer_cases.c.h

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