Skip to content

Commit

Permalink
Hacky way to make _FOR_ITER a viable uop
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Nov 15, 2023
1 parent f965c81 commit e909a83
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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: 6 additions & 0 deletions Python/abstract_interp_cases.c.h

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

14 changes: 13 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2368,7 +2368,7 @@ dummy_func(
goto enter_tier_one;
}

replaced op(_POP_JUMP_IF_FALSE, (unused/1, cond -- )) {
replaced op(_POP_JUMP_IF_FALSE, (unused/1, cond -- )) {
assert(PyBool_Check(cond));
int flag = Py_IsFalse(cond);
#if ENABLE_SPECIALIZATION
Expand Down Expand Up @@ -2520,10 +2520,13 @@ dummy_func(
if (!_PyErr_ExceptionMatches(tstate, PyExc_StopIteration)) {
GOTO_ERROR(error);
}
#if TIER_ONE
monitor_raise(tstate, frame, this_instr);
#endif
_PyErr_Clear(tstate);
}
/* iterator ended normally */
#if TIER_ONE
assert(next_instr[oparg].op.code == END_FOR ||
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
Py_DECREF(iter);
Expand All @@ -2532,6 +2535,7 @@ dummy_func(
JUMPBY(oparg + 1);
DISPATCH();
<<<<<<< HEAD
<<<<<<< HEAD
||||||| parent of 7dc8c93549a (Tiny fixes to code generator)
#endif
#if TIER_TWO
Expand Down Expand Up @@ -2565,6 +2569,14 @@ dummy_func(
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
goto enter_tier_one;
>>>>>>> 7dc8c93549a (Tiny fixes to code generator)
||||||| parent of 2bd857acb57 (Hacky way to make _FOR_ITER a viable uop)
=======
#endif
#if TIER_TWO
frame->instr_ptr = _PyCode_CODE(_PyFrame_GetCode(frame)) + oparg;
DEOPT_IF(true);
#endif
>>>>>>> 2bd857acb57 (Hacky way to make _FOR_ITER a viable uop)
}
// Common case: no jump, leave it to the code generator
}
Expand Down
49 changes: 49 additions & 0 deletions Python/executor_cases.c.h

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

4 changes: 4 additions & 0 deletions Python/generated_cases.c.h

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

0 comments on commit e909a83

Please sign in to comment.