[pypy-svn] r65028 - in pypy/branch/pyjitpl5/pypy/translator: cli oosupport/test_template
antocuni at codespeak.net
antocuni at codespeak.net
Mon May 4 18:31:02 CEST 2009
Author: antocuni
Date: Mon May 4 18:31:00 2009
New Revision: 65028
Modified:
pypy/branch/pyjitpl5/pypy/translator/cli/opcodes.py
pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/overflow.py
Log:
a test and a fix for int_mod_ovf*
Modified: pypy/branch/pyjitpl5/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/cli/opcodes.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/cli/opcodes.py Mon May 4 18:31:00 2009
@@ -19,13 +19,20 @@
return [PushAllArgs, 'call %s class [mscorlib]System.Math::Abs(%s)' % (type_, type_), StoreResult]
def _check_ovf(op):
- mapping = [('[mscorlib]System.OverflowException', 'exceptions.OverflowError')]
+ mapping = [('[mscorlib]System.OverflowException', 'exceptions.OverflowError'),
+ ('[mscorlib]System.ArithmeticException', 'exceptions.OverflowError')]
return [MapException(op, mapping)]
def _check_zer(op):
mapping = [('[mscorlib]System.DivideByZeroException', 'exceptions.ZeroDivisionError')]
return [MapException(op, mapping)]
+def _check_ovf_zer(op):
+ mapping = [('[mscorlib]System.OverflowException', 'exceptions.OverflowError'),
+ ('[mscorlib]System.DivideByZeroException', 'exceptions.ZeroDivisionError'),
+ ('[mscorlib]System.ArithmeticException', 'exceptions.OverflowError')]
+ return [MapException(op, mapping)]
+
# __________ object oriented & misc operations __________
misc_ops = {
'new': [New],
@@ -167,7 +174,7 @@
'int_sub_ovf': _check_ovf('sub.ovf'),
'int_mul_ovf': _check_ovf('mul.ovf'),
'int_floordiv_ovf': 'div', # these can't overflow!
- 'int_mod_ovf': 'rem',
+ 'int_mod_ovf': _check_ovf('rem'),
'int_lt_ovf': 'clt',
'int_le_ovf': _not('cgt'),
'int_eq_ovf': 'ceq',
@@ -183,7 +190,7 @@
'int_rshift_ovf': 'shr', # these can't overflow!
'int_xor_ovf': 'xor',
'int_floordiv_ovf_zer': _check_zer('div'),
- 'int_mod_ovf_zer': _check_zer('rem'),
+ 'int_mod_ovf_zer': _check_ovf_zer('rem'),
'int_mod_zer': _check_zer('rem'),
'uint_add': 'add',
Modified: pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/overflow.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/overflow.py (original)
+++ pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/overflow.py Mon May 4 18:31:00 2009
@@ -56,3 +56,11 @@
except OverflowError:
return 42
self.check(fn, [-sys.maxint-1])
+
+ def test_mod(self):
+ def fn(x, y):
+ try:
+ return ovfcheck(x % y)
+ except OverflowError:
+ return 42
+ self.check(fn, [-sys.maxint-1, -1])
More information about the Pypy-commit
mailing list