summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-02-01 19:38:06 (GMT)
committerGitHub <noreply@github.com>2023-02-01 19:38:06 (GMT)
commitb91b42d236c81bd7cbe402b322c82bfcd0d883a1 (patch)
tree4b94ef6a601374197e1ceaf9b2b073d9215e257d /Python/compile.c
parent7840ff3cdbdf64f517c9f981f57eff232e676104 (diff)
downloadcpython-b91b42d236c81bd7cbe402b322c82bfcd0d883a1.zip
cpython-b91b42d236c81bd7cbe402b322c82bfcd0d883a1.tar.gz
cpython-b91b42d236c81bd7cbe402b322c82bfcd0d883a1.tar.bz2
gh-98831: rewrite PUSH_EXC_INFO and conditional jumps in the instruction definition DSL (#101481)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/Python/compile.c b/Python/compile.c
index a11bcc7..d9ec689 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -8630,17 +8630,19 @@ opcode_metadata_is_sane(cfg_builder *g) {
int opcode = instr->i_opcode;
int oparg = instr->i_oparg;
assert(opcode <= MAX_REAL_OPCODE);
- int popped = _PyOpcode_num_popped(opcode, oparg);
- int pushed = _PyOpcode_num_pushed(opcode, oparg);
- assert((pushed < 0) == (popped < 0));
- if (pushed >= 0) {
- assert(_PyOpcode_opcode_metadata[opcode].valid_entry);
- int effect = stack_effect(opcode, instr->i_oparg, -1);
- if (effect != pushed - popped) {
- fprintf(stderr,
- "op=%d: stack_effect (%d) != pushed (%d) - popped (%d)\n",
- opcode, effect, pushed, popped);
- result = false;
+ for (int jump = 0; jump <= 1; jump++) {
+ int popped = _PyOpcode_num_popped(opcode, oparg, jump ? true : false);
+ int pushed = _PyOpcode_num_pushed(opcode, oparg, jump ? true : false);
+ assert((pushed < 0) == (popped < 0));
+ if (pushed >= 0) {
+ assert(_PyOpcode_opcode_metadata[opcode].valid_entry);
+ int effect = stack_effect(opcode, instr->i_oparg, jump);
+ if (effect != pushed - popped) {
+ fprintf(stderr,
+ "op=%d arg=%d jump=%d: stack_effect (%d) != pushed (%d) - popped (%d)\n",
+ opcode, oparg, jump, effect, pushed, popped);
+ result = false;
+ }
}
}
}