[pypy-commit] pypy gc_no_cleanup_nursery: A failing test (couldn't get one without the extra check in

arigo noreply at buildbot.pypy.org
Sun Sep 28 19:09:10 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: gc_no_cleanup_nursery
Changeset: r73738:bd4b98bd22c8
Date: 2014-09-28 18:54 +0200
http://bitbucket.org/pypy/pypy/changeset/bd4b98bd22c8/

Log:	A failing test (couldn't get one without the extra check in
	get_item_value(), but something similar is what occurs in a
	translated pypy)

diff --git a/rpython/jit/metainterp/optimizeopt/virtualize.py b/rpython/jit/metainterp/optimizeopt/virtualize.py
--- a/rpython/jit/metainterp/optimizeopt/virtualize.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualize.py
@@ -284,7 +284,8 @@
         method returns the value that must be set into an array that
         was allocated with zero=True if 'clear' is True."""
         subvalue = self._items[i]
-        if self.clear and subvalue is self.constvalue:
+        if self.clear and (subvalue is self.constvalue or
+                           subvalue.is_null()):
             subvalue = None
         return subvalue
 
diff --git a/rpython/jit/metainterp/test/test_virtual.py b/rpython/jit/metainterp/test/test_virtual.py
--- a/rpython/jit/metainterp/test/test_virtual.py
+++ b/rpython/jit/metainterp/test/test_virtual.py
@@ -707,6 +707,25 @@
             return node[0] + node[1]
         assert self.meta_interp(f, [40]) == f(40)
 
+    def test_virtual_array_with_nulls(self):
+        class Foo:
+            pass
+        myjitdriver = JitDriver(greens=[], reds=['n', 'node'])
+        def f(n):
+            node = [None, Foo()]
+            while n > 0:
+                myjitdriver.can_enter_jit(n=n, node=node)
+                myjitdriver.jit_merge_point(n=n, node=node)
+                newnode = [None] * 2
+                if (n >> 3) & 1:
+                    newnode[1] = node[1]
+                else:
+                    newnode[1] = node[1]
+                node = newnode
+                n -= 1
+            return 42
+        assert self.meta_interp(f, [40]) == 42
+
     def test_this_doesnt_force1(self):
         mydriver = JitDriver(reds=['i', 'j'], greens=[])
         def f():


More information about the pypy-commit mailing list