From 22541577fc202c8ac3194eeb19096bee0c144bad Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 16:45:52 -0800 Subject: [PATCH 01/14] Add support for register instructions (These aren't used yet, but may be coming soon, and it's easier to keep this tool the same between branches.) --- Tools/cases_generator/generate_cases.py | 91 ++++++++++++++++++------- Tools/cases_generator/parser.py | 13 ++-- 2 files changed, 75 insertions(+), 29 deletions(-) diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 5eed74c5e1472b..8fdd0191fb3acc 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -96,6 +96,8 @@ def assign(self, dst: StackEffect, src: StackEffect): cast = self.cast(dst, src) if m := re.match(r"^PEEK\((\d+)\)$", dst.name): self.emit(f"POKE({m.group(1)}, {cast}{src.name});") + elif m := re.match(r"^REG\(oparg(\d+)\)$", dst.name): + self.emit(f"Py_XSETREF({dst.name}, {cast}{src.name});") else: self.emit(f"{dst.name} = {cast}{src.name};") @@ -109,6 +111,7 @@ class Instruction: # Parts of the underlying instruction definition inst: parser.InstDef + register: bool kind: typing.Literal["inst", "op"] name: str block: parser.Block @@ -121,6 +124,8 @@ class Instruction: cache_effects: list[parser.CacheEffect] input_effects: list[StackEffect] output_effects: list[StackEffect] + input_registers: list[str] # Parallel to input_effects + output_registers: list[str] # Etc. # Set later family: parser.Family | None = None @@ -129,6 +134,7 @@ class Instruction: def __init__(self, inst: parser.InstDef): self.inst = inst + self.register = inst.register self.kind = inst.kind self.name = inst.name self.block = inst.block @@ -150,9 +156,18 @@ def __init__(self, inst: parser.InstDef): break self.unmoved_names = frozenset(unmoved_names) + def analyze_registers(self, a: "Analyzer") -> None: + regs = iter(("REG(oparg1)", "REG(oparg2)", "REG(oparg3)")) + try: + self.input_registers = [next(regs) for _ in self.input_effects] + self.output_registers = [next(regs) for _ in self.output_effects] + except StopIteration: # Running out of registers + a.error(f"Instruction {self.name} has too many register effects", node=self.inst) + def write(self, out: Formatter) -> None: """Write one instruction, sans prologue and epilogue.""" # Write a static assertion that a family's cache size is correct + if family := self.family: if self.name == family.members[0]: if cache_size := family.size: @@ -161,10 +176,16 @@ def write(self, out: Formatter) -> None: f'{self.cache_offset}, "incorrect cache size");' ) - # Write input stack effect variable declarations and initializations - for i, ieffect in enumerate(reversed(self.input_effects), 1): - src = StackEffect(f"PEEK({i})", "") - out.declare(ieffect, src) + if not self.register: + # Write input stack effect variable declarations and initializations + for i, ieffect in enumerate(reversed(self.input_effects), 1): + src = StackEffect(f"PEEK({i})", "") + out.declare(ieffect, src) + else: + # Write input register variable declarations and initializations + for ieffect, reg in zip(self.input_effects, self.input_registers): + src = StackEffect(reg, "") + out.declare(ieffect, src) # Write output stack effect variable declarations input_names = {ieffect.name for ieffect in self.input_effects} @@ -172,20 +193,28 @@ def write(self, out: Formatter) -> None: if oeffect.name not in input_names: out.declare(oeffect, None) + # out.emit(f"JUMPBY(OPSIZE({self.inst.name}) - 1);") + self.write_body(out, 0) # Skip the rest if the block always exits if self.always_exits: return - # Write net stack growth/shrinkage - diff = len(self.output_effects) - len(self.input_effects) - out.stack_adjust(diff) + if not self.register: + # Write net stack growth/shrinkage + diff = len(self.output_effects) - len(self.input_effects) + out.stack_adjust(diff) - # Write output stack effect assignments - for i, oeffect in enumerate(reversed(self.output_effects), 1): - if oeffect.name not in self.unmoved_names: - dst = StackEffect(f"PEEK({i})", "") + # Write output stack effect assignments + for i, oeffect in enumerate(reversed(self.output_effects), 1): + if oeffect.name not in self.unmoved_names: + dst = StackEffect(f"PEEK({i})", "") + out.assign(dst, oeffect) + else: + # Write output register assignments + for oeffect, reg in zip(self.output_effects, self.output_registers): + dst = StackEffect(reg, "") out.assign(dst, oeffect) # Write cache effect @@ -222,14 +251,17 @@ def write_body(self, out: Formatter, dedent: int, cache_adjust: int = 0) -> None # ERROR_IF() must pop the inputs from the stack. # The code block is responsible for DECREF()ing them. # NOTE: If the label doesn't exist, just add it to ceval.c. - ninputs = len(self.input_effects) - # Don't pop common input/output effects at the bottom! - # These aren't DECREF'ed so they can stay. - for ieff, oeff in zip(self.input_effects, self.output_effects): - if ieff.name == oeff.name: - ninputs -= 1 - else: - break + if not self.register: + ninputs = len(self.input_effects) + # Don't pop common input/output effects at the bottom! + # These aren't DECREF'ed so they can stay. + for ieff, oeff in zip(self.input_effects, self.output_effects): + if ieff.name == oeff.name: + ninputs -= 1 + else: + break + else: + ninputs = 0 if ninputs: out.write_raw( f"{extra}{space}if ({cond}) goto pop_{ninputs}_{label};\n" @@ -237,10 +269,11 @@ def write_body(self, out: Formatter, dedent: int, cache_adjust: int = 0) -> None else: out.write_raw(f"{extra}{space}if ({cond}) goto {label};\n") elif m := re.match(r"(\s*)DECREF_INPUTS\(\);\s*$", line): - space = m.group(1) - for ieff in self.input_effects: - if ieff.name not in self.unmoved_names: - out.write_raw(f"{extra}{space}Py_DECREF({ieff.name});\n") + if not self.register: + space = m.group(1) + for ieff in self.input_effects: + if ieff.name not in self.unmoved_names: + out.write_raw(f"{extra}{space}Py_DECREF({ieff.name});\n") else: out.write_raw(extra + line) @@ -392,6 +425,7 @@ def analyze(self) -> None: self.find_predictions() self.map_families() self.check_families() + self.analyze_register_instrs() self.analyze_supers_and_macros() def find_predictions(self) -> None: @@ -458,6 +492,11 @@ def check_families(self) -> None: family, ) + def analyze_register_instrs(self) -> None: + for instr in self.instrs.values(): + if instr.register: + instr.analyze_registers(self) + def analyze_supers_and_macros(self) -> None: """Analyze each super- and macro instruction.""" self.super_instrs = {} @@ -616,9 +655,13 @@ def write_super(self, sup: SuperInstruction) -> None: with self.wrap_super_or_macro(sup): first = True for comp in sup.parts: - if not first: + if first: + pass + # self.out.emit("JUMPBY(OPSIZE(opcode) - 1);") + else: self.out.emit("NEXTOPARG();") self.out.emit("JUMPBY(1);") + # self.out.emit("JUMPBY(OPSIZE(opcode));") first = False comp.write_body(self.out, 0) if comp.instr.cache_offset: diff --git a/Tools/cases_generator/parser.py b/Tools/cases_generator/parser.py index d802c733dfd10c..06a4f5fb35261e 100644 --- a/Tools/cases_generator/parser.py +++ b/Tools/cases_generator/parser.py @@ -84,6 +84,7 @@ class OpName(Node): @dataclass class InstHeader(Node): + register: bool kind: Literal["inst", "op"] name: str inputs: list[InputEffect] @@ -92,6 +93,7 @@ class InstHeader(Node): @dataclass class InstDef(Node): + register: bool kind: Literal["inst", "op"] name: str inputs: list[InputEffect] @@ -134,16 +136,17 @@ def definition(self) -> InstDef | Super | Macro | Family | None: def inst_def(self) -> InstDef | None: if hdr := self.inst_header(): if block := self.block(): - return InstDef(hdr.kind, hdr.name, hdr.inputs, hdr.outputs, block) + return InstDef(hdr.register, hdr.kind, hdr.name, hdr.inputs, hdr.outputs, block) raise self.make_syntax_error("Expected block") return None @contextual def inst_header(self) -> InstHeader | None: # inst(NAME) - # | inst(NAME, (inputs -- outputs)) - # | op(NAME, (inputs -- outputs)) + # | [register] inst(NAME, (inputs -- outputs)) + # | [register] op(NAME, (inputs -- outputs)) # TODO: Make INST a keyword in the lexer. + register = bool(self.expect(lx.REGISTER)) if (tkn := self.expect(lx.IDENTIFIER)) and (kind := tkn.text) in ("inst", "op"): if self.expect(lx.LPAREN) and (tkn := self.expect(lx.IDENTIFIER)): name = tkn.text @@ -151,10 +154,10 @@ def inst_header(self) -> InstHeader | None: inp, outp = self.io_effect() if self.expect(lx.RPAREN): if (tkn := self.peek()) and tkn.kind == lx.LBRACE: - return InstHeader(kind, name, inp, outp) + return InstHeader(register, kind, name, inp, outp) elif self.expect(lx.RPAREN) and kind == "inst": # No legacy stack effect if kind is "op". - return InstHeader(kind, name, [], []) + return InstHeader(register, kind, name, [], []) return None def io_effect(self) -> tuple[list[InputEffect], list[OutputEffect]]: From 61b8c8dd51868f4253723ce7990fbed58f5e38d6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 16:55:39 -0800 Subject: [PATCH 02/14] Allow unused registers (at the end) --- Tools/cases_generator/generate_cases.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 8fdd0191fb3acc..e28c727c6af72d 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -159,8 +159,8 @@ def __init__(self, inst: parser.InstDef): def analyze_registers(self, a: "Analyzer") -> None: regs = iter(("REG(oparg1)", "REG(oparg2)", "REG(oparg3)")) try: - self.input_registers = [next(regs) for _ in self.input_effects] - self.output_registers = [next(regs) for _ in self.output_effects] + self.input_registers = [next(regs) for ieff in self.input_effects if ieff.name != UNUSED] + self.output_registers = [next(regs) for oeff in self.output_effects if oeff.name != UNUSED] except StopIteration: # Running out of registers a.error(f"Instruction {self.name} has too many register effects", node=self.inst) From bc75a3432e9fb4e9f90802bc89eb5749caf9bbc6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 16:56:20 -0800 Subject: [PATCH 03/14] Reformatted using black --- Tools/cases_generator/generate_cases.py | 16 ++++++++++++---- Tools/cases_generator/parser.py | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index e28c727c6af72d..72986f6536c5d4 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -159,10 +159,16 @@ def __init__(self, inst: parser.InstDef): def analyze_registers(self, a: "Analyzer") -> None: regs = iter(("REG(oparg1)", "REG(oparg2)", "REG(oparg3)")) try: - self.input_registers = [next(regs) for ieff in self.input_effects if ieff.name != UNUSED] - self.output_registers = [next(regs) for oeff in self.output_effects if oeff.name != UNUSED] + self.input_registers = [ + next(regs) for ieff in self.input_effects if ieff.name != UNUSED + ] + self.output_registers = [ + next(regs) for oeff in self.output_effects if oeff.name != UNUSED + ] except StopIteration: # Running out of registers - a.error(f"Instruction {self.name} has too many register effects", node=self.inst) + a.error( + f"Instruction {self.name} has too many register effects", node=self.inst + ) def write(self, out: Formatter) -> None: """Write one instruction, sans prologue and epilogue.""" @@ -238,7 +244,9 @@ def write_body(self, out: Formatter, dedent: int, cache_adjust: int = 0) -> None else: typ = f"uint{bits}_t " func = f"read_u{bits}" - out.emit(f"{typ}{ceffect.name} = {func}(&next_instr[{cache_offset}].cache);") + out.emit( + f"{typ}{ceffect.name} = {func}(&next_instr[{cache_offset}].cache);" + ) cache_offset += ceffect.size assert cache_offset == self.cache_offset + cache_adjust diff --git a/Tools/cases_generator/parser.py b/Tools/cases_generator/parser.py index 06a4f5fb35261e..ef151916a42bef 100644 --- a/Tools/cases_generator/parser.py +++ b/Tools/cases_generator/parser.py @@ -136,7 +136,9 @@ def definition(self) -> InstDef | Super | Macro | Family | None: def inst_def(self) -> InstDef | None: if hdr := self.inst_header(): if block := self.block(): - return InstDef(hdr.register, hdr.kind, hdr.name, hdr.inputs, hdr.outputs, block) + return InstDef( + hdr.register, hdr.kind, hdr.name, hdr.inputs, hdr.outputs, block + ) raise self.make_syntax_error("Expected block") return None From dab4e921d847ceb5a53aa8b452b11417547d9e31 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 20:13:47 -0800 Subject: [PATCH 04/14] Generate opcode_metadata.h --- Makefile.pre.in | 9 ++ Python/compile.c | 2 + Python/opcode_metadata.h | 180 ++++++++++++++++++++++++ Tools/cases_generator/generate_cases.py | 74 +++++++++- Tools/cases_generator/parser.py | 6 +- 5 files changed, 262 insertions(+), 9 deletions(-) create mode 100644 Python/opcode_metadata.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 1f8bd561f61dcd..6ceab34e29d52d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1455,6 +1455,15 @@ regen-cases: -i $(srcdir)/Python/bytecodes.c \ -o $(srcdir)/Python/generated_cases.c.h.new $(UPDATE_FILE) $(srcdir)/Python/generated_cases.c.h $(srcdir)/Python/generated_cases.c.h.new + # Regenerate Python/opcode_metadata.h from Python/bytecodes.c + # using Tools/cases_generator/generate_cases.py --metadata + PYTHONPATH=$(srcdir)/Tools/cases_generator \ + $(PYTHON_FOR_REGEN) \ + $(srcdir)/Tools/cases_generator/generate_cases.py \ + --metadata \ + -i $(srcdir)/Python/bytecodes.c \ + -o $(srcdir)/Python/opcode_metadata.h.new + $(UPDATE_FILE) $(srcdir)/Python/opcode_metadata.h $(srcdir)/Python/opcode_metadata.h.new Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/condvar.h $(srcdir)/Python/generated_cases.c.h diff --git a/Python/compile.c b/Python/compile.c index cbbdfb9e946772..7a046319c59cce 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -35,6 +35,8 @@ #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_symtable.h" // PySTEntryObject +#include "opcode_metadata.h" // _PyOpcode_opcode_metadata + #define DEFAULT_BLOCK_SIZE 16 #define DEFAULT_CODE_SIZE 128 diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h new file mode 100644 index 00000000000000..13978ae575c890 --- /dev/null +++ b/Python/opcode_metadata.h @@ -0,0 +1,180 @@ +// This file is generated by Tools/cases_generator/generate_cases.py --metadata +// from Python/bytecodes.c +// Do not edit! +struct { + int n_popped; + int n_pushed; +} _PyOpcode_opcode_metadata[256] = { + [NOP] = { .n_popped = 0, .n_pushed = 0 }, + [RESUME] = { .n_popped = 0, .n_pushed = 0 }, + [LOAD_CLOSURE] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_FAST_CHECK] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_FAST] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_CONST] = { .n_popped = 0, .n_pushed = 1 }, + [STORE_FAST] = { .n_popped = 1, .n_pushed = 0 }, + [LOAD_FAST__LOAD_FAST] = { .n_popped = 0, .n_pushed = 2 }, + [LOAD_FAST__LOAD_CONST] = { .n_popped = 0, .n_pushed = 2 }, + [STORE_FAST__LOAD_FAST] = { .n_popped = 1, .n_pushed = 1 }, + [STORE_FAST__STORE_FAST] = { .n_popped = 2, .n_pushed = 0 }, + [LOAD_CONST__LOAD_FAST] = { .n_popped = 0, .n_pushed = 2 }, + [POP_TOP] = { .n_popped = 1, .n_pushed = 0 }, + [PUSH_NULL] = { .n_popped = 0, .n_pushed = 1 }, + [UNARY_POSITIVE] = { .n_popped = 1, .n_pushed = 1 }, + [UNARY_NEGATIVE] = { .n_popped = 1, .n_pushed = 1 }, + [UNARY_NOT] = { .n_popped = 1, .n_pushed = 1 }, + [UNARY_INVERT] = { .n_popped = 1, .n_pushed = 1 }, + [BINARY_OP_MULTIPLY_INT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_MULTIPLY_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_SUBTRACT_INT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_SUBTRACT_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_ADD_UNICODE] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_INPLACE_ADD_UNICODE] = { .n_popped = 2, .n_pushed = 0 }, + [BINARY_OP_ADD_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_OP_ADD_INT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_SUBSCR] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_SLICE] = { .n_popped = 3, .n_pushed = 1 }, + [STORE_SLICE] = { .n_popped = 4, .n_pushed = 0 }, + [BINARY_SUBSCR_LIST_INT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_SUBSCR_TUPLE_INT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_SUBSCR_DICT] = { .n_popped = 2, .n_pushed = 1 }, + [BINARY_SUBSCR_GETITEM] = { .n_popped = 2, .n_pushed = 1 }, + [LIST_APPEND] = { .n_popped = 1, .n_pushed = 0 }, + [SET_ADD] = { .n_popped = 1, .n_pushed = 0 }, + [STORE_SUBSCR] = { .n_popped = 3, .n_pushed = 0 }, + [STORE_SUBSCR_LIST_INT] = { .n_popped = 3, .n_pushed = 0 }, + [STORE_SUBSCR_DICT] = { .n_popped = 3, .n_pushed = 0 }, + [DELETE_SUBSCR] = { .n_popped = 2, .n_pushed = 0 }, + [PRINT_EXPR] = { .n_popped = 1, .n_pushed = 0 }, + [RAISE_VARARGS] = { .n_popped = -1, .n_pushed = -1 }, + [INTERPRETER_EXIT] = { .n_popped = 1, .n_pushed = 0 }, + [RETURN_VALUE] = { .n_popped = 1, .n_pushed = 0 }, + [GET_AITER] = { .n_popped = 1, .n_pushed = 1 }, + [GET_ANEXT] = { .n_popped = 1, .n_pushed = 2 }, + [GET_AWAITABLE] = { .n_popped = 1, .n_pushed = 1 }, + [SEND] = { .n_popped = -1, .n_pushed = -1 }, + [ASYNC_GEN_WRAP] = { .n_popped = 1, .n_pushed = 1 }, + [YIELD_VALUE] = { .n_popped = 1, .n_pushed = 0 }, + [POP_EXCEPT] = { .n_popped = 1, .n_pushed = 0 }, + [RERAISE] = { .n_popped = -1, .n_pushed = -1 }, + [PREP_RERAISE_STAR] = { .n_popped = 2, .n_pushed = 1 }, + [END_ASYNC_FOR] = { .n_popped = -1, .n_pushed = -1 }, + [CLEANUP_THROW] = { .n_popped = -1, .n_pushed = -1 }, + [STOPITERATION_ERROR] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ASSERTION_ERROR] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_BUILD_CLASS] = { .n_popped = 0, .n_pushed = 1 }, + [STORE_NAME] = { .n_popped = 1, .n_pushed = 0 }, + [DELETE_NAME] = { .n_popped = 0, .n_pushed = 0 }, + [UNPACK_SEQUENCE] = { .n_popped = -1, .n_pushed = -1 }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, + [UNPACK_SEQUENCE_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, + [UNPACK_SEQUENCE_LIST] = { .n_popped = -1, .n_pushed = -1 }, + [UNPACK_EX] = { .n_popped = -1, .n_pushed = -1 }, + [STORE_ATTR] = { .n_popped = 2, .n_pushed = 0 }, + [DELETE_ATTR] = { .n_popped = 1, .n_pushed = 0 }, + [STORE_GLOBAL] = { .n_popped = 1, .n_pushed = 0 }, + [DELETE_GLOBAL] = { .n_popped = 0, .n_pushed = 0 }, + [LOAD_NAME] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_GLOBAL] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_GLOBAL_MODULE] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_GLOBAL_BUILTIN] = { .n_popped = -1, .n_pushed = -1 }, + [DELETE_FAST] = { .n_popped = 0, .n_pushed = 0 }, + [MAKE_CELL] = { .n_popped = 0, .n_pushed = 0 }, + [DELETE_DEREF] = { .n_popped = 0, .n_pushed = 0 }, + [LOAD_CLASSDEREF] = { .n_popped = 0, .n_pushed = 1 }, + [LOAD_DEREF] = { .n_popped = 0, .n_pushed = 1 }, + [STORE_DEREF] = { .n_popped = 1, .n_pushed = 0 }, + [COPY_FREE_VARS] = { .n_popped = 0, .n_pushed = 0 }, + [BUILD_STRING] = { .n_popped = -1, .n_pushed = -1 }, + [BUILD_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, + [BUILD_LIST] = { .n_popped = -1, .n_pushed = -1 }, + [LIST_TO_TUPLE] = { .n_popped = 1, .n_pushed = 1 }, + [LIST_EXTEND] = { .n_popped = 1, .n_pushed = 0 }, + [SET_UPDATE] = { .n_popped = 1, .n_pushed = 0 }, + [BUILD_SET] = { .n_popped = -1, .n_pushed = -1 }, + [BUILD_MAP] = { .n_popped = -1, .n_pushed = -1 }, + [SETUP_ANNOTATIONS] = { .n_popped = 0, .n_pushed = 0 }, + [BUILD_CONST_KEY_MAP] = { .n_popped = -1, .n_pushed = -1 }, + [DICT_UPDATE] = { .n_popped = 1, .n_pushed = 0 }, + [DICT_MERGE] = { .n_popped = 1, .n_pushed = 0 }, + [MAP_ADD] = { .n_popped = 2, .n_pushed = 0 }, + [LOAD_ATTR] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_INSTANCE_VALUE] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_MODULE] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_WITH_HINT] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_SLOT] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_CLASS] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_PROPERTY] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { .n_popped = -1, .n_pushed = -1 }, + [STORE_ATTR_INSTANCE_VALUE] = { .n_popped = 2, .n_pushed = 0 }, + [STORE_ATTR_WITH_HINT] = { .n_popped = 2, .n_pushed = 0 }, + [STORE_ATTR_SLOT] = { .n_popped = 2, .n_pushed = 0 }, + [COMPARE_OP] = { .n_popped = 2, .n_pushed = 1 }, + [COMPARE_OP_FLOAT_JUMP] = { .n_popped = 3, .n_pushed = 1 }, + [COMPARE_OP_INT_JUMP] = { .n_popped = 3, .n_pushed = 1 }, + [COMPARE_OP_STR_JUMP] = { .n_popped = 3, .n_pushed = 1 }, + [IS_OP] = { .n_popped = 2, .n_pushed = 1 }, + [CONTAINS_OP] = { .n_popped = 2, .n_pushed = 1 }, + [CHECK_EG_MATCH] = { .n_popped = -1, .n_pushed = -1 }, + [CHECK_EXC_MATCH] = { .n_popped = 2, .n_pushed = 2 }, + [IMPORT_NAME] = { .n_popped = 2, .n_pushed = 1 }, + [IMPORT_STAR] = { .n_popped = 1, .n_pushed = 0 }, + [IMPORT_FROM] = { .n_popped = 1, .n_pushed = 2 }, + [JUMP_FORWARD] = { .n_popped = 0, .n_pushed = 0 }, + [JUMP_BACKWARD] = { .n_popped = 0, .n_pushed = 0 }, + [POP_JUMP_IF_FALSE] = { .n_popped = -1, .n_pushed = -1 }, + [POP_JUMP_IF_TRUE] = { .n_popped = -1, .n_pushed = -1 }, + [POP_JUMP_IF_NOT_NONE] = { .n_popped = -1, .n_pushed = -1 }, + [POP_JUMP_IF_NONE] = { .n_popped = -1, .n_pushed = -1 }, + [JUMP_IF_FALSE_OR_POP] = { .n_popped = -1, .n_pushed = -1 }, + [JUMP_IF_TRUE_OR_POP] = { .n_popped = -1, .n_pushed = -1 }, + [JUMP_BACKWARD_NO_INTERRUPT] = { .n_popped = -1, .n_pushed = -1 }, + [GET_LEN] = { .n_popped = -1, .n_pushed = -1 }, + [MATCH_CLASS] = { .n_popped = -1, .n_pushed = -1 }, + [MATCH_MAPPING] = { .n_popped = -1, .n_pushed = -1 }, + [MATCH_SEQUENCE] = { .n_popped = -1, .n_pushed = -1 }, + [MATCH_KEYS] = { .n_popped = -1, .n_pushed = -1 }, + [GET_ITER] = { .n_popped = -1, .n_pushed = -1 }, + [GET_YIELD_FROM_ITER] = { .n_popped = -1, .n_pushed = -1 }, + [FOR_ITER] = { .n_popped = -1, .n_pushed = -1 }, + [FOR_ITER_LIST] = { .n_popped = -1, .n_pushed = -1 }, + [FOR_ITER_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, + [FOR_ITER_RANGE] = { .n_popped = -1, .n_pushed = -1 }, + [FOR_ITER_GEN] = { .n_popped = -1, .n_pushed = -1 }, + [BEFORE_ASYNC_WITH] = { .n_popped = -1, .n_pushed = -1 }, + [BEFORE_WITH] = { .n_popped = -1, .n_pushed = -1 }, + [WITH_EXCEPT_START] = { .n_popped = 4, .n_pushed = 5 }, + [PUSH_EXC_INFO] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_METHOD_WITH_DICT] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_METHOD_NO_DICT] = { .n_popped = -1, .n_pushed = -1 }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { .n_popped = -1, .n_pushed = -1 }, + [KW_NAMES] = { .n_popped = -1, .n_pushed = -1 }, + [CALL] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_PY_EXACT_ARGS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_PY_WITH_DEFAULTS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_TYPE_1] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_STR_1] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_TUPLE_1] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_BUILTIN_CLASS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_BUILTIN_O] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_BUILTIN_FAST] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_LEN] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_ISINSTANCE] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_LIST_APPEND] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { .n_popped = -1, .n_pushed = -1 }, + [CALL_FUNCTION_EX] = { .n_popped = -1, .n_pushed = -1 }, + [MAKE_FUNCTION] = { .n_popped = -1, .n_pushed = -1 }, + [RETURN_GENERATOR] = { .n_popped = -1, .n_pushed = -1 }, + [BUILD_SLICE] = { .n_popped = -1, .n_pushed = -1 }, + [FORMAT_VALUE] = { .n_popped = -1, .n_pushed = -1 }, + [COPY] = { .n_popped = -1, .n_pushed = -1 }, + [BINARY_OP] = { .n_popped = 2, .n_pushed = 1 }, + [SWAP] = { .n_popped = -1, .n_pushed = -1 }, + [EXTENDED_ARG] = { .n_popped = -1, .n_pushed = -1 }, + [CACHE] = { .n_popped = -1, .n_pushed = -1 }, +}; diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 72986f6536c5d4..38e9b9d0159040 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -21,6 +21,9 @@ DEFAULT_OUTPUT = os.path.relpath( os.path.join(os.path.dirname(__file__), "../../Python/generated_cases.c.h") ) +DEFAULT_METADATA_OUTPUT = os.path.relpath( + os.path.join(os.path.dirname(__file__), "../../Python/opcode_metadata.h") +) BEGIN_MARKER = "// BEGIN BYTECODES //" END_MARKER = "// END BYTECODES //" RE_PREDICTED = r"^\s*(?:PREDICT\(|GO_TO_INSTRUCTION\(|DEOPT_IF\(.*?,\s*)(\w+)\);\s*$" @@ -37,6 +40,10 @@ arg_parser.add_argument( "-o", "--output", type=str, help="Generated code", default=DEFAULT_OUTPUT ) +arg_parser.add_argument( + "-m", "--metadata", action="store_true", + help=f"Generated metadata (changes output default to {DEFAULT_METADATA_OUTPUT})" +) class Formatter: @@ -112,7 +119,7 @@ class Instruction: # Parts of the underlying instruction definition inst: parser.InstDef register: bool - kind: typing.Literal["inst", "op"] + kind: typing.Literal["inst", "op", "legacy"] # Legacy means no (input -- output) name: str block: parser.Block block_text: list[str] # Block.text, less curlies, less PREDICT() calls @@ -124,8 +131,8 @@ class Instruction: cache_effects: list[parser.CacheEffect] input_effects: list[StackEffect] output_effects: list[StackEffect] - input_registers: list[str] # Parallel to input_effects - output_registers: list[str] # Etc. + input_registers: list[str] = dataclasses.field(repr=False) # Parallel to input_effects + output_registers: list[str] = dataclasses.field(repr=False) # Etc. # Set later family: parser.Family | None = None @@ -610,6 +617,55 @@ def stack_analysis( ] return stack, -lowest + def write_metadata(self) -> None: + """Write instruction metadata to output file.""" + with open(self.output_filename, "w") as f: + # Write provenance header + f.write(f"// This file is generated by {os.path.relpath(__file__)} --metadata\n") + f.write(f"// from {os.path.relpath(self.filename)}\n") + f.write(f"// Do not edit!\n") + + # Create formatter; the rest of the code uses this + self.out = Formatter(f, 0) + + # Write variable definition + self.out.emit("struct {") + with self.out.indent(): + self.out.emit("int n_popped;") + self.out.emit("int n_pushed;") + self.out.emit("} _PyOpcode_opcode_metadata[256] = {") + + # Write metadata for each instruction + for thing in self.everything: + match thing: + case parser.InstDef(): + if thing.kind != "op": + self.write_metadata_for_inst(self.instrs[thing.name]) + case parser.Super(): + self.write_metadata_for_super(self.super_instrs[thing.name]) + case parser.Macro(): + pass # Macros don't exist at runtime + case _: + typing.assert_never(thing) + + # Write end of array + self.out.emit("};") + + def write_metadata_for_inst(self, instr: Instruction) -> None: + """Write metadata for a single instruction.""" + if instr.kind == "legacy": + n_popped = n_pushed = -1 + else: + n_popped = len(instr.input_effects) + n_pushed = len(instr.output_effects) + self.out.emit(f" [{instr.name}] = {{ .{n_popped = }, .{n_pushed = } }},") + + def write_metadata_for_super(self, sup: SuperInstruction) -> None: + """Write metadata for a super-instruction.""" + n_popped = sum(len(comp.instr.input_effects) for comp in sup.parts) + n_pushed = sum(len(comp.instr.output_effects) for comp in sup.parts) + self.out.emit(f" [{sup.name}] = {{ .{n_popped = }, .{n_pushed = } }},") + def write_instructions(self) -> None: """Write instructions to output file.""" with open(self.output_filename, "w") as f: @@ -618,7 +674,7 @@ def write_instructions(self) -> None: f.write(f"// from {os.path.relpath(self.filename)}\n") f.write(f"// Do not edit!\n") - # Create formatter; the rest of the code uses this. + # Create formatter; the rest of the code uses this self.out = Formatter(f, 8) # Write and count instructions of all kinds @@ -628,7 +684,7 @@ def write_instructions(self) -> None: for thing in self.everything: match thing: case parser.InstDef(): - if thing.kind == "inst": + if thing.kind != "op": n_instrs += 1 self.write_instr(self.instrs[thing.name]) case parser.Super(): @@ -762,12 +818,18 @@ def always_exits(lines: list[str]) -> bool: def main(): """Parse command line, parse input, analyze, write output.""" args = arg_parser.parse_args() # Prints message and sys.exit(2) on error + if args.metadata: + if args.output == DEFAULT_OUTPUT: + args.output = DEFAULT_METADATA_OUTPUT a = Analyzer(args.input, args.output) # Raises OSError if input unreadable a.parse() # Raises SyntaxError on failure a.analyze() # Prints messages and sets a.errors on failure if a.errors: sys.exit(f"Found {a.errors} errors") - a.write_instructions() # Raises OSError if output can't be written + if args.metadata: + a.write_metadata() + else: + a.write_instructions() # Raises OSError if output can't be written if __name__ == "__main__": diff --git a/Tools/cases_generator/parser.py b/Tools/cases_generator/parser.py index ef151916a42bef..4885394bf6b1e5 100644 --- a/Tools/cases_generator/parser.py +++ b/Tools/cases_generator/parser.py @@ -85,7 +85,7 @@ class OpName(Node): @dataclass class InstHeader(Node): register: bool - kind: Literal["inst", "op"] + kind: Literal["inst", "op", "legacy"] # Legacy means no (inputs -- outputs) name: str inputs: list[InputEffect] outputs: list[OutputEffect] @@ -94,7 +94,7 @@ class InstHeader(Node): @dataclass class InstDef(Node): register: bool - kind: Literal["inst", "op"] + kind: Literal["inst", "op", "legacy"] name: str inputs: list[InputEffect] outputs: list[OutputEffect] @@ -159,7 +159,7 @@ def inst_header(self) -> InstHeader | None: return InstHeader(register, kind, name, inp, outp) elif self.expect(lx.RPAREN) and kind == "inst": # No legacy stack effect if kind is "op". - return InstHeader(register, kind, name, [], []) + return InstHeader(register, "legacy", name, [], []) return None def io_effect(self) -> tuple[list[InputEffect], list[OutputEffect]]: From 737a96a4825c1201079ef20ab4ec919da5fbbd6e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 20:17:40 -0800 Subject: [PATCH 05/14] Reformatted using black; fixed help for -m --- Tools/cases_generator/generate_cases.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 38e9b9d0159040..bcfe308475eeaa 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -41,8 +41,10 @@ "-o", "--output", type=str, help="Generated code", default=DEFAULT_OUTPUT ) arg_parser.add_argument( - "-m", "--metadata", action="store_true", - help=f"Generated metadata (changes output default to {DEFAULT_METADATA_OUTPUT})" + "-m", + "--metadata", + action="store_true", + help=f"Generate metadata instead, changes output default to {DEFAULT_METADATA_OUTPUT}", ) @@ -131,8 +133,9 @@ class Instruction: cache_effects: list[parser.CacheEffect] input_effects: list[StackEffect] output_effects: list[StackEffect] - input_registers: list[str] = dataclasses.field(repr=False) # Parallel to input_effects - output_registers: list[str] = dataclasses.field(repr=False) # Etc. + # Parallel to input_effects + input_registers: list[str] = dataclasses.field(repr=False) + output_registers: list[str] = dataclasses.field(repr=False) # Set later family: parser.Family | None = None @@ -621,7 +624,9 @@ def write_metadata(self) -> None: """Write instruction metadata to output file.""" with open(self.output_filename, "w") as f: # Write provenance header - f.write(f"// This file is generated by {os.path.relpath(__file__)} --metadata\n") + f.write( + f"// This file is generated by {os.path.relpath(__file__)} --metadata\n" + ) f.write(f"// from {os.path.relpath(self.filename)}\n") f.write(f"// Do not edit!\n") From e96562f96bc5777668964fe14047a5faa263ae7a Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 20:39:47 -0800 Subject: [PATCH 06/14] Add register directions to opcode_metadata.h --- Python/opcode_metadata.h | 352 ++++++++++++------------ Tools/cases_generator/generate_cases.py | 21 +- 2 files changed, 195 insertions(+), 178 deletions(-) diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 13978ae575c890..99c08a9cc41e85 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -1,180 +1,184 @@ // This file is generated by Tools/cases_generator/generate_cases.py --metadata // from Python/bytecodes.c // Do not edit! +enum Direction { DIR_NONE, DIR_READ, DIR_WRITE }; struct { - int n_popped; - int n_pushed; + short n_popped; + short n_pushed; + Direction dir_op1; + Direction dir_op2; + Direction dir_op3; } _PyOpcode_opcode_metadata[256] = { - [NOP] = { .n_popped = 0, .n_pushed = 0 }, - [RESUME] = { .n_popped = 0, .n_pushed = 0 }, - [LOAD_CLOSURE] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_FAST_CHECK] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_FAST] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_CONST] = { .n_popped = 0, .n_pushed = 1 }, - [STORE_FAST] = { .n_popped = 1, .n_pushed = 0 }, - [LOAD_FAST__LOAD_FAST] = { .n_popped = 0, .n_pushed = 2 }, - [LOAD_FAST__LOAD_CONST] = { .n_popped = 0, .n_pushed = 2 }, - [STORE_FAST__LOAD_FAST] = { .n_popped = 1, .n_pushed = 1 }, - [STORE_FAST__STORE_FAST] = { .n_popped = 2, .n_pushed = 0 }, - [LOAD_CONST__LOAD_FAST] = { .n_popped = 0, .n_pushed = 2 }, - [POP_TOP] = { .n_popped = 1, .n_pushed = 0 }, - [PUSH_NULL] = { .n_popped = 0, .n_pushed = 1 }, - [UNARY_POSITIVE] = { .n_popped = 1, .n_pushed = 1 }, - [UNARY_NEGATIVE] = { .n_popped = 1, .n_pushed = 1 }, - [UNARY_NOT] = { .n_popped = 1, .n_pushed = 1 }, - [UNARY_INVERT] = { .n_popped = 1, .n_pushed = 1 }, - [BINARY_OP_MULTIPLY_INT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_MULTIPLY_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_SUBTRACT_INT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_SUBTRACT_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_ADD_UNICODE] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_INPLACE_ADD_UNICODE] = { .n_popped = 2, .n_pushed = 0 }, - [BINARY_OP_ADD_FLOAT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_OP_ADD_INT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_SUBSCR] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_SLICE] = { .n_popped = 3, .n_pushed = 1 }, - [STORE_SLICE] = { .n_popped = 4, .n_pushed = 0 }, - [BINARY_SUBSCR_LIST_INT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_SUBSCR_TUPLE_INT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_SUBSCR_DICT] = { .n_popped = 2, .n_pushed = 1 }, - [BINARY_SUBSCR_GETITEM] = { .n_popped = 2, .n_pushed = 1 }, - [LIST_APPEND] = { .n_popped = 1, .n_pushed = 0 }, - [SET_ADD] = { .n_popped = 1, .n_pushed = 0 }, - [STORE_SUBSCR] = { .n_popped = 3, .n_pushed = 0 }, - [STORE_SUBSCR_LIST_INT] = { .n_popped = 3, .n_pushed = 0 }, - [STORE_SUBSCR_DICT] = { .n_popped = 3, .n_pushed = 0 }, - [DELETE_SUBSCR] = { .n_popped = 2, .n_pushed = 0 }, - [PRINT_EXPR] = { .n_popped = 1, .n_pushed = 0 }, - [RAISE_VARARGS] = { .n_popped = -1, .n_pushed = -1 }, - [INTERPRETER_EXIT] = { .n_popped = 1, .n_pushed = 0 }, - [RETURN_VALUE] = { .n_popped = 1, .n_pushed = 0 }, - [GET_AITER] = { .n_popped = 1, .n_pushed = 1 }, - [GET_ANEXT] = { .n_popped = 1, .n_pushed = 2 }, - [GET_AWAITABLE] = { .n_popped = 1, .n_pushed = 1 }, - [SEND] = { .n_popped = -1, .n_pushed = -1 }, - [ASYNC_GEN_WRAP] = { .n_popped = 1, .n_pushed = 1 }, - [YIELD_VALUE] = { .n_popped = 1, .n_pushed = 0 }, - [POP_EXCEPT] = { .n_popped = 1, .n_pushed = 0 }, - [RERAISE] = { .n_popped = -1, .n_pushed = -1 }, - [PREP_RERAISE_STAR] = { .n_popped = 2, .n_pushed = 1 }, - [END_ASYNC_FOR] = { .n_popped = -1, .n_pushed = -1 }, - [CLEANUP_THROW] = { .n_popped = -1, .n_pushed = -1 }, - [STOPITERATION_ERROR] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ASSERTION_ERROR] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_BUILD_CLASS] = { .n_popped = 0, .n_pushed = 1 }, - [STORE_NAME] = { .n_popped = 1, .n_pushed = 0 }, - [DELETE_NAME] = { .n_popped = 0, .n_pushed = 0 }, - [UNPACK_SEQUENCE] = { .n_popped = -1, .n_pushed = -1 }, - [UNPACK_SEQUENCE_TWO_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, - [UNPACK_SEQUENCE_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, - [UNPACK_SEQUENCE_LIST] = { .n_popped = -1, .n_pushed = -1 }, - [UNPACK_EX] = { .n_popped = -1, .n_pushed = -1 }, - [STORE_ATTR] = { .n_popped = 2, .n_pushed = 0 }, - [DELETE_ATTR] = { .n_popped = 1, .n_pushed = 0 }, - [STORE_GLOBAL] = { .n_popped = 1, .n_pushed = 0 }, - [DELETE_GLOBAL] = { .n_popped = 0, .n_pushed = 0 }, - [LOAD_NAME] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_GLOBAL] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_GLOBAL_MODULE] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_GLOBAL_BUILTIN] = { .n_popped = -1, .n_pushed = -1 }, - [DELETE_FAST] = { .n_popped = 0, .n_pushed = 0 }, - [MAKE_CELL] = { .n_popped = 0, .n_pushed = 0 }, - [DELETE_DEREF] = { .n_popped = 0, .n_pushed = 0 }, - [LOAD_CLASSDEREF] = { .n_popped = 0, .n_pushed = 1 }, - [LOAD_DEREF] = { .n_popped = 0, .n_pushed = 1 }, - [STORE_DEREF] = { .n_popped = 1, .n_pushed = 0 }, - [COPY_FREE_VARS] = { .n_popped = 0, .n_pushed = 0 }, - [BUILD_STRING] = { .n_popped = -1, .n_pushed = -1 }, - [BUILD_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, - [BUILD_LIST] = { .n_popped = -1, .n_pushed = -1 }, - [LIST_TO_TUPLE] = { .n_popped = 1, .n_pushed = 1 }, - [LIST_EXTEND] = { .n_popped = 1, .n_pushed = 0 }, - [SET_UPDATE] = { .n_popped = 1, .n_pushed = 0 }, - [BUILD_SET] = { .n_popped = -1, .n_pushed = -1 }, - [BUILD_MAP] = { .n_popped = -1, .n_pushed = -1 }, - [SETUP_ANNOTATIONS] = { .n_popped = 0, .n_pushed = 0 }, - [BUILD_CONST_KEY_MAP] = { .n_popped = -1, .n_pushed = -1 }, - [DICT_UPDATE] = { .n_popped = 1, .n_pushed = 0 }, - [DICT_MERGE] = { .n_popped = 1, .n_pushed = 0 }, - [MAP_ADD] = { .n_popped = 2, .n_pushed = 0 }, - [LOAD_ATTR] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_INSTANCE_VALUE] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_MODULE] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_WITH_HINT] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_SLOT] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_CLASS] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_PROPERTY] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { .n_popped = -1, .n_pushed = -1 }, - [STORE_ATTR_INSTANCE_VALUE] = { .n_popped = 2, .n_pushed = 0 }, - [STORE_ATTR_WITH_HINT] = { .n_popped = 2, .n_pushed = 0 }, - [STORE_ATTR_SLOT] = { .n_popped = 2, .n_pushed = 0 }, - [COMPARE_OP] = { .n_popped = 2, .n_pushed = 1 }, - [COMPARE_OP_FLOAT_JUMP] = { .n_popped = 3, .n_pushed = 1 }, - [COMPARE_OP_INT_JUMP] = { .n_popped = 3, .n_pushed = 1 }, - [COMPARE_OP_STR_JUMP] = { .n_popped = 3, .n_pushed = 1 }, - [IS_OP] = { .n_popped = 2, .n_pushed = 1 }, - [CONTAINS_OP] = { .n_popped = 2, .n_pushed = 1 }, - [CHECK_EG_MATCH] = { .n_popped = -1, .n_pushed = -1 }, - [CHECK_EXC_MATCH] = { .n_popped = 2, .n_pushed = 2 }, - [IMPORT_NAME] = { .n_popped = 2, .n_pushed = 1 }, - [IMPORT_STAR] = { .n_popped = 1, .n_pushed = 0 }, - [IMPORT_FROM] = { .n_popped = 1, .n_pushed = 2 }, - [JUMP_FORWARD] = { .n_popped = 0, .n_pushed = 0 }, - [JUMP_BACKWARD] = { .n_popped = 0, .n_pushed = 0 }, - [POP_JUMP_IF_FALSE] = { .n_popped = -1, .n_pushed = -1 }, - [POP_JUMP_IF_TRUE] = { .n_popped = -1, .n_pushed = -1 }, - [POP_JUMP_IF_NOT_NONE] = { .n_popped = -1, .n_pushed = -1 }, - [POP_JUMP_IF_NONE] = { .n_popped = -1, .n_pushed = -1 }, - [JUMP_IF_FALSE_OR_POP] = { .n_popped = -1, .n_pushed = -1 }, - [JUMP_IF_TRUE_OR_POP] = { .n_popped = -1, .n_pushed = -1 }, - [JUMP_BACKWARD_NO_INTERRUPT] = { .n_popped = -1, .n_pushed = -1 }, - [GET_LEN] = { .n_popped = -1, .n_pushed = -1 }, - [MATCH_CLASS] = { .n_popped = -1, .n_pushed = -1 }, - [MATCH_MAPPING] = { .n_popped = -1, .n_pushed = -1 }, - [MATCH_SEQUENCE] = { .n_popped = -1, .n_pushed = -1 }, - [MATCH_KEYS] = { .n_popped = -1, .n_pushed = -1 }, - [GET_ITER] = { .n_popped = -1, .n_pushed = -1 }, - [GET_YIELD_FROM_ITER] = { .n_popped = -1, .n_pushed = -1 }, - [FOR_ITER] = { .n_popped = -1, .n_pushed = -1 }, - [FOR_ITER_LIST] = { .n_popped = -1, .n_pushed = -1 }, - [FOR_ITER_TUPLE] = { .n_popped = -1, .n_pushed = -1 }, - [FOR_ITER_RANGE] = { .n_popped = -1, .n_pushed = -1 }, - [FOR_ITER_GEN] = { .n_popped = -1, .n_pushed = -1 }, - [BEFORE_ASYNC_WITH] = { .n_popped = -1, .n_pushed = -1 }, - [BEFORE_WITH] = { .n_popped = -1, .n_pushed = -1 }, - [WITH_EXCEPT_START] = { .n_popped = 4, .n_pushed = 5 }, - [PUSH_EXC_INFO] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_METHOD_WITH_VALUES] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_METHOD_WITH_DICT] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_METHOD_NO_DICT] = { .n_popped = -1, .n_pushed = -1 }, - [LOAD_ATTR_METHOD_LAZY_DICT] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_BOUND_METHOD_EXACT_ARGS] = { .n_popped = -1, .n_pushed = -1 }, - [KW_NAMES] = { .n_popped = -1, .n_pushed = -1 }, - [CALL] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_PY_EXACT_ARGS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_PY_WITH_DEFAULTS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_TYPE_1] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_STR_1] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_TUPLE_1] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_BUILTIN_CLASS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_BUILTIN_O] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_BUILTIN_FAST] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_LEN] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_ISINSTANCE] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_LIST_APPEND] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { .n_popped = -1, .n_pushed = -1 }, - [CALL_FUNCTION_EX] = { .n_popped = -1, .n_pushed = -1 }, - [MAKE_FUNCTION] = { .n_popped = -1, .n_pushed = -1 }, - [RETURN_GENERATOR] = { .n_popped = -1, .n_pushed = -1 }, - [BUILD_SLICE] = { .n_popped = -1, .n_pushed = -1 }, - [FORMAT_VALUE] = { .n_popped = -1, .n_pushed = -1 }, - [COPY] = { .n_popped = -1, .n_pushed = -1 }, - [BINARY_OP] = { .n_popped = 2, .n_pushed = 1 }, - [SWAP] = { .n_popped = -1, .n_pushed = -1 }, - [EXTENDED_ARG] = { .n_popped = -1, .n_pushed = -1 }, - [CACHE] = { .n_popped = -1, .n_pushed = -1 }, + [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_CLOSURE] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_FAST_CHECK] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_FAST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_CONST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_FAST] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_FAST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_FAST__LOAD_CONST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_FAST__LOAD_FAST] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_FAST__STORE_FAST] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNARY_INVERT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_MULTIPLY_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_MULTIPLY_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_SUBTRACT_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_SUBTRACT_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_ADD_UNICODE] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_INPLACE_ADD_UNICODE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_ADD_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP_ADD_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SUBSCR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SLICE] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_SLICE] = { 4, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SUBSCR_LIST_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SUBSCR_TUPLE_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SUBSCR_DICT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_SUBSCR_GETITEM] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LIST_APPEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [SET_ADD] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_SUBSCR] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_SUBSCR_LIST_INT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_SUBSCR_DICT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_SUBSCR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [PRINT_EXPR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [RAISE_VARARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [INTERPRETER_EXIT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [RETURN_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_AITER] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_ANEXT] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [YIELD_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [END_ASYNC_FOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CLEANUP_THROW] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STOPITERATION_ERROR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ASSERTION_ERROR] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_BUILD_CLASS] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_NAME] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_NAME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNPACK_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNPACK_SEQUENCE_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNPACK_SEQUENCE_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [UNPACK_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_ATTR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_ATTR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_GLOBAL] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_GLOBAL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_NAME] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_GLOBAL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_GLOBAL_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_GLOBAL_BUILTIN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_FAST] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [MAKE_CELL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DELETE_DEREF] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_CLASSDEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_DEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_DEREF] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [COPY_FREE_VARS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_STRING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LIST_TO_TUPLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LIST_EXTEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [SET_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_SET] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [SETUP_ANNOTATIONS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_CONST_KEY_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [DICT_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [DICT_MERGE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [MAP_ADD] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_INSTANCE_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_WITH_HINT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_SLOT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_PROPERTY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_ATTR_INSTANCE_VALUE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_ATTR_WITH_HINT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [STORE_ATTR_SLOT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [COMPARE_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [COMPARE_OP_FLOAT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [COMPARE_OP_INT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [COMPARE_OP_STR_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [IS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CONTAINS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CHECK_EG_MATCH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CHECK_EXC_MATCH] = { 2, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [IMPORT_NAME] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [IMPORT_STAR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [IMPORT_FROM] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE }, + [JUMP_FORWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [JUMP_BACKWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_JUMP_IF_FALSE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_JUMP_IF_TRUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_JUMP_IF_NOT_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [POP_JUMP_IF_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [JUMP_IF_FALSE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [JUMP_IF_TRUE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [JUMP_BACKWARD_NO_INTERRUPT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [MATCH_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [MATCH_MAPPING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [MATCH_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [MATCH_KEYS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [GET_YIELD_FROM_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FOR_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FOR_ITER_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FOR_ITER_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FOR_ITER_RANGE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FOR_ITER_GEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BEFORE_ASYNC_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BEFORE_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [WITH_EXCEPT_START] = { 4, 5, DIR_NONE, DIR_NONE, DIR_NONE }, + [PUSH_EXC_INFO] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_METHOD_WITH_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_METHOD_NO_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [KW_NAMES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_PY_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_PY_WITH_DEFAULTS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_TYPE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_STR_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_TUPLE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_BUILTIN_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_BUILTIN_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_BUILTIN_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_ISINSTANCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_LIST_APPEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CALL_FUNCTION_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [MAKE_FUNCTION] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [RETURN_GENERATOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BUILD_SLICE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [FORMAT_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [COPY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, }; diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index bcfe308475eeaa..6e149985afd983 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -634,10 +634,14 @@ def write_metadata(self) -> None: self.out = Formatter(f, 0) # Write variable definition + self.out.emit("enum Direction { DIR_NONE, DIR_READ, DIR_WRITE };") self.out.emit("struct {") with self.out.indent(): - self.out.emit("int n_popped;") - self.out.emit("int n_pushed;") + self.out.emit("short n_popped;") + self.out.emit("short n_pushed;") + self.out.emit("Direction dir_op1;") + self.out.emit("Direction dir_op2;") + self.out.emit("Direction dir_op3;") self.out.emit("} _PyOpcode_opcode_metadata[256] = {") # Write metadata for each instruction @@ -658,18 +662,27 @@ def write_metadata(self) -> None: def write_metadata_for_inst(self, instr: Instruction) -> None: """Write metadata for a single instruction.""" + dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" if instr.kind == "legacy": n_popped = n_pushed = -1 + assert not instr.register else: n_popped = len(instr.input_effects) n_pushed = len(instr.output_effects) - self.out.emit(f" [{instr.name}] = {{ .{n_popped = }, .{n_pushed = } }},") + if instr.register: + directions: list[str] = [] + directions.extend("DIR_READ" for _ in instr.input_effects) + directions.extend("DIR_WRITE" for _ in instr.output_effects) + directions.extend("DIR_NONE" for _ in range(3)) + dir_op1, dir_op2, dir_op3 = directions[:3] + self.out.emit(f" [{instr.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") def write_metadata_for_super(self, sup: SuperInstruction) -> None: """Write metadata for a super-instruction.""" n_popped = sum(len(comp.instr.input_effects) for comp in sup.parts) n_pushed = sum(len(comp.instr.output_effects) for comp in sup.parts) - self.out.emit(f" [{sup.name}] = {{ .{n_popped = }, .{n_pushed = } }},") + dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" + self.out.emit(f" [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") def write_instructions(self) -> None: """Write instructions to output file.""" From 5670523b9ef393365ca5470128f049a3b54120e2 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jan 2023 20:49:21 -0800 Subject: [PATCH 07/14] Fix enum and make metadata static const --- Python/opcode_metadata.h | 8 ++++---- Tools/cases_generator/generate_cases.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 99c08a9cc41e85..8c48aadbca65b9 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -2,12 +2,12 @@ // from Python/bytecodes.c // Do not edit! enum Direction { DIR_NONE, DIR_READ, DIR_WRITE }; -struct { +static const struct { short n_popped; short n_pushed; - Direction dir_op1; - Direction dir_op2; - Direction dir_op3; + enum Direction dir_op1; + enum Direction dir_op2; + enum Direction dir_op3; } _PyOpcode_opcode_metadata[256] = { [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 6e149985afd983..3fa45c67e4d69a 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -635,13 +635,13 @@ def write_metadata(self) -> None: # Write variable definition self.out.emit("enum Direction { DIR_NONE, DIR_READ, DIR_WRITE };") - self.out.emit("struct {") + self.out.emit("static const struct {") with self.out.indent(): self.out.emit("short n_popped;") self.out.emit("short n_pushed;") - self.out.emit("Direction dir_op1;") - self.out.emit("Direction dir_op2;") - self.out.emit("Direction dir_op3;") + self.out.emit("enum Direction dir_op1;") + self.out.emit("enum Direction dir_op2;") + self.out.emit("enum Direction dir_op3;") self.out.emit("} _PyOpcode_opcode_metadata[256] = {") # Write metadata for each instruction From f108288ff773ea4a00421b01740b68894d2990e7 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 4 Jan 2023 10:43:31 -0800 Subject: [PATCH 08/14] Fix stack effect for YIELD_VALUE --- Python/bytecodes.c | 2 +- Python/opcode_metadata.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 839fac3fcd1176..4d760bcf8ab359 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -772,7 +772,7 @@ dummy_func( ERROR_IF(w == NULL, error); } - inst(YIELD_VALUE, (retval --)) { + inst(YIELD_VALUE, (retval -- unused)) { // NOTE: It's important that YIELD_VALUE never raises an exception! // The compiler treats any exception raised here as a failed close() // or throw() call. diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 8c48aadbca65b9..7e8ef752d16a74 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -57,7 +57,7 @@ static const struct { [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [YIELD_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, + [YIELD_VALUE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, From 1068f64f061e11b64e1cdd6abbfdb642d4a7b32f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 4 Jan 2023 10:48:48 -0800 Subject: [PATCH 09/14] Generate metadata for macros, fixing END_FOR --- Python/opcode_metadata.h | 1 + Tools/cases_generator/generate_cases.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 7e8ef752d16a74..2a6234e3db21d6 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -23,6 +23,7 @@ static const struct { [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, + [END_FOR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 3fa45c67e4d69a..564ec48596d3b4 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -653,7 +653,7 @@ def write_metadata(self) -> None: case parser.Super(): self.write_metadata_for_super(self.super_instrs[thing.name]) case parser.Macro(): - pass # Macros don't exist at runtime + self.write_metadata_for_macro(self.macro_instrs[thing.name]) case _: typing.assert_never(thing) @@ -684,6 +684,13 @@ def write_metadata_for_super(self, sup: SuperInstruction) -> None: dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" self.out.emit(f" [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") + def write_metadata_for_macro(self, mac: MacroInstruction) -> None: + """Write metadata for a macro-instruction.""" + n_popped = sum(len(comp.instr.input_effects) for comp in mac.parts if isinstance(comp, Component)) + n_pushed = sum(len(comp.instr.output_effects) for comp in mac.parts if isinstance(comp, Component)) + dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" + self.out.emit(f" [{mac.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") + def write_instructions(self) -> None: """Write instructions to output file.""" with open(self.output_filename, "w") as f: From a5998865b4fa52adbc9ababd7b7b8bdb26bb97bb Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 4 Jan 2023 10:57:01 -0800 Subject: [PATCH 10/14] Add a 'valid_entry' flag to opcode metadata --- Python/opcode_metadata.h | 347 ++++++++++++------------ Tools/cases_generator/generate_cases.py | 25 +- 2 files changed, 194 insertions(+), 178 deletions(-) diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 2a6234e3db21d6..d66027bd5015e8 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -8,178 +8,179 @@ static const struct { enum Direction dir_op1; enum Direction dir_op2; enum Direction dir_op3; + bool valid_entry; } _PyOpcode_opcode_metadata[256] = { - [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_CLOSURE] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_FAST_CHECK] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_FAST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_CONST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_FAST] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_FAST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_FAST__LOAD_CONST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_FAST__LOAD_FAST] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_FAST__STORE_FAST] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [END_FOR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNARY_INVERT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_MULTIPLY_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_MULTIPLY_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_SUBTRACT_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_SUBTRACT_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_ADD_UNICODE] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_INPLACE_ADD_UNICODE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_ADD_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP_ADD_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SUBSCR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SLICE] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_SLICE] = { 4, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SUBSCR_LIST_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SUBSCR_TUPLE_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SUBSCR_DICT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_SUBSCR_GETITEM] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LIST_APPEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [SET_ADD] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_SUBSCR] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_SUBSCR_LIST_INT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_SUBSCR_DICT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_SUBSCR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [PRINT_EXPR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [RAISE_VARARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [INTERPRETER_EXIT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [RETURN_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_AITER] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_ANEXT] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [YIELD_VALUE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [END_ASYNC_FOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CLEANUP_THROW] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STOPITERATION_ERROR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ASSERTION_ERROR] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_BUILD_CLASS] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_NAME] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_NAME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNPACK_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNPACK_SEQUENCE_TWO_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNPACK_SEQUENCE_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNPACK_SEQUENCE_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [UNPACK_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_ATTR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_ATTR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_GLOBAL] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_GLOBAL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_NAME] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_GLOBAL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_GLOBAL_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_GLOBAL_BUILTIN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_FAST] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [MAKE_CELL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DELETE_DEREF] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_CLASSDEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_DEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_DEREF] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [COPY_FREE_VARS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_STRING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LIST_TO_TUPLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LIST_EXTEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [SET_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_SET] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [SETUP_ANNOTATIONS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_CONST_KEY_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [DICT_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [DICT_MERGE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [MAP_ADD] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_INSTANCE_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_WITH_HINT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_SLOT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_PROPERTY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_ATTR_INSTANCE_VALUE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_ATTR_WITH_HINT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [STORE_ATTR_SLOT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [COMPARE_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [COMPARE_OP_FLOAT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [COMPARE_OP_INT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [COMPARE_OP_STR_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [IS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CONTAINS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CHECK_EG_MATCH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CHECK_EXC_MATCH] = { 2, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [IMPORT_NAME] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [IMPORT_STAR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [IMPORT_FROM] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE }, - [JUMP_FORWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [JUMP_BACKWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_JUMP_IF_FALSE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_JUMP_IF_TRUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_JUMP_IF_NOT_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [POP_JUMP_IF_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [JUMP_IF_FALSE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [JUMP_IF_TRUE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [JUMP_BACKWARD_NO_INTERRUPT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [MATCH_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [MATCH_MAPPING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [MATCH_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [MATCH_KEYS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [GET_YIELD_FROM_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FOR_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FOR_ITER_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FOR_ITER_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FOR_ITER_RANGE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FOR_ITER_GEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BEFORE_ASYNC_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BEFORE_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [WITH_EXCEPT_START] = { 4, 5, DIR_NONE, DIR_NONE, DIR_NONE }, - [PUSH_EXC_INFO] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_METHOD_WITH_VALUES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_METHOD_WITH_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_METHOD_NO_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [LOAD_ATTR_METHOD_LAZY_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_BOUND_METHOD_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [KW_NAMES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_PY_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_PY_WITH_DEFAULTS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_TYPE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_STR_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_TUPLE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_BUILTIN_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_BUILTIN_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_BUILTIN_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_ISINSTANCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_LIST_APPEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CALL_FUNCTION_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [MAKE_FUNCTION] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [RETURN_GENERATOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BUILD_SLICE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [FORMAT_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [COPY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE }, - [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, - [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE }, + [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_CLOSURE] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_FAST_CHECK] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_FAST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_CONST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_FAST] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_FAST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_FAST__LOAD_CONST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_FAST__LOAD_FAST] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_FAST__STORE_FAST] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [END_FOR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNARY_INVERT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_MULTIPLY_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_MULTIPLY_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_SUBTRACT_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_SUBTRACT_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_ADD_UNICODE] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_INPLACE_ADD_UNICODE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_ADD_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP_ADD_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SUBSCR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SLICE] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_SLICE] = { 4, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SUBSCR_LIST_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SUBSCR_TUPLE_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SUBSCR_DICT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_SUBSCR_GETITEM] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LIST_APPEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [SET_ADD] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_SUBSCR] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_SUBSCR_LIST_INT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_SUBSCR_DICT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_SUBSCR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [PRINT_EXPR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [RAISE_VARARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [INTERPRETER_EXIT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [RETURN_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_AITER] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_ANEXT] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [YIELD_VALUE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [END_ASYNC_FOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CLEANUP_THROW] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STOPITERATION_ERROR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ASSERTION_ERROR] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_BUILD_CLASS] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_NAME] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_NAME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNPACK_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNPACK_SEQUENCE_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNPACK_SEQUENCE_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [UNPACK_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_ATTR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_ATTR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_GLOBAL] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_GLOBAL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_NAME] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_GLOBAL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_GLOBAL_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_GLOBAL_BUILTIN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_FAST] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MAKE_CELL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DELETE_DEREF] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_CLASSDEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_DEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_DEREF] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COPY_FREE_VARS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_STRING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LIST_TO_TUPLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LIST_EXTEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [SET_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_SET] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [SETUP_ANNOTATIONS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_CONST_KEY_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DICT_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [DICT_MERGE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MAP_ADD] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_INSTANCE_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_WITH_HINT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_SLOT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_PROPERTY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_ATTR_INSTANCE_VALUE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_ATTR_WITH_HINT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [STORE_ATTR_SLOT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COMPARE_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COMPARE_OP_FLOAT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COMPARE_OP_INT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COMPARE_OP_STR_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [IS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CONTAINS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CHECK_EG_MATCH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CHECK_EXC_MATCH] = { 2, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [IMPORT_NAME] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [IMPORT_STAR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [IMPORT_FROM] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [JUMP_FORWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [JUMP_BACKWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_JUMP_IF_FALSE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_JUMP_IF_TRUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_JUMP_IF_NOT_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [POP_JUMP_IF_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [JUMP_IF_FALSE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [JUMP_IF_TRUE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [JUMP_BACKWARD_NO_INTERRUPT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MATCH_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MATCH_MAPPING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MATCH_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MATCH_KEYS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [GET_YIELD_FROM_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FOR_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FOR_ITER_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FOR_ITER_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FOR_ITER_RANGE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FOR_ITER_GEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BEFORE_ASYNC_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BEFORE_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [WITH_EXCEPT_START] = { 4, 5, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [PUSH_EXC_INFO] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_METHOD_WITH_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_METHOD_NO_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [KW_NAMES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_PY_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_PY_WITH_DEFAULTS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_TYPE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_STR_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_TUPLE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_BUILTIN_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_BUILTIN_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_BUILTIN_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_ISINSTANCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_LIST_APPEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CALL_FUNCTION_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [MAKE_FUNCTION] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [RETURN_GENERATOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BUILD_SLICE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [FORMAT_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [COPY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, }; diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 564ec48596d3b4..c0136258f7bf0b 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -642,6 +642,7 @@ def write_metadata(self) -> None: self.out.emit("enum Direction dir_op1;") self.out.emit("enum Direction dir_op2;") self.out.emit("enum Direction dir_op3;") + self.out.emit("bool valid_entry;") self.out.emit("} _PyOpcode_opcode_metadata[256] = {") # Write metadata for each instruction @@ -675,21 +676,35 @@ def write_metadata_for_inst(self, instr: Instruction) -> None: directions.extend("DIR_WRITE" for _ in instr.output_effects) directions.extend("DIR_NONE" for _ in range(3)) dir_op1, dir_op2, dir_op3 = directions[:3] - self.out.emit(f" [{instr.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") + self.out.emit( + f" [{instr.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + ) def write_metadata_for_super(self, sup: SuperInstruction) -> None: """Write metadata for a super-instruction.""" n_popped = sum(len(comp.instr.input_effects) for comp in sup.parts) n_pushed = sum(len(comp.instr.output_effects) for comp in sup.parts) dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" - self.out.emit(f" [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") + self.out.emit( + f" [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + ) def write_metadata_for_macro(self, mac: MacroInstruction) -> None: """Write metadata for a macro-instruction.""" - n_popped = sum(len(comp.instr.input_effects) for comp in mac.parts if isinstance(comp, Component)) - n_pushed = sum(len(comp.instr.output_effects) for comp in mac.parts if isinstance(comp, Component)) + n_popped = sum( + len(comp.instr.input_effects) + for comp in mac.parts + if isinstance(comp, Component) + ) + n_pushed = sum( + len(comp.instr.output_effects) + for comp in mac.parts + if isinstance(comp, Component) + ) dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" - self.out.emit(f" [{mac.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3} }},") + self.out.emit( + f" [{mac.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + ) def write_instructions(self) -> None: """Write instructions to output file.""" From 404053b44578b10471e67093760cb056884e4d88 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 4 Jan 2023 20:29:20 +0000 Subject: [PATCH 11/14] add sanity check for opcode metadata --- Python/compile.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index 7a046319c59cce..bdd35ebf0ea497 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8670,6 +8670,27 @@ no_redundant_jumps(cfg_builder *g) { return true; } +static bool +opcode_metadata_is_sane(cfg_builder *g) { + 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; + assert(opcode <= MAX_REAL_OPCODE); + int pushed = _PyOpcode_opcode_metadata[opcode].n_pushed; + int popped = _PyOpcode_opcode_metadata[opcode].n_popped; + assert((pushed < 0) == (popped < 0)); + if (pushed >= 0) { + int effect = stack_effect(opcode, instr->i_oparg, -1); + if (effect != pushed - popped) { + return false; + } + } + } + } + return true; +} + static bool no_empty_basic_blocks(cfg_builder *g) { for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) { @@ -8853,6 +8874,7 @@ assemble(struct compiler *c, int addNone) } assert(no_redundant_jumps(g)); + assert(opcode_metadata_is_sane(g)); /* Can't modify the bytecode after computing jump offsets. */ assemble_jump_offsets(g->g_entryblock); From b00ec7b4167560ec1a799f12026171e7f149d5d5 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 4 Jan 2023 21:16:49 +0000 Subject: [PATCH 12/14] add print when assertion fails --- Python/compile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index bdd35ebf0ea497..967a00eb10896e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8683,6 +8683,9 @@ opcode_metadata_is_sane(cfg_builder *g) { if (pushed >= 0) { 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); return false; } } From 88c67cdc9a08708eda3f80cda15128ca22befef5 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 4 Jan 2023 21:20:20 +0000 Subject: [PATCH 13/14] assert entry is valid --- Python/compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/compile.c b/Python/compile.c index 967a00eb10896e..dc1c49557fd51c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -8681,6 +8681,7 @@ opcode_metadata_is_sane(cfg_builder *g) { int popped = _PyOpcode_opcode_metadata[opcode].n_popped; 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, From 555589a269c6d199f1b2a89b4abe0561f87fde02 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 4 Jan 2023 13:50:55 -0800 Subject: [PATCH 14/14] Add instr format metadata field --- Python/opcode_metadata.h | 347 ++++++++++++------------ Tools/cases_generator/generate_cases.py | 63 ++++- 2 files changed, 224 insertions(+), 186 deletions(-) diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index d66027bd5015e8..2d539896844d80 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -9,178 +9,179 @@ static const struct { enum Direction dir_op2; enum Direction dir_op3; bool valid_entry; + char instr_format[10]; } _PyOpcode_opcode_metadata[256] = { - [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_CLOSURE] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_FAST_CHECK] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_FAST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_CONST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_FAST] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_FAST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_FAST__LOAD_CONST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_FAST__LOAD_FAST] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_FAST__STORE_FAST] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [END_FOR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNARY_INVERT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_MULTIPLY_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_MULTIPLY_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_SUBTRACT_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_SUBTRACT_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_ADD_UNICODE] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_INPLACE_ADD_UNICODE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_ADD_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP_ADD_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SUBSCR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SLICE] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_SLICE] = { 4, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SUBSCR_LIST_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SUBSCR_TUPLE_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SUBSCR_DICT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_SUBSCR_GETITEM] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LIST_APPEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [SET_ADD] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_SUBSCR] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_SUBSCR_LIST_INT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_SUBSCR_DICT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_SUBSCR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [PRINT_EXPR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [RAISE_VARARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [INTERPRETER_EXIT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [RETURN_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_AITER] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_ANEXT] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [YIELD_VALUE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [END_ASYNC_FOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CLEANUP_THROW] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STOPITERATION_ERROR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ASSERTION_ERROR] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_BUILD_CLASS] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_NAME] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_NAME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNPACK_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNPACK_SEQUENCE_TWO_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNPACK_SEQUENCE_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNPACK_SEQUENCE_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [UNPACK_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_ATTR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_ATTR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_GLOBAL] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_GLOBAL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_NAME] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_GLOBAL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_GLOBAL_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_GLOBAL_BUILTIN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_FAST] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MAKE_CELL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DELETE_DEREF] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_CLASSDEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_DEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_DEREF] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COPY_FREE_VARS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_STRING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LIST_TO_TUPLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LIST_EXTEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [SET_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_SET] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [SETUP_ANNOTATIONS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_CONST_KEY_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DICT_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [DICT_MERGE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MAP_ADD] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_INSTANCE_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_WITH_HINT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_SLOT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_PROPERTY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_ATTR_INSTANCE_VALUE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_ATTR_WITH_HINT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [STORE_ATTR_SLOT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COMPARE_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COMPARE_OP_FLOAT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COMPARE_OP_INT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COMPARE_OP_STR_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [IS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CONTAINS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CHECK_EG_MATCH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CHECK_EXC_MATCH] = { 2, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [IMPORT_NAME] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [IMPORT_STAR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [IMPORT_FROM] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [JUMP_FORWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [JUMP_BACKWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_JUMP_IF_FALSE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_JUMP_IF_TRUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_JUMP_IF_NOT_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [POP_JUMP_IF_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [JUMP_IF_FALSE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [JUMP_IF_TRUE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [JUMP_BACKWARD_NO_INTERRUPT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MATCH_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MATCH_MAPPING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MATCH_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MATCH_KEYS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [GET_YIELD_FROM_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FOR_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FOR_ITER_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FOR_ITER_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FOR_ITER_RANGE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FOR_ITER_GEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BEFORE_ASYNC_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BEFORE_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [WITH_EXCEPT_START] = { 4, 5, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [PUSH_EXC_INFO] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_METHOD_WITH_VALUES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_METHOD_WITH_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_METHOD_NO_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [LOAD_ATTR_METHOD_LAZY_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_BOUND_METHOD_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [KW_NAMES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_PY_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_PY_WITH_DEFAULTS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_TYPE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_STR_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_TUPLE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_BUILTIN_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_BUILTIN_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_BUILTIN_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_ISINSTANCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_LIST_APPEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CALL_FUNCTION_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [MAKE_FUNCTION] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [RETURN_GENERATOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BUILD_SLICE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [FORMAT_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [COPY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, - [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true }, + [NOP] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [RESUME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_CLOSURE] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_FAST_CHECK] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_FAST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_CONST] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_FAST] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_FAST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBIB" }, + [LOAD_FAST__LOAD_CONST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBIB" }, + [STORE_FAST__LOAD_FAST] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBIB" }, + [STORE_FAST__STORE_FAST] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBIB" }, + [LOAD_CONST__LOAD_FAST] = { 0, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBIB" }, + [POP_TOP] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [PUSH_NULL] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [END_FOR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNARY_POSITIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNARY_NEGATIVE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNARY_NOT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNARY_INVERT] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BINARY_OP_MULTIPLY_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_MULTIPLY_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_SUBTRACT_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_SUBTRACT_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_ADD_UNICODE] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_INPLACE_ADD_UNICODE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BINARY_OP_ADD_FLOAT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_OP_ADD_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [BINARY_SUBSCR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [BINARY_SLICE] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_SLICE] = { 4, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BINARY_SUBSCR_LIST_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [BINARY_SUBSCR_TUPLE_INT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [BINARY_SUBSCR_DICT] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [BINARY_SUBSCR_GETITEM] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [LIST_APPEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [SET_ADD] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_SUBSCR] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [STORE_SUBSCR_LIST_INT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [STORE_SUBSCR_DICT] = { 3, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [DELETE_SUBSCR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [PRINT_EXPR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [RAISE_VARARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [INTERPRETER_EXIT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [RETURN_VALUE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_AITER] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_ANEXT] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_AWAITABLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [SEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [ASYNC_GEN_WRAP] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [YIELD_VALUE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [POP_EXCEPT] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [RERAISE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [PREP_RERAISE_STAR] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [END_ASYNC_FOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CLEANUP_THROW] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STOPITERATION_ERROR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ASSERTION_ERROR] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_BUILD_CLASS] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_NAME] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DELETE_NAME] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNPACK_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNPACK_SEQUENCE_TWO_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNPACK_SEQUENCE_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNPACK_SEQUENCE_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [UNPACK_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_ATTR] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [DELETE_ATTR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_GLOBAL] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DELETE_GLOBAL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_NAME] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_GLOBAL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_GLOBAL_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_GLOBAL_BUILTIN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DELETE_FAST] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MAKE_CELL] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DELETE_DEREF] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_CLASSDEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_DEREF] = { 0, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_DEREF] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [COPY_FREE_VARS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_STRING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LIST_TO_TUPLE] = { 1, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LIST_EXTEND] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [SET_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_SET] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [SETUP_ANNOTATIONS] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_CONST_KEY_MAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DICT_UPDATE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [DICT_MERGE] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MAP_ADD] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_INSTANCE_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_MODULE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_WITH_HINT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_SLOT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_PROPERTY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [STORE_ATTR_INSTANCE_VALUE] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [STORE_ATTR_WITH_HINT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [STORE_ATTR_SLOT] = { 2, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC000" }, + [COMPARE_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC0" }, + [COMPARE_OP_FLOAT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC0IB" }, + [COMPARE_OP_INT_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC0IB" }, + [COMPARE_OP_STR_JUMP] = { 3, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC0IB" }, + [IS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CONTAINS_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CHECK_EG_MATCH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CHECK_EXC_MATCH] = { 2, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [IMPORT_NAME] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [IMPORT_STAR] = { 1, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [IMPORT_FROM] = { 1, 2, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [JUMP_FORWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [JUMP_BACKWARD] = { 0, 0, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [POP_JUMP_IF_FALSE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [POP_JUMP_IF_TRUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [POP_JUMP_IF_NOT_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [POP_JUMP_IF_NONE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [JUMP_IF_FALSE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [JUMP_IF_TRUE_OR_POP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [JUMP_BACKWARD_NO_INTERRUPT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MATCH_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MATCH_MAPPING] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MATCH_SEQUENCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MATCH_KEYS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [GET_YIELD_FROM_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FOR_ITER] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FOR_ITER_LIST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FOR_ITER_TUPLE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FOR_ITER_RANGE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FOR_ITER_GEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BEFORE_ASYNC_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BEFORE_WITH] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [WITH_EXCEPT_START] = { 4, 5, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [PUSH_EXC_INFO] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_METHOD_WITH_VALUES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_METHOD_WITH_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_METHOD_NO_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [LOAD_ATTR_METHOD_LAZY_DICT] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_BOUND_METHOD_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [KW_NAMES] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_PY_EXACT_ARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_PY_WITH_DEFAULTS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_TYPE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_STR_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_TUPLE_1] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_BUILTIN_CLASS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_BUILTIN_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_BUILTIN_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_LEN] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_ISINSTANCE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_LIST_APPEND] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CALL_FUNCTION_EX] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [MAKE_FUNCTION] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [RETURN_GENERATOR] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BUILD_SLICE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [FORMAT_VALUE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [COPY] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [BINARY_OP] = { 2, 1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IBC" }, + [SWAP] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [EXTENDED_ARG] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, + [CACHE] = { -1, -1, DIR_NONE, DIR_NONE, DIR_NONE, true, "IB" }, }; diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index c0136258f7bf0b..7452b2ced05254 100644 --- a/Tools/cases_generator/generate_cases.py +++ b/Tools/cases_generator/generate_cases.py @@ -643,6 +643,7 @@ def write_metadata(self) -> None: self.out.emit("enum Direction dir_op2;") self.out.emit("enum Direction dir_op3;") self.out.emit("bool valid_entry;") + self.out.emit("char instr_format[10];") self.out.emit("} _PyOpcode_opcode_metadata[256] = {") # Write metadata for each instruction @@ -661,6 +662,46 @@ def write_metadata(self) -> None: # Write end of array self.out.emit("};") + def get_format(self, thing: Instruction | SuperInstruction | MacroInstruction) -> str: + """Get the format string for a single instruction.""" + def instr_format(instr: Instruction) -> str: + if instr.register: + fmt = "IBBB" + else: + fmt = "IB" + cache = "C" + for ce in instr.cache_effects: + for _ in range(ce.size): + fmt += cache + cache = "0" + return fmt + match thing: + case Instruction(): + format = instr_format(thing) + case SuperInstruction(): + format = "" + for part in thing.parts: + format += instr_format(part.instr) + case MacroInstruction(): + # Macros don't support register instructions yet + format = "IB" + cache = "C" + for part in thing.parts: + if isinstance(part, parser.CacheEffect): + for _ in range(part.size): + format += cache + cache = "0" + else: + assert isinstance(part, Component) + for ce in part.instr.cache_effects: + for _ in range(ce.size): + format += cache + cache = "0" + case _: + typing.assert_never(thing) + assert len(format) < 10 # Else update the size of instr_format above + return format + def write_metadata_for_inst(self, instr: Instruction) -> None: """Write metadata for a single instruction.""" dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" @@ -676,8 +717,9 @@ def write_metadata_for_inst(self, instr: Instruction) -> None: directions.extend("DIR_WRITE" for _ in instr.output_effects) directions.extend("DIR_NONE" for _ in range(3)) dir_op1, dir_op2, dir_op3 = directions[:3] + format = self.get_format(instr) self.out.emit( - f" [{instr.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + f' [{instr.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true, "{format}" }},' ) def write_metadata_for_super(self, sup: SuperInstruction) -> None: @@ -685,25 +727,20 @@ def write_metadata_for_super(self, sup: SuperInstruction) -> None: n_popped = sum(len(comp.instr.input_effects) for comp in sup.parts) n_pushed = sum(len(comp.instr.output_effects) for comp in sup.parts) dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" + format = self.get_format(sup) self.out.emit( - f" [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + f' [{sup.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true, "{format}" }},' ) def write_metadata_for_macro(self, mac: MacroInstruction) -> None: """Write metadata for a macro-instruction.""" - n_popped = sum( - len(comp.instr.input_effects) - for comp in mac.parts - if isinstance(comp, Component) - ) - n_pushed = sum( - len(comp.instr.output_effects) - for comp in mac.parts - if isinstance(comp, Component) - ) + parts = [comp for comp in mac.parts if isinstance(comp, Component)] + n_popped = sum(len(comp.instr.input_effects) for comp in parts) + n_pushed = sum(len(comp.instr.output_effects) for comp in parts) dir_op1 = dir_op2 = dir_op3 = "DIR_NONE" + format = self.get_format(mac) self.out.emit( - f" [{mac.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true }}," + f' [{mac.name}] = {{ {n_popped}, {n_pushed}, {dir_op1}, {dir_op2}, {dir_op3}, true, "{format}" }},' ) def write_instructions(self) -> None: