[pypy-svn] r12767 - in pypy/dist/pypy/translator: . goal
pedronis at codespeak.net
pedronis at codespeak.net
Tue May 24 14:20:46 CEST 2005
Author: pedronis
Date: Tue May 24 14:20:45 2005
New Revision: 12767
Modified:
pypy/dist/pypy/translator/annrpython.py
pypy/dist/pypy/translator/goal/translate_pypy.py
Log:
- be more aggressive annotating exception handling with constant last_exception
- added sanity check about except blocks to translate_pypy
Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py (original)
+++ pypy/dist/pypy/translator/annrpython.py Tue May 24 14:20:45 2005
@@ -435,6 +435,7 @@
if isinstance(link.exitcase, (types.ClassType, type)) \
and issubclass(link.exitcase, Exception):
+ assert last_exception_var and last_exc_value_var
last_exception_object = annmodel.SomeObject()
last_exception_object.knowntype = type
if isinstance(last_exception_var, Constant):
@@ -454,10 +455,10 @@
for a,v in zip(link.args,link.target.inputargs):
renaming.setdefault(a, []).append(v)
for a,v in zip(link.args,link.target.inputargs):
- if a is last_exception_var:
+ if a == last_exception_var:
assert in_except_block
cells.append(last_exception_object)
- elif a is last_exc_value_var:
+ elif a == last_exc_value_var:
assert in_except_block
cells.append(last_exc_value_object)
last_exc_value_vars.append(v)
Modified: pypy/dist/pypy/translator/goal/translate_pypy.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate_pypy.py (original)
+++ pypy/dist/pypy/translator/goal/translate_pypy.py Tue May 24 14:20:45 2005
@@ -56,6 +56,7 @@
run_async_server()
if not options['-no-a']:
a = t.annotate(inputtypes, overrides=pypy_overrides)
+ sanity_check_exceptblocks(t)
worstblocks_topten(a)
if not options['-no-s']:
a.simplify()
@@ -66,6 +67,25 @@
options['-no-mark-some-objects'] = True # Do not do this again
find_someobjects(t)
+def sanity_check_exceptblocks(translator):
+ annotator = translator.annotator
+ irreg = 0
+ for graph in translator.flowgraphs.itervalues():
+ et, ev = graph.exceptblock.inputargs
+ s_et = annotator.binding(et, extquery=True)
+ s_ev = annotator.binding(ev, extquery=True)
+ if s_et:
+ if s_et.knowntype == type:
+ if s_et.__class__ == SomeObject:
+ if hasattr(s_et, 'is_type_of') and s_et.is_type_of == [ev]:
+ continue
+ else:
+ if s_et.__class__ == annmodel.SomePBC:
+ continue
+ print "*****", graph.name, "exceptblock is not completely sane"
+ irreg += 1
+ if irreg == 0:
+ print "*** All exceptblocks seem sane."
def find_someobjects(translator, quiet=False):
"""Find all functions in that have SomeObject in their signature."""
More information about the Pypy-commit
mailing list