Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r47335:7b8611a1573e Date: 2011-09-19 09:47 +0200 http://bitbucket.org/pypy/pypy/changeset/7b8611a1573e/
Log: merge heads 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 @@ -9,7 +9,10 @@ def reset(self): # contains boxes where the class is already known self.known_class_boxes = {} - # store the boxes that contain newly allocated objects: + # store the boxes that contain newly allocated objects, this maps the + # boxes to a bool, the bool indicates whether or not the object has + # escaped the trace or not, its presences in the mapping shows that it + # was allocated inside the trace self.new_boxes = {} # contains frame boxes that are not virtualizables self.nonstandard_virtualizables = {} @@ -23,6 +26,17 @@ self.length_cache = {} def invalidate_caches(self, opnum, descr, argboxes): + self.mark_escaped(opnum, argboxes) + self.clear_caches(opnum, descr, argboxes) + + def mark_escaped(self, opnum, argboxes): + for idx, box in enumerate(argboxes): + # setfield_gc and setarrayitem_gc don't escape their first argument + if not (idx == 0 and opnum in [rop.SETFIELD_GC, rop.SETARRAYITEM_GC]): + if box in self.new_boxes: + self.new_boxes[box] = False + + def clear_caches(self, opnum, descr, argboxes): if opnum == rop.SETFIELD_GC: return if opnum == rop.SETARRAYITEM_GC: @@ -73,8 +87,11 @@ def nonstandard_virtualizables_now_known(self, box): self.nonstandard_virtualizables[box] = None + def is_unescaped(self, box): + return self.new_boxes.get(box, False) + def new(self, box): - self.new_boxes[box] = None + self.new_boxes[box] = True def new_array(self, box, lengthbox): self.new(box) @@ -146,7 +163,6 @@ indexcache = cache.get(index, None) cache[index] = self._do_write_with_aliasing(indexcache, box, valuebox) - def arraylen(self, box): return self.length_cache.get(box, None) 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 @@ -326,3 +326,22 @@ [None, None, box2, None, None] ) assert h.getarrayitem(box4, descr1, index1) is None + + def test_unescaped(self): + h = HeapCache() + assert not h.is_unescaped(box1) + h.new(box2) + assert h.is_unescaped(box2) + h.invalidate_caches(rop.SETFIELD_GC, None, [box2, box1]) + assert h.is_unescaped(box2) + h.invalidate_caches(rop.SETFIELD_GC, None, [box1, box2]) + assert not h.is_unescaped(box2) + + def test_unescaped_array(self): + h = HeapCache() + h.new_array(box1, lengthbox1) + assert h.is_unescaped(box1) + h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, index1, box2]) + assert h.is_unescaped(box1) + h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1]) + assert not h.is_unescaped(box1) \ No newline at end of file diff --git a/pypy/module/_continuation/test/support.py b/pypy/module/_continuation/test/support.py --- a/pypy/module/_continuation/test/support.py +++ b/pypy/module/_continuation/test/support.py @@ -9,4 +9,4 @@ import pypy.rlib.rstacklet except CompilationError, e: py.test.skip("cannot import rstacklet: %s" % e) - cls.space = gettestobjspace(usemodules=['_continuation']) + cls.space = gettestobjspace(usemodules=['_continuation'], continuation=True) diff --git a/pypy/module/test_lib_pypy/test_greenlet.py b/pypy/module/test_lib_pypy/test_greenlet.py --- a/pypy/module/test_lib_pypy/test_greenlet.py +++ b/pypy/module/test_lib_pypy/test_greenlet.py @@ -3,7 +3,7 @@ class AppTestGreenlet: def setup_class(cls): - cls.space = gettestobjspace(usemodules=['_continuation']) + cls.space = gettestobjspace(usemodules=['_continuation'], continuation=True) def test_simple(self): from greenlet import greenlet _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit