[pypy-commit] pypy heap-caching-during-tracing: make promotion influence the heap cache
cfbolz
noreply at buildbot.pypy.org
Sat Jul 16 22:00:06 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: heap-caching-during-tracing
Changeset: r45688:22dc9cdf9e06
Date: 2011-07-16 21:59 +0200
http://bitbucket.org/pypy/pypy/changeset/22dc9cdf9e06/
Log: make promotion influence 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
@@ -2354,6 +2354,16 @@
for i in range(len(boxes)):
if boxes[i] is oldbox:
boxes[i] = newbox
+ for descr, (frombox, tobox) in self.heap_cache.iteritems():
+ change = False
+ if frombox is oldbox:
+ change = True
+ frombox = newbox
+ if tobox is oldbox:
+ change = True
+ tobox = newbox
+ if change:
+ self.heap_cache[descr] = frombox, tobox
def find_biggest_function(self):
start_stack = []
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
@@ -232,3 +232,27 @@
self.check_operations_history(setarrayitem_gc=2, setfield_gc=3,
getarrayitem_gc=0, getfield_gc=1)
+ def test_promote_changes_heap_cache(self):
+ class A: pass
+ a1 = A()
+ a2 = A()
+ a1.l = a2.l = [0, 0]
+ a1.x = a2.x = 0
+ def fn(n):
+ if n > 0:
+ a = a1
+ else:
+ a = a2
+ a.l = [0, 0]
+ jit.promote(a.x)
+ a.l[a.x] = n
+ a.x += 1
+ a.l[a.x] = n + 1
+ x1 = a.l[a.x]
+ a.x -= 1
+ x2 = a.l[a.x]
+ return x1 + x2
+ res = self.interp_operations(fn, [7])
+ assert res == 7 * 2 + 1
+ self.check_operations_history(setarrayitem_gc=2, setfield_gc=2,
+ getarrayitem_gc=0, getfield_gc=2)
More information about the pypy-commit
mailing list