[pypy-svn] r29482 - in pypy/dist/pypy/jit/timeshifter: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Jun 29 11:34:21 CEST 2006
Author: arigo
Date: Thu Jun 29 11:34:19 2006
New Revision: 29482
Modified:
pypy/dist/pypy/jit/timeshifter/test/test_vlist.py
pypy/dist/pypy/jit/timeshifter/vlist.py
Log:
(arre, pedronis, arigo)
Implemented a few more methods.
Modified: pypy/dist/pypy/jit/timeshifter/test/test_vlist.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_vlist.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_vlist.py Thu Jun 29 11:34:19 2006
@@ -30,3 +30,33 @@
insns, res = timeshift(ll_function, [0], [], policy=P_OOPSPEC)
assert res == 131
assert insns == {'int_is_true': 1}
+
+def test_merge():
+ def ll_function(flag):
+ lst = []
+ if flag:
+ lst.append(flag)
+ else:
+ lst.append(131)
+ return lst[-1]
+ insns, res = timeshift(ll_function, [6], [], policy=P_OOPSPEC)
+ assert res == 6
+ assert insns == {'int_is_true': 1}
+ insns, res = timeshift(ll_function, [0], [], policy=P_OOPSPEC)
+ assert res == 131
+ assert insns == {'int_is_true': 1}
+
+def test_replace():
+ def ll_function(flag):
+ lst = []
+ if flag:
+ lst.append(12)
+ else:
+ lst.append(131)
+ return lst[-1]
+ insns, res = timeshift(ll_function, [6], [], policy=P_OOPSPEC)
+ assert res == 12
+ assert insns == {'int_is_true': 1}
+ insns, res = timeshift(ll_function, [0], [], policy=P_OOPSPEC)
+ assert res == 131
+ assert insns == {'int_is_true': 1}
Modified: pypy/dist/pypy/jit/timeshifter/vlist.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/vlist.py (original)
+++ pypy/dist/pypy/jit/timeshifter/vlist.py Thu Jun 29 11:34:19 2006
@@ -42,10 +42,13 @@
outgoingvarboxes.append(vlist.ownbox)
return False
assert self.typedesc is vlist.typedesc
- contmemo[self] = vlist
- contmemo[vlist] = self
self_boxes = self.fz_item_boxes
vlist_boxes = vlist.item_boxes
+ if len(self_boxes) != len(vlist_boxes):
+ outgoingvarboxes.append(vlist.ownbox)
+ return False
+ contmemo[self] = vlist
+ contmemo[vlist] = self
fullmatch = True
for i in range(len(self_boxes)):
if not self_boxes[i].exactmatch(vlist_boxes[i],
@@ -94,7 +97,12 @@
return result
def replace(self, memo):
- assert 0
+ contmemo = memo.containers
+ if self not in contmemo:
+ contmemo[self] = None
+ for i in range(len(self.item_boxes)):
+ self.item_boxes[i] = self.item_boxes[i].replace(memo)
+ self.ownbox = self.ownbox.replace(memo)
def oop_newlist(jitstate, typedesc, lengthbox):
More information about the Pypy-commit
mailing list