diff options
author | Mark Shannon <mark@hotpy.org> | 2021-05-07 14:19:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 14:19:19 (GMT) |
commit | adcd2205565f91c6719f4141ab4e1da6d7086126 (patch) | |
tree | 0953b285944eccde57b05b8f3c7e30fb501a3d64 /Lib/opcode.py | |
parent | b32c8e97951db46484ba3b646b988bcdc4062199 (diff) | |
download | cpython-adcd2205565f91c6719f4141ab4e1da6d7086126.zip cpython-adcd2205565f91c6719f4141ab4e1da6d7086126.tar.gz cpython-adcd2205565f91c6719f4141ab4e1da6d7086126.tar.bz2 |
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%.
Diffstat (limited to 'Lib/opcode.py')
-rw-r--r-- | Lib/opcode.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/opcode.py b/Lib/opcode.py index 37e88e9..88022a4 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -86,11 +86,15 @@ def_op('MATCH_MAPPING', 31) def_op('MATCH_SEQUENCE', 32) def_op('MATCH_KEYS', 33) def_op('COPY_DICT_WITHOUT_KEYS', 34) +def_op('PUSH_EXC_INFO', 35) + +def_op('POP_EXCEPT_AND_RERAISE', 37) def_op('WITH_EXCEPT_START', 49) def_op('GET_AITER', 50) def_op('GET_ANEXT', 51) def_op('BEFORE_ASYNC_WITH', 52) +def_op('BEFORE_WITH', 53) def_op('END_ASYNC_FOR', 54) def_op('INPLACE_ADD', 55) @@ -124,7 +128,6 @@ def_op('RETURN_VALUE', 83) def_op('IMPORT_STAR', 84) def_op('SETUP_ANNOTATIONS', 85) def_op('YIELD_VALUE', 86) -def_op('POP_BLOCK', 87) def_op('POP_EXCEPT', 89) @@ -164,7 +167,6 @@ def_op('CONTAINS_OP', 118) def_op('RERAISE', 119) jabs_op('JUMP_IF_NOT_EXC_MATCH', 121) -jrel_op('SETUP_FINALLY', 122) # Distance to target address def_op('LOAD_FAST', 124) # Local variable number haslocal.append(124) @@ -190,7 +192,7 @@ hasfree.append(138) def_op('CALL_FUNCTION_KW', 141) # #args + #kwargs def_op('CALL_FUNCTION_EX', 142) # Flags -jrel_op('SETUP_WITH', 143) + def_op('EXTENDED_ARG', 144) EXTENDED_ARG = 144 def_op('LIST_APPEND', 145) @@ -201,7 +203,6 @@ hasfree.append(148) def_op('MATCH_CLASS', 152) -jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) def_op('BUILD_CONST_KEY_MAP', 156) def_op('BUILD_STRING', 157) |