[pypy-commit] pypy improve-heap-caching-tracing: test and fix: make getfield use getfield_now_known
cfbolz
noreply at buildbot.pypy.org
Wed Sep 7 15:13:15 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: improve-heap-caching-tracing
Changeset: r47137:7213ef516d50
Date: 2011-09-07 14:02 +0200
http://bitbucket.org/pypy/pypy/changeset/7213ef516d50/
Log: test and fix: make getfield use getfield_now_known
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
@@ -545,8 +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)
+ self.metainterp.heapcache.getfield_now_known(box, fielddescr, resbox)
return resbox
@arguments("orgpc", "box", "descr")
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
@@ -428,27 +428,38 @@
self.check_operations_history(getfield_gc=0)
return
-
def test_heap_caching_multiple_objects(self):
class Gbl(object):
pass
g = Gbl()
class A(object):
pass
+ a1 = A()
+ g.a1 = a1
+ a1.x = 7
+ a2 = A()
+ g.a2 = a2
+ a2.x = 7
+ def gn(a1, a2):
+ return a1.x + a2.x
def fn(n):
- a1 = A()
- g.a = a1
- a1.x = n
- a2 = A()
- g.a = a2
- a2.x = n - 1
- return a1.x + a2.x + a1.x + a2.x
- res = self.interp_operations(fn, [7])
- assert res == 2 * 7 + 2 * 6
- self.check_operations_history(getfield_gc=0)
+ if n < 0:
+ a1 = A()
+ g.a1 = a1
+ a1.x = n
+ a2 = A()
+ g.a2 = a2
+ a2.x = n - 1
+ else:
+ a1 = g.a1
+ a2 = g.a2
+ return a1.x + a2.x + gn(a1, a2)
res = self.interp_operations(fn, [-7])
assert res == 2 * -7 + 2 * -8
- self.check_operations_history(getfield_gc=0)
+ self.check_operations_history(setfield_gc=4, getfield_gc=0)
+ res = self.interp_operations(fn, [7])
+ assert res == 4 * 7
+ self.check_operations_history(getfield_gc=4)
def test_heap_caching_multiple_tuples(self):
class Gbl(object):
More information about the pypy-commit
mailing list