[pypy-commit] pypy exc-later: Add a hack to make implicit Exception exitcases around function calls explicit again
rlamy
noreply at buildbot.pypy.org
Wed Mar 18 18:26:42 CET 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exc-later
Changeset: r76460:53e4a161bd86
Date: 2015-03-18 17:22 +0000
http://bitbucket.org/pypy/pypy/changeset/53e4a161bd86/
Log: Add a hack to make implicit Exception exitcases around function
calls explicit again
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -352,25 +352,34 @@
flowcontext.py).
"""
for block in list(graph.iterblocks()):
- for i in range(len(block.exits)-1, -1, -1):
- exit = block.exits[i]
- if not (exit.target is graph.exceptblock and
- exit.args[0] == Constant(AssertionError)):
+ for i in range(len(block.exits)-1, -1, -1):
+ exit = block.exits[i]
+ if not (exit.target is graph.exceptblock and
+ exit.args[0] == Constant(AssertionError)):
+ continue
+ # can we remove this exit without breaking the graph?
+ if len(block.exits) < 2:
+ break
+ if block.canraise:
+ if exit.exitcase is None:
+ break
+ elif (exit.exitcase is Exception and
+ block.raising_op.opname
+ in ('simple_call', 'call_args')):
+ v_etype = Variable('last_exception')
+ v_exc = Variable('last_exc_value')
+ exit.args = [v_etype, v_exc]
+ exit.last_exception = v_etype
+ exit.last_exc_value = v_exc
continue
- # can we remove this exit without breaking the graph?
- if len(block.exits) < 2:
- break
- if block.canraise:
- if exit.exitcase is None:
- break
- if len(block.exits) == 2:
- # removing the last non-exceptional exit
- block.exitswitch = None
- exit.exitcase = None
- # remove this exit
- lst = list(block.exits)
- del lst[i]
- block.recloseblock(*lst)
+ if len(block.exits) == 2:
+ # removing the last non-exceptional exit
+ block.exitswitch = None
+ exit.exitcase = None
+ # remove this exit
+ lst = list(block.exits)
+ del lst[i]
+ block.recloseblock(*lst)
# _____________________________________________________________________
More information about the pypy-commit
mailing list