[pypy-svn] r37683 - in pypy/branch/jit-virtual-world/pypy/jit/timeshifter: . test
ac at codespeak.net
ac at codespeak.net
Wed Jan 31 20:24:48 CET 2007
Author: ac
Date: Wed Jan 31 20:24:47 2007
New Revision: 37683
Modified:
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rcontainer.py
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(pedronis, arre) Some support for virtualizable in virtualizable.
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py Wed Jan 31 20:24:47 2007
@@ -1615,7 +1615,7 @@
typedesc = self.gettypedesc()
for fielddesc, _ in typedesc.redirected_fielddescs:
FIELDTYPE = fielddesc.RESTYPE
- argtypes += getredrepr(FIELDTYPE).residual_argtypes()
+ argtypes.append(FIELDTYPE)
return argtypes
def residual_args_collector(self):
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rcontainer.py Wed Jan 31 20:24:47 2007
@@ -358,7 +358,9 @@
elif isinstance(RESTYPE, lltype.Ptr):
T = RESTYPE.TO
if hasattr(T, '_hints'):
- self.virtualizable = T._hints.get('virtualizable', False)
+ # xxx hack for simple recursive cases
+ if not PTRTYPE.TO._hints.get('virtualizable', False):
+ self.virtualizable = T._hints.get('virtualizable', False)
self.gcref = T._gckind == 'gc'
if isinstance(T, lltype.ContainerType):
if not T._is_varsize() or hasattr(T, 'll_newlist'):
@@ -372,9 +374,9 @@
self.gv_default = RGenOp.constPrebuiltGlobal(self.RESTYPE._defl())
if RESTYPE is lltype.Void and self.allow_void:
pass # no redboxcls at all
- elif self.virtualizable:
- self.structdesc = StructTypeDesc(hrtyper, T)
else:
+ if self.virtualizable:
+ self.structdesc = StructTypeDesc(hrtyper, T)
self.redboxcls = rvalue.ll_redboxcls(RESTYPE)
self.immutable = PTRTYPE.TO._hints.get('immutable', False)
@@ -383,8 +385,6 @@
return True
def makedefaultbox(self):
- if self.virtualizable:
- return self.structdesc.factory()
return self.redboxcls(self.kind, self.gv_default)
def makebox(self, jitstate, gvar):
Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_virtualizable.py Wed Jan 31 20:24:47 2007
@@ -1208,3 +1208,51 @@
assert res == 42
self.check_oops(newlist=0)
+
+ def test_recursive(self):
+
+ class XY(object):
+ _virtualizable_ = True
+
+ def __init__(self, x, back):
+ self.x = x
+ self.back = back
+
+ def f(xy):
+ return xy.x
+
+ def main(x, y):
+ xyy = XY(y, None)
+ xy = XY(x, xyy)
+ return f(xy)
+
+ res = self.timeshift_from_portal(main, f, [20, 22], policy=P_OOPSPEC)
+ assert res == 20
+ self.check_insns(getfield=0)
+
+
+ def test_recursive_load_from(self):
+
+ class W(object):
+ def __init__(self, xy):
+ self.xy = xy
+
+ class XY(object):
+ _virtualizable_ = True
+
+ def __init__(self, x, back):
+ self.x = x
+ self.back = back
+
+ def f(w):
+ xy = w.xy
+ return xy.x
+
+ def main(x, y):
+ xyy = XY(y, None)
+ xy = XY(x, xyy)
+ return f(W(xy))
+
+ res = self.timeshift_from_portal(main, f, [20, 22], policy=P_OOPSPEC)
+ assert res == 20
+
More information about the pypy-svn
mailing list