Skip to content

Commit 0f3e071

Browse files
Address code review
1 parent 5514f48 commit 0f3e071

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

Lib/test/test_capi/test_opt.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,7 +3552,7 @@ def testfunc(*args):
35523552
uops = get_opnames(ex)
35533553

35543554
self.assertIn("_BINARY_OP_SUBSCR_INIT_CALL", uops)
3555-
# _POP_TOP_NOP is a sign the optimizer ran and didn't hit bottom.
3555+
# _POP_TOP_NOP is a sign the optimizer ran and didn't hit contradiction.
35563556
self.assertGreaterEqual(count_ops(ex, "_POP_TOP_NOP"), 1)
35573557

35583558
def test_load_attr_property_frame(self):
@@ -3566,14 +3566,12 @@ def testfunc(*args):
35663566
y = b.prop + b.prop
35673567

35683568
testfunc((3, B()))
3569-
import dis
3570-
dis.dis(testfunc, adaptive=True)
35713569
res, ex = self._run_with_optimizer(testfunc, (TIER2_THRESHOLD, B()))
35723570
self.assertIsNotNone(ex)
35733571
uops = get_opnames(ex)
35743572

35753573
self.assertIn("_LOAD_ATTR_PROPERTY_FRAME", uops)
3576-
# This is a sign the optimizer ran and didn't hit bottom.
3574+
# This is a sign the optimizer ran and didn't hit contradiction.
35773575
self.assertIn("_INSERT_2_LOAD_CONST_INLINE_BORROW", uops)
35783576

35793577
def test_unary_negative(self):

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ dummy_func(void) {
335335
break;
336336
}
337337
_Py_UOpsAbstractFrame *f = frame_new(ctx, co, 0, NULL, 0);
338+
if (f == NULL) {
339+
break;
340+
}
338341
f->locals[0] = container;
339342
f->locals[1] = sub;
340343
new_frame = PyJitRef_Wrap((JitOptSymbol *)f);
@@ -767,13 +770,17 @@ dummy_func(void) {
767770
}
768771

769772
op(_LOAD_ATTR_PROPERTY_FRAME, (fget/4, owner -- new_frame)) {
773+
// + 1 for _SAVE_RETURN_OFFSET
770774
assert((this_instr + 2)->opcode == _PUSH_FRAME);
771775
PyCodeObject *co = get_code_with_logging(this_instr + 2);
772776
if (co == NULL) {
773777
ctx->done = true;
774778
break;
775779
}
776780
_Py_UOpsAbstractFrame *f = frame_new(ctx, co, 0, NULL, 0);
781+
if (f == NULL) {
782+
break;
783+
}
777784
f->locals[0] = owner;
778785
new_frame = PyJitRef_Wrap((JitOptSymbol *)f);
779786
}

Python/optimizer_cases.c.h

Lines changed: 6 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)