[pypy-svn] r78336 - in pypy/branch/jit-unroll-loops/pypy/jit/metainterp: optimizeopt test

hakanardo at codespeak.net hakanardo at codespeak.net
Wed Oct 27 08:17:49 CEST 2010


Author: hakanardo
Date: Wed Oct 27 08:17:48 2010
New Revision: 78336

Modified:
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_virtual.py
Log:
Dont duplicate inputargs

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/optimizeopt/unroll.py	Wed Oct 27 08:17:48 2010
@@ -51,8 +51,9 @@
         self.snapshot_map ={None: None}
         
         inputargs = []
+        seen = []
         for arg in jump_args:
-            for a in self.getvalue(arg).get_forced_boxes([]):
+            for a in self.getvalue(arg).get_forced_boxes(seen):
                 if not isinstance(a, Const):
                     inputargs.append(a)
 

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_virtual.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_virtual.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_virtual.py	Wed Oct 27 08:17:48 2010
@@ -34,6 +34,28 @@
         self.check_loops(new=0, new_with_vtable=0,
                                 getfield_gc=0, setfield_gc=0)
 
+    def test_virtualized2(self):
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'node1', 'node2'])
+        def f(n):
+            node1 = self._new()
+            node1.value = 0
+            node2 = self._new()
+            node2.value = 0
+            while n > 0:
+                myjitdriver.can_enter_jit(n=n, node1=node1, node2=node2)
+                myjitdriver.jit_merge_point(n=n, node1=node1, node2=node2)
+                next1 = self._new()
+                next1.value = node1.value + n + node2.value
+                next2 = self._new()
+                next2.value = next1.value
+                node1 = next1
+                node2 = next2
+                n -= 1
+            return node1.value * node2.value
+        assert f(10) == self.meta_interp(f, [10])
+        self.check_loops(new=0, new_with_vtable=0,
+                         getfield_gc=0, setfield_gc=0)
+
     def test_virtualized_circular1(self):
         class MyNode():
             pass



More information about the Pypy-commit mailing list