[pypy-svn] pypy jit-str_in_preamble: forcing unsupported vritauls changes the VirtualState

hakanardo commits-noreply at bitbucket.org
Sun Mar 27 13:06:46 CEST 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-str_in_preamble
Changeset: r42981:31a39eb2e87b
Date: 2011-03-27 13:06 +0200
http://bitbucket.org/pypy/pypy/changeset/31a39eb2e87b/

Log:	forcing unsupported vritauls changes the VirtualState

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
@@ -262,13 +262,13 @@
             assert jumpop.getdescr() is loop.token
             jump_args = jumpop.getarglist()
             jumpop.initarglist([])
-            #virtual_state = [self.getvalue(a).is_virtual() for a in jump_args]
-            modifier = VirtualStateAdder(self.optimizer)
-            virtual_state = modifier.get_virtual_state(jump_args)
 
             loop.preamble.operations = self.optimizer.newoperations
             preamble_optimizer = self.optimizer
             self.optimizer = self.optimizer.reconstruct_for_next_iteration(jump_args)
+            modifier = VirtualStateAdder(self.optimizer)
+            virtual_state = modifier.get_virtual_state(jump_args)
+
             try:
                 inputargs = self.inline(self.cloned_operations,
                                         loop.inputargs, jump_args)

diff --git a/pypy/jit/metainterp/test/test_string.py b/pypy/jit/metainterp/test/test_string.py
--- a/pypy/jit/metainterp/test/test_string.py
+++ b/pypy/jit/metainterp/test/test_string.py
@@ -389,6 +389,23 @@
         for c1, c2 in zip(s1.chars, s2):
             assert c1==c2
 
+    def test_string_in_virtual_state(self):
+        _str = self._str
+        s1 = _str("a")
+        s2 = _str("AA")
+        mydriver = JitDriver(reds = ['i', 'n', 'sa'], greens = [])
+        def f(n):
+            sa = s1
+            i = 0
+            while i < n:
+                mydriver.jit_merge_point(i=i, n=n, sa=sa)
+                if i&4 == 0:
+                    sa += s1
+                else:
+                    sa += s2
+                i += 1
+            return len(sa)
+        assert self.meta_interp(f, [16]) == f(16)
 
 #class TestOOtype(StringTests, OOJitMixin):
 #    CALL = "oosend"


More information about the Pypy-commit mailing list