Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: improve-heap-caching-tracing Changeset: r47138:60e23189885e Date: 2011-09-07 14:13 +0200 http://bitbucket.org/pypy/pypy/changeset/60e23189885e/
Log: make list allocation go through the heap cache 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 @@ -480,11 +480,9 @@ @arguments("descr", "descr", "descr", "descr", "box") def opimpl_newlist(self, structdescr, lengthdescr, itemsdescr, arraydescr, sizebox): - # XXX use heapcache - sbox = self.metainterp.execute_and_record(rop.NEW, structdescr) + sbox = self.opimpl_new(structdescr) self._opimpl_setfield_gc_any(sbox, lengthdescr, sizebox) - abox = self.metainterp.execute_and_record(rop.NEW_ARRAY, arraydescr, - sizebox) + abox = self.opimpl_new_array(arraydescr, sizebox) self._opimpl_setfield_gc_any(sbox, itemsdescr, abox) return sbox 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 @@ -521,6 +521,29 @@ assert res == 2 * 7 + 2 * 8 self.check_operations_history(getarrayitem_gc=2) + + def test_heap_caching_multiple_lists(self): + class Gbl(object): + pass + g = Gbl() + g.l = [] + def fn(n): + if n < -100: + g.l.append(1) + a1 = [n, n, n] + g.l = a1 + a1[0] = n + a2 = [n, n, n] + g.l = a2 + a2[0] = n - 1 + return a1[0] + a2[0] + a1[0] + a2[0] + res = self.interp_operations(fn, [7]) + assert res == 2 * 7 + 2 * 6 + self.check_operations_history(getarrayitem_gc=0, getfield_gc=0) + res = self.interp_operations(fn, [-7]) + assert res == 2 * -7 + 2 * -8 + self.check_operations_history(getarrayitem_gc=0, getfield_gc=0) + def test_length_caching(self): class Gbl(object): pass _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit