diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-01-25 20:41:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 20:41:03 +0000 |
commit | 19f90d6b97120eafe6dc6689d5a946f50c0c8ef8 (patch) | |
tree | 11cee177e3ece119b64122580ace76ebf6f2518e /Python/compile.c | |
parent | a178ba82bfe2f2fb6f6ff0e67cb734fd7c4321e3 (diff) | |
download | cpython-git-19f90d6b97120eafe6dc6689d5a946f50c0c8ef8.tar.gz |
gh-98831: add variable stack effect support to cases generator (#101309)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/compile.c b/Python/compile.c index 9fc997cdf5..c31f08c0a1 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -36,7 +36,7 @@ #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_symtable.h" // PySTEntryObject -#include "opcode_metadata.h" // _PyOpcode_opcode_metadata +#include "opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed #define DEFAULT_BLOCK_SIZE 16 @@ -8651,13 +8651,15 @@ no_redundant_jumps(cfg_builder *g) { static bool opcode_metadata_is_sane(cfg_builder *g) { + bool result = true; for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) { for (int i = 0; i < b->b_iused; i++) { struct instr *instr = &b->b_instr[i]; int opcode = instr->i_opcode; + int oparg = instr->i_oparg; assert(opcode <= MAX_REAL_OPCODE); - int pushed = _PyOpcode_opcode_metadata[opcode].n_pushed; - int popped = _PyOpcode_opcode_metadata[opcode].n_popped; + 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); @@ -8666,12 +8668,12 @@ opcode_metadata_is_sane(cfg_builder *g) { fprintf(stderr, "op=%d: stack_effect (%d) != pushed (%d) - popped (%d)\n", opcode, effect, pushed, popped); - return false; + result = false; } } } } - return true; + return result; } static bool |