[pypy-svn] r66487 - in pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Tue Jul 21 19:44:52 CEST 2009


Author: arigo
Date: Tue Jul 21 19:44:52 2009
New Revision: 66487

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
Remove unneeded guard_no_exceptions.


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/optimizeopt.py	Tue Jul 21 19:44:52 2009
@@ -204,6 +204,7 @@
     # ----------
 
     def propagate_forward(self):
+        self.exception_might_have_happened = False
         self.newoperations = []
         for op in self.loop.operations:
             opnum = op.opnum
@@ -226,6 +227,8 @@
                         must_clone = False
                     op.args[i] = box
         self.newoperations.append(op)
+        if op.can_raise():
+            self.exception_might_have_happened = True
 
     def optimize_default(self, op):
         if op.is_always_pure():
@@ -278,6 +281,12 @@
         self.emit_operation(op)
         value.make_constant_class()
 
+    def optimize_GUARD_NO_EXCEPTION(self, op):
+        if not self.exception_might_have_happened:
+            return
+        self.emit_operation(op)
+        self.exception_might_have_happened = False
+
     def optimize_OONONNULL(self, op):
         if self.known_nonnull(op.args[0]):
             assert op.result.getint() == 1

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/test/test_optimizeopt.py	Tue Jul 21 19:44:52 2009
@@ -301,6 +301,35 @@
 
     # ----------
 
+    def test_fold_guard_no_exception(self):
+        ops = """
+        [i]
+        guard_no_exception()
+            fail()
+        i1 = int_add(i, 3)
+        guard_no_exception()
+            fail()
+        i2 = call(i1)
+        guard_no_exception()
+            fail(i1, i2)
+        guard_no_exception()
+            fail()
+        i3 = call(i2)
+        jump(i1)       # the exception is considered lost when we loop back
+        """
+        expected = """
+        [i]
+        i1 = int_add(i, 3)
+        i2 = call(i1)
+        guard_no_exception()
+            fail(i1, i2)
+        i3 = call(i2)
+        jump(i1)
+        """
+        self.optimize_loop(ops, 'Not', expected)
+
+    # ----------
+
     def test_virtual_1(self):
         ops = """
         [i, p0]



More information about the Pypy-commit mailing list