[pypy-svn] r74121 - in pypy/branch/blackhole-improvement/pypy/jit: codewriter metainterp metainterp/test

arigo at codespeak.net arigo at codespeak.net
Tue Apr 27 19:44:54 CEST 2010


Author: arigo
Date: Tue Apr 27 19:44:53 2010
New Revision: 74121

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_basic.py
Log:
Fixes, just enough for the test in test_basic.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	Tue Apr 27 19:44:53 2010
@@ -88,7 +88,8 @@
         if len(block.exits) != 2:
             return False
         v = block.exitswitch
-        if isinstance(v, tuple) or v.concretetype != lltype.Bool:
+        if (v == c_last_exception or isinstance(v, tuple)
+            or v.concretetype != lltype.Bool):
             return False
         for link in block.exits:
             if v in link.args:
@@ -132,7 +133,7 @@
         else:
             rewrite(self, op, block)
 
-    def rewrite_exc_op_int_floordiv_ovf_zer(self, op, block):
+    def _rewrite_exc_div_or_mod_ovf_zer(self, op, block):
         # See test_flatten.test_int_floordiv_ovf_zer for the mangling done here
         usedvars = self.list_vars_in_use_at_end(block, op.args, op.result)
         block.operations.pop()
@@ -150,10 +151,14 @@
             ]
         block = self.write_new_condition(block, usedvars, ovf_link,
                                  ('int_ne', v2, Constant(-1, lltype.Signed)))
+        basename = op.opname.split('_')[1]
         block.operations += [
-            SpaceOperation('int_floordiv', op.args, op.result),
+            SpaceOperation('int_' + basename, op.args, op.result),
             ]
 
+    rewrite_exc_op_int_floordiv_ovf_zer = _rewrite_exc_div_or_mod_ovf_zer
+    rewrite_exc_op_int_mod_ovf_zer      = _rewrite_exc_div_or_mod_ovf_zer
+
     def list_vars_in_use_at_end(self, block, extravars=[], exclude=None):
         lists = [extravars]
         for link in block.exits:

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	Tue Apr 27 19:44:53 2010
@@ -277,6 +277,18 @@
         return a * b
 
     @arguments("i", "i", returns="i")
+    def opimpl_int_and(self, a, b):
+        return a & b
+
+    @arguments("i", "i", returns="i")
+    def opimpl_int_floordiv(self, a, b):
+        return llop.int_floordiv(lltype.Signed, a, b)
+
+    @arguments("i", "i", returns="i")
+    def opimpl_int_mod(self, a, b):
+        return llop.int_mod(lltype.Signed, a, b)
+
+    @arguments("i", "i", returns="i")
     def opimpl_uint_floordiv(self, a, b):
         c = llop.uint_floordiv(lltype.Unsigned, r_uint(a), r_uint(b))
         return intmask(c)
@@ -344,6 +356,13 @@
         else:
             return target
 
+    @arguments("L", "i", "pc", returns="L")
+    def opimpl_goto_if_not_int_is_true(self, target, a, pc):
+        if a:
+            return pc
+        else:
+            return target
+
     @arguments("L", returns="L")
     def opimpl_goto(self, target):
         return target

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/test/test_basic.py	Tue Apr 27 19:44:53 2010
@@ -761,21 +761,26 @@
     def test_zerodivisionerror(self):
         # test the case of exception-raising operation that is not delegated
         # to the backend at all: ZeroDivisionError
-        from pypy.rpython.lltypesystem.lloperation import llop
         #
         def f(n):
+            assert n >= 0
             try:
-                return llop.int_mod_ovf_zer(lltype.Signed, 5, n)
+                return ovfcheck(5 % n)
             except ZeroDivisionError:
                 return -666
+            except OverflowError:
+                return -777
         res = self.interp_operations(f, [0])
         assert res == -666
         #
         def f(n):
+            assert n >= 0
             try:
-                return llop.int_floordiv_ovf_zer(lltype.Signed, 6, n)
+                return ovfcheck(6 // n)
             except ZeroDivisionError:
                 return -667
+            except OverflowError:
+                return -778
         res = self.interp_operations(f, [0])
         assert res == -667
 



More information about the Pypy-commit mailing list