[pypy-svn] pypy jit-virtual_state: dont make the same mistake twice

hakanardo commits-noreply at bitbucket.org
Tue Feb 8 19:30:34 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-virtual_state
Changeset: r41713:3ee660b2f234
Date: 2011-02-08 19:29 +0100
http://bitbucket.org/pypy/pypy/changeset/3ee660b2f234/

Log:	dont make the same mistake twice

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -671,8 +671,20 @@
                                         "jumping to preamble instead")
                             self.emit_operation(op)
                         return
-                if not self.retraced:    
-                    raise RetraceLoop
+                if not self.retraced:
+                    if not descr.failed_states:
+                        raise RetraceLoop
+                    for failed in descr.failed_states:
+                        if failed.generalization_of(virtual_state):
+                            # Retracing once more will most likely fail again
+                            break
+                    else:
+                        raise RetraceLoop
+                else:
+                    if not descr.failed_states:
+                        descr.failed_states=[virtual_state]
+                    else:
+                        descr.failed_states.append(virtual_state)
         self.emit_operation(op)
                 
         

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_basic.py
--- a/pypy/jit/metainterp/test/test_basic.py
+++ b/pypy/jit/metainterp/test/test_basic.py
@@ -1498,8 +1498,8 @@
             return x
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
-        self.check_loops(guard_class=0, guard_value=3)        
-        self.check_loops(guard_class=0, guard_value=6, everywhere=True)
+        self.check_loops(guard_class=0, guard_value=2)        
+        self.check_loops(guard_class=0, guard_value=5, everywhere=True)
 
     def test_merge_guardnonnull_guardclass(self):
         from pypy.rlib.objectmodel import instantiate
@@ -1528,9 +1528,9 @@
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
         self.check_loops(guard_class=0, guard_nonnull=0,
-                         guard_nonnull_class=2, guard_isnull=1)
+                         guard_nonnull_class=2, guard_isnull=0)
         self.check_loops(guard_class=0, guard_nonnull=0,
-                         guard_nonnull_class=4, guard_isnull=2,
+                         guard_nonnull_class=4, guard_isnull=1,
                          everywhere=True)
 
     def test_merge_guardnonnull_guardvalue(self):
@@ -1558,9 +1558,9 @@
             return x
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=1,
                          guard_nonnull_class=0, guard_isnull=1)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=4,
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
                          guard_nonnull_class=0, guard_isnull=2,
                          everywhere=True)
 
@@ -1590,9 +1590,9 @@
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
         self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
-                         guard_nonnull_class=0, guard_isnull=1)
+                         guard_nonnull_class=0, guard_isnull=0)
         self.check_loops(guard_class=0, guard_nonnull=0, guard_value=4,
-                         guard_nonnull_class=0, guard_isnull=2,
+                         guard_nonnull_class=0, guard_isnull=1,
                          everywhere=True)
 
     def test_merge_guardnonnull_guardclass_guardvalue(self):
@@ -1623,10 +1623,10 @@
             return x
         res = self.meta_interp(f, [399], listops=True)
         assert res == f(399)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
-                         guard_nonnull_class=0, guard_isnull=1)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=6,
-                         guard_nonnull_class=0, guard_isnull=2,
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
+                         guard_nonnull_class=0, guard_isnull=0)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=5,
+                         guard_nonnull_class=0, guard_isnull=1,
                          everywhere=True)
 
     def test_residual_call_doesnt_lose_info(self):

diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -749,6 +749,7 @@
     generated assembler.
     """
     short_preamble = None
+    failed_states = None
     terminating = False # see TerminatingLoopToken in compile.py
     outermost_jitdriver_sd = None
     # and more data specified by the backend when the loop is compiled

diff --git a/pypy/jit/metainterp/test/test_virtual.py b/pypy/jit/metainterp/test/test_virtual.py
--- a/pypy/jit/metainterp/test/test_virtual.py
+++ b/pypy/jit/metainterp/test/test_virtual.py
@@ -562,6 +562,7 @@
                 n -= 1
             return node1.value + node2.value
         assert self.meta_interp(f, [40, 3]) == f(40, 3)
+        self.check_loop_count(6)
 
     def test_virtual_array_bridge(self):
         myjitdriver = JitDriver(greens = [], reds = ['n', 'node'])


More information about the Pypy-commit mailing list