[pypy-svn] r62584 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp metainterp/test

fijal at codespeak.net fijal at codespeak.net
Thu Mar 5 15:44:45 CET 2009


Author: fijal
Date: Thu Mar  5 15:44:45 2009
New Revision: 62584

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_exception.py
Log:
int_mod_ovf and int_mod_ovf_zer


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Thu Mar  5 15:44:45 2009
@@ -68,6 +68,7 @@
     'int_neg'         : (('int',), 'int'),
     'int_invert'      : (('int',), 'int'),
     'int_add_ovf'     : (('int', 'int'), 'int'),
+    'int_mod_ovf'     : (('int', 'int'), 'int'),
     'int_sub_ovf'     : (('int', 'int'), 'int'),
     'int_mul_ovf'     : (('int', 'int'), 'int'),
     'int_neg_ovf'     : (('int',), 'int'),
@@ -866,7 +867,7 @@
         return res
 
     for _opname in ['int_add_ovf', 'int_sub_ovf', 'int_mul_ovf',
-                    'int_neg_ovf',
+                    'int_neg_ovf', 'int_mod_ovf',
                     ]:
         exec py.code.Source('''
             def op_%s(self, *args):

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/codewriter.py	Thu Mar  5 15:44:45 2009
@@ -162,7 +162,7 @@
 
 
 class BytecodeMaker(object):
-    debug = True
+    debug = False
     
     def __init__(self, codewriter, graph, portal):
         self.codewriter = codewriter
@@ -197,6 +197,8 @@
         self.bytecode._labelpos = labelpos
         if self.debug:
             self.bytecode.dump()
+        else:
+            print repr(self.bytecode)
 
     def const_position(self, constvalue):
         """Generate a constant of the given value.
@@ -466,6 +468,10 @@
     def serialize_op_int_add_nonneg_ovf(self, op):
         self.default_serialize_op(op, 'int_add_ovf')
 
+    def serialize_op_int_mod_ovf_zer(self, op):
+        # XXX handle ZeroDivisionError
+        self.default_serialize_op(op, 'int_mod_ovf')
+
     def serialize_op_hint(self, op):
         hints = op.args[1].value
         if hints.get('promote') and op.args[0].concretetype is not lltype.Void:

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py	Thu Mar  5 15:44:45 2009
@@ -236,7 +236,7 @@
                 self.execute(rop.%s, [b1, b2], "int")
         ''' % (_opimpl, _opimpl.upper())).compile()
 
-    for _opimpl in ['int_add_ovf', 'int_sub_ovf', 'int_mul_ovf',
+    for _opimpl in ['int_add_ovf', 'int_sub_ovf', 'int_mul_ovf', 'int_mod_ovf',
                     ]:
         exec py.code.Source('''
             @arguments("box", "box")

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py	Thu Mar  5 15:44:45 2009
@@ -156,7 +156,8 @@
     INT_SUB_OVF            = 111
     INT_MUL_OVF            = 112
     INT_NEG_OVF            = 113
-    _OVF_LAST = 113
+    INT_MOD_OVF            = 114
+    _OVF_LAST = 114
     _CANRAISE_LAST = 119 # ----- end of can_raise operations -----
     _LAST = 119     # for the backend to add more internal operations
 

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_exception.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_exception.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_exception.py	Thu Mar  5 15:44:45 2009
@@ -309,6 +309,17 @@
         res = self.meta_interp(f, [1])
         assert res == expected
 
+    def test_int_mod_ovf_zer(self):
+        def f(x, y):
+            try:
+                return ovfcheck(x%y)
+            except ZeroDivisionError:
+                return 1
+            except OverflowError:
+                return 2
+
+        res = self.interp_operations(f, [1, 2])
+        assert res == 1
 
 class MyError(Exception):
     def __init__(self, n):



More information about the Pypy-commit mailing list