[pypy-svn] r37386 - in pypy/dist/pypy/jit/timeshifter: . test
ac at codespeak.net
ac at codespeak.net
Fri Jan 26 14:40:40 CET 2007
Author: ac
Date: Fri Jan 26 14:40:39 2007
New Revision: 37386
Modified:
pypy/dist/pypy/jit/timeshifter/rvirtualizable.py
pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
More passing tests :-)
Modified: pypy/dist/pypy/jit/timeshifter/rvirtualizable.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rvirtualizable.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rvirtualizable.py Fri Jan 26 14:40:39 2007
@@ -14,7 +14,6 @@
vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
vable_rti.touch(struc.vable_base)
- #debug_print(lltype.Void, "TOUCH UPDATE")
j = 0
for fielddesc, _ in fielddescs:
if fielddesc.canbevirtual and fielddesc.gcref:
@@ -24,8 +23,8 @@
tgt = lltype.cast_pointer(fielddesc.PTRTYPE, struc)
setattr(tgt, fielddesc.fieldname, v)
j += 1
-
- struc.vable_access = access_touched
+ ACCESSPTR = TOPPTR.TO.vable_access
+ struc.vable_access = lltype.cast_pointer(ACCESSPTR, access_touched)
return touch_update
@@ -154,7 +153,7 @@
if frameindex >= 0:
return
posshift = -frameindex
- assert index > 0
+ assert posshift > 0
touched = self.getforcestate(base).touched
touched[self.bitmask<<posshift] = None
Modified: pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py Fri Jan 26 14:40:39 2007
@@ -882,3 +882,84 @@
res = self.timeshift_from_portal(main, f, [0], policy=StopAtXPolicy(g))
assert res == 42
+
+ def test_force_then_set_in_residual_call(self):
+ class S(object):
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
+
+ class V(object):
+ _virtualizable_ = True
+ def __init__(self, s):
+ self.s = s
+
+ def g(v):
+ s = v.s
+ x = s.x
+ y = s.y
+ s.x = y
+ s.y = x
+ v.s = S(x*100, y*100)
+
+ def f(v):
+ hint(None, global_merge_point=True)
+ s = S(1, 10)
+ v.s = s
+ g(v)
+ s2 = v.s
+ return s.x*2 + s.y + s2.x * 2 + s2.y
+
+ def main():
+ v = V(None)
+ return f(v)
+
+ res = self.timeshift_from_portal(main, f, [], policy=StopAtXPolicy(g))
+ assert res == 20 + 1 + 200 + 1000
+
+
+ def test_inheritance_with_residual_call(self):
+ class S(object):
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
+
+
+ class X(object):
+ _virtualizable_ = True
+
+ def __init__(self, x):
+ self.x = x
+
+ class XY(X):
+
+ def __init__(self, x, y, s):
+ X.__init__(self, x)
+ self.s = s
+ self.y = y
+
+ def g(xy):
+ s = xy.s
+ x = xy.x
+ y = xy.y
+ if x:
+ xy.x = s.x
+ xy.y = s.y
+ if y:
+ xy.s = S(x, y)
+
+ def f(xy, sx, sy):
+ hint(None, global_merge_point=True)
+ xy.s = S(sx, sy)
+ g(xy)
+ return xy.x + xy.y * 16 + xy.s.x * 16 ** 2 + xy.s.y * 16 ** 3
+
+ def main(x, y, sx, sy):
+ X(0)
+ xy = XY(x, y, None)
+ return f(xy, sx, sy)
+
+ res = self.timeshift_from_portal(main, f, [1, 2, 4, 8],
+ policy=StopAtXPolicy(g))
+ assert res == 4 + 8 * 16 + 1 * 16 ** 2 + 2 * 16 ** 3
+
More information about the Pypy-commit
mailing list