Author: Antonio Cuni <[email protected]>
Branch: virtual-raw-mallocs
Changeset: r59537:15d965e53419
Date: 2012-12-23 18:02 +0100
http://bitbucket.org/pypy/pypy/changeset/15d965e53419/

Log:    add a test for a virtual which survives one iteration of the loop,
        and fix it

diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py 
b/pypy/jit/metainterp/optimizeopt/virtualstate.py
--- a/pypy/jit/metainterp/optimizeopt/virtualstate.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py
@@ -593,7 +593,7 @@
     def make_varraystruct(self, arraydescr, fielddescrs):
         return VArrayStructStateInfo(arraydescr, fielddescrs)
 
-    def make_vrawbuffer(self):
+    def make_vrawbuffer(self, size, offsets, descrs):
         return VRawBufferStateInfo()
 
 class BoxNotProducable(Exception):
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
@@ -1244,6 +1244,28 @@
         # the getarrayitem_raw is in the bridge
         self.check_resops(getarrayitem_raw=1, setarrayitem_raw=0)
 
+    def test_raw_malloc_two_iterations(self):
+        mydriver = JitDriver(greens=[], reds = 'auto')
+        def f(n):
+            res = 0
+            buffer = lltype.malloc(rffi.CCHARP.TO, 1, flavor='raw')
+            buffer[0] = chr(0)
+            while ord(buffer[0]) < n:
+                mydriver.jit_merge_point()
+                i = ord(buffer[0])
+                lltype.free(buffer, flavor='raw')
+                buffer = lltype.malloc(rffi.CCHARP.TO, 1, flavor='raw')
+                buffer[0] = chr(i+1)
+                res += i
+            lltype.free(buffer, flavor='raw')
+            return res
+        assert f(10) == 45
+        res = self.meta_interp(f, [10])
+        assert res == 45
+        # the getarrayitem_raw is in the preamble
+        self.check_resops(getarrayitem_raw=1, setarrayitem_raw=0)
+
+
 
 
 OONODE = ootype.Instance('NODE', ootype.ROOT, {})
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to