[pypy-svn] r18164 - in pypy/dist/pypy/translator/llvm: . backendopt
ericvrp at codespeak.net
ericvrp at codespeak.net
Tue Oct 4 21:07:06 CEST 2005
Author: ericvrp
Date: Tue Oct 4 21:07:05 2005
New Revision: 18164
Modified:
pypy/dist/pypy/translator/llvm/backendopt/removeexcmallocs.py
pypy/dist/pypy/translator/llvm/exception.py
Log:
* exception handling policies renamed.
CPython -> invokeunwind
fast -> explicit
* cleanup logging.
Modified: pypy/dist/pypy/translator/llvm/backendopt/removeexcmallocs.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/backendopt/removeexcmallocs.py (original)
+++ pypy/dist/pypy/translator/llvm/backendopt/removeexcmallocs.py Tue Oct 4 21:07:05 2005
@@ -17,6 +17,7 @@
an exception instance 'long' after it has been raised.
"""
n_removed = 0
+ n_removed_of_type = {}
blocks = [x for x in flatten(graph) if isinstance(x, Block)]
for block in blocks:
ops = block.operations
@@ -28,8 +29,14 @@
name = str(ops[0].args[0])
if 'Exception' not in name and 'Error' not in name: #XXX better to look at the actual structure
continue
- log.removeexceptionmallocs('%s from function %s' % (name, ref))
+ #log.removeexceptionmallocs('%s from function %s' % (name, ref))
ops[0].opname = 'malloc_exception' #XXX refactor later to not use a new operationtype
n_removed += 1
+ if name in n_removed_of_type: n_removed_of_type[name] += 1
+ else: n_removed_of_type[name] = 1
+ if n_removed:
+ log.removeexceptionmallocs('%dx' % (n_removed,))
+ for k,v in n_removed_of_type.iteritems():
+ log.removeexceptionmallocs(' -> %dx %s' % (v, k))
return n_removed
Modified: pypy/dist/pypy/translator/llvm/exception.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/exception.py (original)
+++ pypy/dist/pypy/translator/llvm/exception.py Tue Oct 4 21:07:05 2005
@@ -49,13 +49,13 @@
return noresult
def new(exceptionpolicy=None): #factory
- exceptionpolicy = exceptionpolicy or 'fast'
- if exceptionpolicy == 'cpython':
- from pypy.translator.llvm.exception import CPythonExceptionPolicy
- exceptionpolicy = CPythonExceptionPolicy()
- elif exceptionpolicy == 'fast':
- from pypy.translator.llvm.exception import FastExceptionPolicy
- exceptionpolicy = FastExceptionPolicy()
+ exceptionpolicy = exceptionpolicy or 'explicit'
+ if exceptionpolicy == 'invokeunwind':
+ from pypy.translator.llvm.exception import InvokeUnwindExceptionPolicy
+ exceptionpolicy = InvokeUnwindExceptionPolicy()
+ elif exceptionpolicy == 'explicit':
+ from pypy.translator.llvm.exception import ExplicitExceptionPolicy
+ exceptionpolicy = ExplicitExceptionPolicy()
elif exceptionpolicy == 'none':
from pypy.translator.llvm.exception import NoneExceptionPolicy
exceptionpolicy = NoneExceptionPolicy()
@@ -70,7 +70,7 @@
pass
-class CPythonExceptionPolicy(ExceptionPolicy): #uses issubclass() and llvm invoke&unwind
+class InvokeUnwindExceptionPolicy(ExceptionPolicy): #uses issubclass() and llvm invoke&unwind
def __init__(self):
pass
@@ -160,7 +160,7 @@
return '-enable-correct-eh-support'
-class FastExceptionPolicy(ExceptionPolicy): #uses issubclass() and last_exception tests after each call
+class ExplicitExceptionPolicy(ExceptionPolicy): #uses issubclass() and last_exception tests after each call
def __init__(self):
self.invoke_count = 0
More information about the Pypy-commit
mailing list