summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-01-13 10:30:28 (GMT)
committerGitHub <noreply@github.com>2025-01-13 10:30:28 (GMT)
commitddd959987c557beaf823b681bf5e5e573ad657ac (patch)
treee59574d3eb62f94e497f7aecd585bf656ebc984e /Lib
parent29fe8072cf404b891dde9c1d415095edddbe19de (diff)
downloadcpython-ddd959987c557beaf823b681bf5e5e573ad657ac.zip
cpython-ddd959987c557beaf823b681bf5e5e573ad657ac.tar.gz
cpython-ddd959987c557beaf823b681bf5e5e573ad657ac.tar.bz2
GH-128685: Specialize (rather than quicken) LOAD_CONST into LOAD_CONST_[IM]MORTAL (GH-128708)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_opcode_metadata.py42
-rw-r--r--Lib/test/test_dis.py4
2 files changed, 24 insertions, 22 deletions
diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py
index 64ee56f..d93e8d8 100644
--- a/Lib/_opcode_metadata.py
+++ b/Lib/_opcode_metadata.py
@@ -7,6 +7,7 @@ _specializations = {
"RESUME_CHECK",
],
"LOAD_CONST": [
+ "LOAD_CONST_MORTAL",
"LOAD_CONST_IMMORTAL",
],
"TO_BOOL": [
@@ -178,26 +179,27 @@ _specialized_opmap = {
'LOAD_ATTR_SLOT': 205,
'LOAD_ATTR_WITH_HINT': 206,
'LOAD_CONST_IMMORTAL': 207,
- 'LOAD_GLOBAL_BUILTIN': 208,
- 'LOAD_GLOBAL_MODULE': 209,
- 'LOAD_SUPER_ATTR_ATTR': 210,
- 'LOAD_SUPER_ATTR_METHOD': 211,
- 'RESUME_CHECK': 212,
- 'SEND_GEN': 213,
- 'STORE_ATTR_INSTANCE_VALUE': 214,
- 'STORE_ATTR_SLOT': 215,
- 'STORE_ATTR_WITH_HINT': 216,
- 'STORE_SUBSCR_DICT': 217,
- 'STORE_SUBSCR_LIST_INT': 218,
- 'TO_BOOL_ALWAYS_TRUE': 219,
- 'TO_BOOL_BOOL': 220,
- 'TO_BOOL_INT': 221,
- 'TO_BOOL_LIST': 222,
- 'TO_BOOL_NONE': 223,
- 'TO_BOOL_STR': 224,
- 'UNPACK_SEQUENCE_LIST': 225,
- 'UNPACK_SEQUENCE_TUPLE': 226,
- 'UNPACK_SEQUENCE_TWO_TUPLE': 227,
+ 'LOAD_CONST_MORTAL': 208,
+ 'LOAD_GLOBAL_BUILTIN': 209,
+ 'LOAD_GLOBAL_MODULE': 210,
+ 'LOAD_SUPER_ATTR_ATTR': 211,
+ 'LOAD_SUPER_ATTR_METHOD': 212,
+ 'RESUME_CHECK': 213,
+ 'SEND_GEN': 214,
+ 'STORE_ATTR_INSTANCE_VALUE': 215,
+ 'STORE_ATTR_SLOT': 216,
+ 'STORE_ATTR_WITH_HINT': 217,
+ 'STORE_SUBSCR_DICT': 218,
+ 'STORE_SUBSCR_LIST_INT': 219,
+ 'TO_BOOL_ALWAYS_TRUE': 220,
+ 'TO_BOOL_BOOL': 221,
+ 'TO_BOOL_INT': 222,
+ 'TO_BOOL_LIST': 223,
+ 'TO_BOOL_NONE': 224,
+ 'TO_BOOL_STR': 225,
+ 'UNPACK_SEQUENCE_LIST': 226,
+ 'UNPACK_SEQUENCE_TUPLE': 227,
+ 'UNPACK_SEQUENCE_TWO_TUPLE': 228,
}
opmap = {
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 76d9b54..ed8bd6f 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -892,7 +892,7 @@ dis_loop_test_quickened_code = """\
%3d RESUME_CHECK 0
%3d BUILD_LIST 0
- LOAD_CONST 0 ((1, 2, 3))
+ LOAD_CONST_MORTAL 0 ((1, 2, 3))
LIST_EXTEND 1
LOAD_SMALL_INT 3
BINARY_OP 5 (*)
@@ -2548,7 +2548,7 @@ class TestDisCLI(unittest.TestCase):
expect = '''
0 RESUME 0
- 1 LOAD_CONST_IMMORTAL 0 (None)
+ 1 LOAD_CONST 0 (None)
RETURN_VALUE
'''
for flag in ['-S', '--specialized']: