[pypy-commit] pypy improve-heap-caching-tracing: fix XXX: also record newness of non-vtable memory

cfbolz noreply at buildbot.pypy.org
Wed Sep 7 15:13:14 CEST 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: improve-heap-caching-tracing
Changeset: r47136:f7596aea7542
Date: 2011-09-07 11:35 +0200
http://bitbucket.org/pypy/pypy/changeset/f7596aea7542/

Log:	fix XXX: also record newness of non-vtable memory add a new one XXX

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
@@ -367,8 +367,9 @@
 
     @arguments("descr")
     def opimpl_new(self, sizedescr):
-        # XXX heapcache.new
-        return self.execute_with_descr(rop.NEW, sizedescr)
+        resbox = self.execute_with_descr(rop.NEW, sizedescr)
+        self.metainterp.heapcache.new(resbox)
+        return resbox
 
     @arguments("descr")
     def opimpl_new_with_vtable(self, sizedescr):
@@ -544,6 +545,7 @@
         if tobox is not None:
             return tobox
         resbox = self.execute_with_descr(opnum, fielddescr, box)
+        # XXX getfield_now_known
         self.metainterp.heapcache.setfield(box, fielddescr, resbox)
         return resbox
 
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
@@ -450,6 +450,26 @@
         assert res == 2 * -7 + 2 * -8
         self.check_operations_history(getfield_gc=0)
 
+    def test_heap_caching_multiple_tuples(self):
+        class Gbl(object):
+            pass
+        g = Gbl()
+        def gn(a1, a2):
+            return a1[0] + a2[0]
+        def fn(n):
+            a1 = (n, )
+            g.a = a1
+            a2 = (n - 1, )
+            g.a = a2
+            jit.promote(n)
+            return a1[0] + a2[0] + gn(a1, a2)
+        res = self.interp_operations(fn, [7])
+        assert res == 2 * 7 + 2 * 6
+        self.check_operations_history(getfield_gc_pure=0)
+        res = self.interp_operations(fn, [-7])
+        assert res == 2 * -7 + 2 * -8
+        self.check_operations_history(getfield_gc_pure=0)
+
     def test_heap_caching_multiple_arrays(self):
         class Gbl(object):
             pass


More information about the pypy-commit mailing list