From adcd2205565f91c6719f4141ab4e1da6d7086126 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Fri, 7 May 2021 15:19:19 +0100 Subject: bpo-40222: "Zero cost" exception handling (GH-25729) "Zero cost" exception handling. * Uses a lookup table to determine how to handle exceptions. * Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements. * Reduces the size of the frame object by about 60%. --- Tools/scripts/generate_opcode_h.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Tools/scripts/generate_opcode_h.py') diff --git a/Tools/scripts/generate_opcode_h.py b/Tools/scripts/generate_opcode_h.py index cba13b24213..290f6251af1 100644 --- a/Tools/scripts/generate_opcode_h.py +++ b/Tools/scripts/generate_opcode_h.py @@ -16,14 +16,12 @@ extern "C" { """.lstrip() footer = """ -/* EXCEPT_HANDLER is a special, implicit block type which is created when - entering an except handler. It is not an opcode but we define it here - as we want it to be available to both frameobject.c and ceval.c, while - remaining private.*/ -#define EXCEPT_HANDLER 257 - #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) +/* Reserve some bytecodes for internal use in the compiler. + * The value of 240 is arbitrary. */ +#define IS_ARTIFICIAL(op) ((op) > 240) + #ifdef __cplusplus } #endif -- cgit v1.2.3