Skip to content

Commit

Permalink
get rid of guard hoisting
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Dec 17, 2023
1 parent c9a007f commit 8420c8a
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 255 deletions.
3 changes: 3 additions & 0 deletions Include/internal/pycore_opcode_metadata.h

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

6 changes: 2 additions & 4 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2544,8 +2544,7 @@ class TestUopsOptimization(unittest.TestCase):
#
# ex = get_first_executor(testfunc)
# self.assertIsNotNone(ex)
# # TODO should be 127, one extra iteration for some reason
# self.assertEqual(res, 129)
# self.assertEqual(res, 127)
# binop_count = [opname for opname, _, _ in ex if opname == "_BINARY_OP_ADD_INT"]
# self.assertEqual(len(binop_count), 3)
#
Expand Down Expand Up @@ -2611,12 +2610,11 @@ class TestUopsOptimization(unittest.TestCase):
# self.assertIsNotNone(ex)
# binop_count = [opname for opname, _, _ in ex if opname == "_BINARY_OP_ADD_INT"]
# self.assertEqual(len(binop_count), 11)

#
# def test_int_cse(self):
# def testfunc(loops):
# num = 0
# while num < loops:
# # TODO data dependency not ordered correctly
# x = num + num
# y = num + num
# num += 1
Expand Down
151 changes: 82 additions & 69 deletions Python/abstract_interp_cases.c.h

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

10 changes: 6 additions & 4 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ dummy_func(
// We definitely pop the return value off the stack on entry.
// We also push it onto the stack on exit, but that's a
// different frame, and it's accounted for by _PUSH_FRAME.
op(_POP_FRAME, (retval --)) {
pure op(_POP_FRAME, (retval --)) {
#if TIER_ONE
assert(frame != &entry_frame);
#endif
Expand Down Expand Up @@ -3096,7 +3096,7 @@ dummy_func(
Py_DECREF(callable);
}

guard op(_CHECK_PEP_523, (--)) {
mandatory guard op(_CHECK_PEP_523, (--)) {
DEOPT_IF(tstate->interp->eval_frame);
}

Expand Down Expand Up @@ -3132,7 +3132,7 @@ dummy_func(
// The 'unused' output effect represents the return value
// (which will be pushed when the frame returns).
// It is needed so CALL_PY_EXACT_ARGS matches its family.
op(_PUSH_FRAME, (new_frame: _PyInterpreterFrame* -- unused if (0))) {
pure op(_PUSH_FRAME, (new_frame: _PyInterpreterFrame* -- unused if (0))) {
// Write it out explicitly because it's subtly different.
// Eventually this should be the only occurrence of this code.
assert(tstate->interp->eval_frame == NULL);
Expand Down Expand Up @@ -4027,7 +4027,8 @@ dummy_func(
frame->instr_ptr = _PyCode_CODE(_PyFrame_GetCode(frame)) + oparg;
}

op(_SAVE_RETURN_OFFSET, (--)) {
// Not exactly a guard, but not pure either, is just required.
mandatory guard op(_SAVE_RETURN_OFFSET, (--)) {
#if TIER_ONE
frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
Expand Down Expand Up @@ -4088,6 +4089,7 @@ dummy_func(
}



// END BYTECODES //

}
Expand Down
Loading

0 comments on commit 8420c8a

Please sign in to comment.