Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: improve-heap-caching-tracing Changeset: r47061:119fa1455e3b Date: 2011-09-04 11:53 +0200 http://bitbucket.org/pypy/pypy/changeset/119fa1455e3b/
Log: fix bug in setfield diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py --- a/pypy/jit/metainterp/heapcache.py +++ b/pypy/jit/metainterp/heapcache.py @@ -65,20 +65,21 @@ def setfield(self, box, descr, fieldbox): # slightly subtle logic here d = self.heap_cache.get(descr, None) - new_d = {box: fieldbox} # a write to an arbitrary box, all other boxes can alias this one if not d or box not in self.new_boxes: # therefore we throw away the cache - self.heap_cache[descr] = new_d + self.heap_cache[descr] = {box: fieldbox} return # the object we are writing to is freshly allocated # only remove some boxes from the cache + new_d = {} for frombox, tobox in d.iteritems(): # the other box is *also* freshly allocated # therefore frombox and box *must* contain different objects # thus we can keep it in the cache if frombox in self.new_boxes: new_d[frombox] = tobox + new_d[box] = fieldbox self.heap_cache[descr] = new_d def getarrayitem(self, box, descr, indexbox): diff --git a/pypy/jit/metainterp/test/test_heapcache.py b/pypy/jit/metainterp/test/test_heapcache.py --- a/pypy/jit/metainterp/test/test_heapcache.py +++ b/pypy/jit/metainterp/test/test_heapcache.py @@ -121,6 +121,8 @@ h.setfield(box3, descr1, box4) assert h.getfield(box3, descr1) is box4 assert h.getfield(box1, descr1) is box2 # box1 and box3 cannot alias + h.setfield(box1, descr1, box3) + assert h.getfield(box1, descr1) is box3 def test_heapcache_arrays(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit