Skip to content

Commit

Permalink
fix optimizer bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Dec 23, 2024
1 parent 976fee4 commit c8b3d31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,17 @@ translate_bytecode_to_trace(
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
int nuops = expansion->nuops;
RESERVE(nuops + 1); /* One extra for exit */
// int16_t last_op = expansion->uops[nuops-1].uop;
// if (last_op == _RETURN_VALUE) {
// // Check for trace stack underflow now:
// // We can't bail e.g. in the middle of
// // LOAD_CONST + _RETURN_VALUE.
// if (trace_stack_depth == 0) {
// DPRINTF(2, "Trace stack underflow\n");
// OPT_STAT_INC(trace_stack_underflow);
// goto done;
// }
// }
int16_t last_op = expansion->uops[nuops-1].uop;
if (last_op == _RETURN_VALUE) {
// Check for trace stack underflow now:
// We can't bail e.g. in the middle of
// LOAD_CONST + _RETURN_VALUE.
if (trace_stack_depth == 0) {
DPRINTF(2, "Trace stack underflow\n");
OPT_STAT_INC(trace_stack_underflow);
goto done;
}
}
uint32_t orig_oparg = oparg; // For OPARG_TOP/BOTTOM
for (int i = 0; i < nuops; i++) {
oparg = orig_oparg;
Expand Down
2 changes: 1 addition & 1 deletion Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
{
/* _PUSH_FRAME doesn't escape or error, but it
* does need the IP for the return address */
bool needs_ip = opcode == _PUSH_FRAME;
bool needs_ip = (opcode == _PUSH_FRAME) || (opcode == _RETURN_OFFSET) || (opcode == _YIELD_OFFSET);
if (_PyUop_Flags[opcode] & HAS_ESCAPES_FLAG) {
needs_ip = true;
may_have_escaped = true;
Expand Down

0 comments on commit c8b3d31

Please sign in to comment.