Commits

Antonio Cuni committed 3d05b0c

add support for live variables which are between the start of the block and the jit_marker

Comments (0)

Files changed (2)

pypy/jit/metainterp/test/test_ajit.py

         assert res == expected
         self.check_resops(int_sub=2, int_mul=0, int_add=18, float_add=8)
 
+    def test_loop_automatic_reds_livevars_before_jit_merge_point(self):
+        myjitdriver = JitDriver(greens = ['m'], reds = 'auto')
+        def f(n, m):
+            res = 0
+            while n > 0:
+                n -= 1
+                myjitdriver.can_enter_jit(m=m)
+                myjitdriver.jit_merge_point(m=m)
+                res += m*2
+            return res
+        expected = f(21, 5)
+        res = self.meta_interp(f, [21, 5])
+        assert res == expected
+        self.check_resops(int_sub=2, int_mul=0, int_add=2)
+
     def test_loop_variant_mul1(self):
         myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
         def f(x, y):

pypy/jit/metainterp/warmspot.py

                 jitdriver = op.args[1].value
                 if not jitdriver.autoreds:
                     continue
+                # compute the set of live variables before the jit_marker
+                alive_v = set(block.inputargs)
+                for op1 in block.operations:
+                    if op1 is op:
+                        break # stop when the meet the jit_marker
+                    if op1.result.concretetype != lltype.Void:
+                        alive_v.add(op1.result)
                 greens_v = op.args[2:]
-                alive_v = set(block.inputargs) # XXX: there might be more
-                                               # alive vars?
                 reds_v = alive_v - set(greens_v)
                 reds_v = support.sort_vars(reds_v)
                 op.args.extend(reds_v)