[pypy-commit] pypy heap-caching-during-tracing: make new construction go via the normal setfield code

cfbolz noreply at buildbot.pypy.org
Sun Jul 17 00:38:04 CEST 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: heap-caching-during-tracing
Changeset: r45690:34414cbab3ef
Date: 2011-07-17 00:22 +0200
http://bitbucket.org/pypy/pypy/changeset/34414cbab3ef/

Log:	make new construction go via the normal setfield code

diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -474,12 +474,10 @@
     def opimpl_newlist(self, structdescr, lengthdescr, itemsdescr, arraydescr,
                        sizebox):
         sbox = self.metainterp.execute_and_record(rop.NEW, structdescr)
-        self.metainterp.execute_and_record(rop.SETFIELD_GC, lengthdescr,
-                                           sbox, sizebox)
+        self._opimpl_setfield_gc_any(sbox, lengthdescr, sizebox)
         abox = self.metainterp.execute_and_record(rop.NEW_ARRAY, arraydescr,
                                                   sizebox)
-        self.metainterp.execute_and_record(rop.SETFIELD_GC, itemsdescr,
-                                           sbox, abox)
+        self._opimpl_setfield_gc_any(sbox, itemsdescr, abox)
         return sbox
 
     @arguments("box", "descr", "descr", "box")
diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py
--- a/pypy/jit/metainterp/test/test_tracingopts.py
+++ b/pypy/jit/metainterp/test/test_tracingopts.py
@@ -300,3 +300,18 @@
         assert res == -7 * 2
         self.check_operations_history(getarrayitem_gc=1,
                 getfield_gc=3)
+
+    def test_list_caching_negative(self):
+        def fn(n):
+            jit.promote(n)
+            a = [0] * n
+            if n > 1000:
+                a.append(0)
+            a[-1] = n
+            x1 = a[-1]
+            a[n - n - 1] = n + 1
+            return a[-1] + x1
+        res = self.interp_operations(fn, [7])
+        assert res == 7 + 7 + 1
+        self.check_operations_history(setarrayitem_gc=2,
+                setfield_gc=2)


More information about the pypy-commit mailing list