FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-37271: Optimize bytecode multiple times until it cannot be optimized further by pablogsal · Pull Request #14068 · python/cpython · GitHub

/ cpython Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (3) .py  (1) .rst  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
26 changes: 17 additions & 9 deletions Lib/test/test_peepholer.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,32 @@ def f(cond, true_value, false_value):

def test_elim_jump_to_uncond_jump(self):
# POP_JUMP_IF_FALSE to JUMP_FORWARD --> POP_JUMP_IF_FALSE to non-jump
# JUMP_FORWARD to JUMP_FORWARD --> JUMP_FORWARD to non-jump
def f():
if a:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
foo()
if b:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
foo()
else:
bar()
else:
baz()
self.check_jump_targets(f)

def test_elim_jump_to_uncond_jump2(self):
# POP_JUMP_IF_FALSE to JUMP_ABSOLUTE --> POP_JUMP_IF_FALSE to non-jump
# JUMP_FORWARD to JUMP_ABSOLUTE --> JUMP_FORWARD to non-jump
def f():
while a:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
a = foo()
if b:
# Intentionally use two-line expression to test issue37213.
if (c
or d):
a = foo()
else:
a = bar()
self.check_jump_targets(f)

def test_elim_jump_to_uncond_jump3(self):
Expand Down Expand Up @@ -370,7 +378,7 @@ def f(cond1, cond2):
# There should be one jump for the while loop.
returns = [instr for instr in dis.get_instructions(f)
if instr.opname == 'JUMP_ABSOLUTE']
self.assertEqual(len(returns), 1)
self.assertEqual(len(returns), 0)
returns = [instr for instr in dis.get_instructions(f)
if instr.opname == 'RETURN_VALUE']
self.assertLessEqual(len(returns), 2)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The peephole optimizer now does multiple runs until the resulting bytecode
cannot be optimized further. Patch by Pablo Galindo.
Loading

Back | FazBrowse Home | New Git URL