summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-09-13 12:03:41 (GMT)
committerGitHub <noreply@github.com>2022-09-13 12:03:41 (GMT)
commit6d7a0e0dd760d4e01e512aad3819c3306c3641a3 (patch)
tree5905a7efc77c2432f128db93df048f060c369e0c /Lib
parent49cceeb5c998a51bb12b7dbde17b53647bb52113 (diff)
downloadcpython-6d7a0e0dd760d4e01e512aad3819c3306c3641a3.zip
cpython-6d7a0e0dd760d4e01e512aad3819c3306c3641a3.tar.gz
cpython-6d7a0e0dd760d4e01e512aad3819c3306c3641a3.tar.bz2
gh-87092: reduce redundancy and repetition in compiler's optimization stage (GH-96713)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dis.py27
-rw-r--r--Lib/test/test_peepholer.py2
2 files changed, 20 insertions, 9 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 48d5960..fc2862c 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -360,13 +360,13 @@ dis_traceback = """\
--> BINARY_OP 11 (/)
POP_TOP
-%3d >> LOAD_FAST_CHECK 1 (tb)
+%3d LOAD_FAST_CHECK 1 (tb)
RETURN_VALUE
>> PUSH_EXC_INFO
%3d LOAD_GLOBAL 0 (Exception)
CHECK_EXC_MATCH
- POP_JUMP_IF_FALSE 22 (to 80)
+ POP_JUMP_IF_FALSE 23 (to 82)
STORE_FAST 0 (e)
%3d LOAD_FAST 0 (e)
@@ -376,7 +376,9 @@ dis_traceback = """\
LOAD_CONST 0 (None)
STORE_FAST 0 (e)
DELETE_FAST 0 (e)
- JUMP_BACKWARD 29 (to 14)
+
+%3d LOAD_FAST 1 (tb)
+ RETURN_VALUE
>> LOAD_CONST 0 (None)
STORE_FAST 0 (e)
DELETE_FAST 0 (e)
@@ -394,6 +396,7 @@ ExceptionTable:
TRACEBACK_CODE.co_firstlineno + 5,
TRACEBACK_CODE.co_firstlineno + 3,
TRACEBACK_CODE.co_firstlineno + 4,
+ TRACEBACK_CODE.co_firstlineno + 5,
TRACEBACK_CODE.co_firstlineno + 3)
def _fstring(a, b, c, d):
@@ -440,7 +443,7 @@ dis_with = """\
CALL 2
POP_TOP
-%3d >> LOAD_CONST 2 (2)
+%3d LOAD_CONST 2 (2)
STORE_FAST 2 (y)
LOAD_CONST 0 (None)
RETURN_VALUE
@@ -453,7 +456,11 @@ dis_with = """\
POP_EXCEPT
POP_TOP
POP_TOP
- JUMP_BACKWARD 13 (to 30)
+
+%3d LOAD_CONST 2 (2)
+ STORE_FAST 2 (y)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
>> COPY 3
POP_EXCEPT
RERAISE 1
@@ -465,6 +472,7 @@ ExceptionTable:
_with.__code__.co_firstlineno + 1,
_with.__code__.co_firstlineno + 3,
_with.__code__.co_firstlineno + 1,
+ _with.__code__.co_firstlineno + 3,
)
async def _asyncwith(c):
@@ -502,7 +510,7 @@ dis_asyncwith = """\
JUMP_BACKWARD_NO_INTERRUPT 4 (to 48)
>> POP_TOP
-%3d >> LOAD_CONST 2 (2)
+%3d LOAD_CONST 2 (2)
STORE_FAST 2 (y)
LOAD_CONST 0 (None)
RETURN_VALUE
@@ -526,7 +534,11 @@ dis_asyncwith = """\
POP_EXCEPT
POP_TOP
POP_TOP
- JUMP_BACKWARD 24 (to 58)
+
+%3d LOAD_CONST 2 (2)
+ STORE_FAST 2 (y)
+ LOAD_CONST 0 (None)
+ RETURN_VALUE
>> COPY 3
POP_EXCEPT
RERAISE 1
@@ -538,6 +550,7 @@ ExceptionTable:
_asyncwith.__code__.co_firstlineno + 1,
_asyncwith.__code__.co_firstlineno + 3,
_asyncwith.__code__.co_firstlineno + 1,
+ _asyncwith.__code__.co_firstlineno + 3,
)
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 5f7e50d..ab45e3c 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -344,8 +344,6 @@ class TestTranforms(BytecodeTestCase):
self.assertEqual(len(returns), 1)
self.check_lnotab(f)
- @unittest.skip("Following gh-92228 the return has two predecessors "
- "and that prevents jump elimination.")
def test_elim_jump_to_return(self):
# JUMP_FORWARD to RETURN --> RETURN
def f(cond, true_value, false_value):