[pypy-svn] r36486 - in pypy/dist/pypy/jit/timeshifter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Jan 11 15:13:00 CET 2007
Author: pedronis
Date: Thu Jan 11 15:12:59 2007
New Revision: 36486
Modified:
pypy/dist/pypy/jit/timeshifter/rcontainer.py
pypy/dist/pypy/jit/timeshifter/rtimeshift.py
pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(arre, pedronis)
intermediate checkin: new test in progress
Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py Thu Jan 11 15:12:59 2007
@@ -110,7 +110,7 @@
def factory(self):
vstruct = self.VStructCls(self)
- vstruct.content_boxes = [desc.redboxcls(desc.kind, desc.gv_default)
+ vstruct.content_boxes = [desc.makedefaultbox()
for desc in self.fielddescs]
if self.virtualizable:
outsidebox = rvalue.PtrRedBox(self.innermostdesc.ptrkind,
@@ -143,6 +143,7 @@
self.RESTYPE = RESTYPE
self.ptrkind = RGenOp.kindToken(PTRTYPE)
self.kind = RGenOp.kindToken(RESTYPE)
+ self.gv_default = RGenOp.constPrebuiltGlobal(self.RESTYPE._defl())
if RESTYPE is lltype.Void and self.allow_void:
pass # no redboxcls at all
else:
@@ -152,6 +153,12 @@
def _freeze_(self):
return True
+ def makedefaultbox(self):
+ return self.redboxcls(self.kind, self.gv_default)
+
+ def makebox(self, gvar):
+ return self.redboxcls(self.kind, gvar)
+
class NamedFieldDesc(FieldDesc):
def __init__(self, RGenOp, PTRTYPE, name):
@@ -165,22 +172,20 @@
def generate_get(self, builder, genvar):
gv_item = builder.genop_getfield(self.fieldtoken, genvar)
- return self.redboxcls(self.kind, gv_item)
+ return self.makebox(gv_item)
def generate_set(self, builder, genvar, gv_value):
builder.genop_setfield(self.fieldtoken, genvar, gv_value)
def generate_getsubstruct(self, builder, genvar):
gv_sub = builder.genop_getsubstruct(self.fieldtoken, genvar)
- return self.redboxcls(self.kind, gv_sub)
+ return self.makebox(gv_sub)
class StructFieldDesc(NamedFieldDesc):
def __init__(self, RGenOp, PTRTYPE, name, index):
NamedFieldDesc.__init__(self, RGenOp, PTRTYPE, name)
self.fieldindex = index
- self.gv_default = RGenOp.constPrebuiltGlobal(self.RESTYPE._defl())
- self.defaultbox = self.redboxcls(self.kind, self.gv_default)
class ArrayFieldDesc(FieldDesc):
allow_void = True
Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py Thu Jan 11 15:12:59 2007
@@ -108,7 +108,7 @@
return argbox.op_getfield(jitstate, fielddesc)
def ll_gensetfield(jitstate, fielddesc, destbox, valuebox):
- return destbox.op_setfield(jitstate, fielddesc, valuebox)
+ destbox.op_setfield(jitstate, fielddesc, valuebox)
def ll_gengetsubstruct(jitstate, fielddesc, argbox):
if argbox.is_constant():
@@ -128,7 +128,7 @@
argbox.getgenvar(jitstate),
indexbox.getgenvar(jitstate))
- return fielddesc.redboxcls(fielddesc.kind, genvar)
+ return fielddesc.makebox(genvar)
def ll_gengetarraysubstruct(jitstate, fielddesc, argbox, indexbox):
if argbox.is_constant() and indexbox.is_constant():
@@ -140,7 +140,7 @@
argbox.getgenvar(jitstate),
indexbox.getgenvar(jitstate))
- return fielddesc.redboxcls(fielddesc.kind, genvar)
+ return fielddesc.makebox(genvar)
def ll_gensetarrayitem(jitstate, fielddesc, destbox, indexbox, valuebox):
@@ -150,8 +150,6 @@
indexbox.getgenvar(jitstate),
valuebox.getgenvar(jitstate)
)
-
- return fielddesc.redboxcls(fielddesc.kind, genvar)
def ll_gengetarraysize(jitstate, fielddesc, argbox):
if argbox.is_constant():
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 Thu Jan 11 15:12:59 2007
@@ -42,6 +42,8 @@
hints = {'virtualizable': True}
))
+E = lltype.GcStruct('e', ('xy', lltype.Ptr(XY)))
+
XP.become(lltype.GcStruct('xp',
('access', lltype.Ptr(XP_ACCESS)),
('x', lltype.Signed),
@@ -154,7 +156,6 @@
[lltype.Ptr(XY), lltype.Signed, lltype.Signed])
def test_simple_explicit_escape(self):
- E = lltype.GcStruct('e', ('xy', lltype.Ptr(XY)))
def f(e, xy):
xy_access = xy.access
@@ -405,3 +406,29 @@
policy=P_NOVIRTUAL)
assert res == 42
self.check_insns(getfield=0, malloc=2)
+
+ def test_simple_explicit_read(self):
+ py.test.skip("WIP")
+
+ def f(e):
+ xy = e.xy
+ xy_access = xy.access
+ if xy_access:
+ xy_access.set_y(xy, 3)
+ else:
+ xy.y = 3
+ return xy.x*2
+
+ def main(x, y):
+ xy = lltype.malloc(XY)
+ xy.access = lltype.nullptr(XY_ACCESS)
+ xy.x = x
+ xy.y = y
+ e = lltype.malloc(E)
+ e.xy = xy
+ v = f(e)
+ return v + e.xy.x+e.xy.y
+
+ res = self.timeshift_from_portal(main, f, [20, 22], policy=P_NOVIRTUAL)
+ assert res == 63
+ self.check_insns(getfield=3)
More information about the Pypy-commit
mailing list