[pypy-svn] r32967 - in pypy/dist/pypy/jit/timeshifter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Fri Oct 6 17:36:37 CEST 2006
Author: pedronis
Date: Fri Oct 6 17:36:28 2006
New Revision: 32967
Modified:
pypy/dist/pypy/jit/timeshifter/rcontainer.py
pypy/dist/pypy/jit/timeshifter/rtyper.py
pypy/dist/pypy/jit/timeshifter/rvalue.py
pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
Log:
(arre, pedronis, arigo around)
unfreezing of vstructs with simple test.
Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py Fri Oct 6 17:36:28 2006
@@ -161,6 +161,20 @@
fullmatch = False
return fullmatch
+ def unfreeze(self, incomingvarboxes, memo):
+ contmemo = memo.containers
+ if self in contmemo:
+ return contmemo[self]
+ typedesc = self.typedesc
+ ownbox = typedesc.ll_factory()
+ contmemo[self] = ownbox
+ vstruct = ownbox.content
+ self_boxes = self.fz_content_boxes
+ for i in range(len(self_boxes)):
+ fz_box = self_boxes[i]
+ vstruct.content_boxes[i] = fz_box.unfreeze(incomingvarboxes,
+ memo)
+ return ownbox
class VirtualStruct(AbstractContainer):
Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py Fri Oct 6 17:36:28 2006
@@ -1118,8 +1118,10 @@
if self.typedesc is None:
T = self.original_concretetype.TO
self.typedesc = rcontainer.StructTypeDesc(ts.RGenOp, T)
- return hop.llops.genmixlevelhelpercall(self.typedesc.ll_factory,
- [], [], ts.s_RedBox)
+ v_ptrbox = hop.llops.genmixlevelhelpercall(self.typedesc.ll_factory,
+ [], [], ts.s_PtrRedBox)
+ return hop.llops.genop('cast_pointer', [v_ptrbox], resulttype=
+ ts.r_RedBox)
class BlueRepr(Repr):
Modified: pypy/dist/pypy/jit/timeshifter/rvalue.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rvalue.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rvalue.py Fri Oct 6 17:36:28 2006
@@ -386,5 +386,4 @@
memo)
def unfreeze(self, incomingvarboxes, memo):
- #return self.fz_content.unfreeze(self.kind, incomingvarboxes, memo)
- raise NotImplementedError
+ return self.fz_content.unfreeze(incomingvarboxes, memo)
Modified: pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_promotion.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_promotion.py Fri Oct 6 17:36:28 2006
@@ -147,6 +147,28 @@
assert res == 340
self.check_insns(int_lt=1, int_mul=0)
+ def test_vstruct_unfreeze(self):
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ def ll_two(k):
+ return (k+1)*2
+ def ll_function(n):
+ s = lltype.malloc(S)
+ s.x = n
+ k = hint(n, promote=True)
+ k = ll_two(k)
+ return hint(k, variable=True) + s.x
+ ll_function._global_merge_points_ = True
+
+ # easy case: no promotion needed
+ res = self.timeshift(ll_function, [20], [0], policy=P_NOVIRTUAL)
+ assert res == 62
+ self.check_insns({})
+
+ # the real test: with promotion
+ res = self.timeshift(ll_function, [20], [], policy=P_NOVIRTUAL)
+ assert res == 62
+ self.check_insns(int_add=0, int_mul=0)
+
def test_more_promotes(self):
py.test.skip("in-progress")
S = lltype.GcStruct('S', ('x', lltype.Signed), ('y', lltype.Signed))
More information about the Pypy-commit
mailing list