Skip to content

Commit 415757f

Browse files
committed
Fewer jumps in ERROR_IF expansion
1 parent 80741b3 commit 415757f

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ dummy_func(
260260
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP);
261261
}
262262

263-
// This is a weird one. It's a super-instruction for
263+
// This is a subtle one. It's a super-instruction for
264264
// BINARY_OP_ADD_UNICODE followed by STORE_FAST
265265
// where the store goes into the left argument.
266266
// So the inputs are the same as for all BINARY_OP

Python/ceval.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
12751275
goto error;
12761276
}
12771277

1278+
pop_4_error:
1279+
STACK_SHRINK(1);
1280+
pop_3_error:
1281+
STACK_SHRINK(1);
1282+
pop_2_error:
1283+
STACK_SHRINK(1);
1284+
pop_1_error:
1285+
STACK_SHRINK(1);
12781286
error:
12791287
call_shape.kwnames = NULL;
12801288
/* Double-check exception status. */

Python/generated_cases.c.h

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/generate_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def write_instr(instr: InstDef, predictions: set[str], indent: str, f: TextIO, d
100100
# ERROR_IF() must remove the inputs from the stack.
101101
# The code block is responsible for DECREF()ing them.
102102
if ninputs:
103-
f.write(f"{space}if ({cond}) {{ STACK_SHRINK({ninputs}); goto {label}; }}\n")
103+
f.write(f"{space}if ({cond}) goto pop_{ninputs}_{label};\n")
104104
else:
105-
f.write(f"{space}if ({cond}) {{ goto {label}; }}\n")
105+
f.write(f"{space}if ({cond}) goto {label};\n")
106106
else:
107107
f.write(line)
108108
noutputs = len(instr.outputs or ())

0 commit comments

Comments
 (0)