Author: Armin Rigo <ar...@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():
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to