Created
October 15, 2013 21:22
-
-
Save zain/6998875 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # i added this test | |
| def test_int_add_ovf_commutative(self): | |
| ops = """ | |
| [i0, i1] | |
| i2 = int_add_ovf(i0, i1) | |
| i3 = int_add_ovf(i1, i0) | |
| jump(i2, i3) | |
| """ | |
| expected = """ | |
| [i0, i1] | |
| i2 = int_add_ovf(i0, i1) | |
| jump(i2, i2) | |
| """ | |
| self.optimize_loop(ops, expected) | |
| # it fails because ops are actually: | |
| (Pdb) print '\n'.join([str(o) for o in loop.operations]) | |
| label(i0, i1, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>) | |
| i3 = int_add_ovf(i1, i0) | |
| jump(i2, i3, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>) |
Author
zain
commented
Oct 15, 2013
Author
$ python pytest.py --pdb rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
==================================================== test session starts ====================================================
platform darwin -- Python 2.7.3[pypy-2.2.0-alpha] -- pytest-2.2.4.dev2
pytest-2.2.4.dev2 from /Users/zain/projects/pypy/pytest.pyc
collected 254 items
rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py ...............s..s....................sssss.ss.................s..s.........s.............s..s.....sssssss...................s..s.................................................
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
self = <rpython.jit.metainterp.optimizeopt.test.test_optimizebasic.TestLLtype object at 0x000000010633c170>
def test_int_add_ovf_commutative(self):
ops = """
[i0, i1]
i2 = int_add_ovf(i0, i1)
i3 = int_add_ovf(i1, i0)
jump(i2, i3)
"""
expected = """
[i0, i1]
i2 = int_add_ovf(i0, i1)
jump(i2, i2)
"""
> self.optimize_loop(ops, expected)
rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py:3713:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.jit.metainterp.optimizeopt.test.test_optimizebasic.TestLLtype object at 0x000000010633c170>
ops = '\n [i0, i1]\n i2 = int_add_ovf(i0, i1)\n i3 = int_add_ovf(i1, i0)\n jump(i2, i3)\n '
optops = '\n [i0, i1]\n i2 = int_add_ovf(i0, i1)\n jump(i2, i2)\n ', call_pure_results = None
def optimize_loop(self, ops, optops, call_pure_results=None):
loop = self.parse(ops)
token = JitCellToken()
loop.operations = [ResOperation(rop.LABEL, loop.inputargs, None, descr=TargetToken(token))] + \
loop.operations
if loop.operations[-1].getopnum() == rop.JUMP:
loop.operations[-1].setdescr(token)
expected = convert_old_style_to_targets(self.parse(optops), jump=True)
self._do_optimize_loop(loop, call_pure_results)
print '\n'.join([str(o) for o in loop.operations])
> self.assert_equal(loop, expected)
rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py:127:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.jit.metainterp.optimizeopt.test.test_optimizebasic.TestLLtype object at 0x000000010633c170>
optimized = <loop>, expected = <loop>, text_right = None
def assert_equal(self, optimized, expected, text_right=None):
from rpython.jit.metainterp.optimizeopt.util import equaloplists
assert len(optimized.inputargs) == len(expected.inputargs)
remap = {}
for box1, box2 in zip(optimized.inputargs, expected.inputargs):
assert box1.__class__ == box2.__class__
remap[box2] = box1
assert equaloplists(optimized.operations,
> expected.operations, False, remap, text_right)
rpython/jit/metainterp/optimizeopt/test/test_util.py:352:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
oplist1 = [label(i0, i1, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>), i3 = int_add_ovf(i1, i0), jump(i2, i3, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>)]
oplist2 = [label(i0, i1, descr=<rpython.jit.metainterp.optimizeopt.test.test_util.FakeDescr object at 0x000000010633c678>), i2 = int_add_ovf(i0, i1), jump(i2, i2, descr=<Loop -1, gen=0>)]
strict_fail_args = False, remap = {None: None, i0(0): i0(0), i1(0): i1(0)}, text_right = 'expected'
def equaloplists(oplist1, oplist2, strict_fail_args=True, remap={},
text_right=None):
# try to use the full width of the terminal to display the list
# unfortunately, does not work with the default capture method of py.test
# (which is fd), you you need to use either -s or --capture=sys, else you
# get the standard 80 columns width
totwidth = py.io.get_terminal_width()
width = totwidth / 2 - 1
print ' Comparing lists '.center(totwidth, '-')
text_right = text_right or 'expected'
print '%s| %s' % ('optimized'.center(width), text_right.center(width))
for op1, op2 in zip(oplist1, oplist2):
txt1 = str(op1)
txt2 = str(op2)
while txt1 or txt2:
print '%s| %s' % (txt1[:width].ljust(width), txt2[:width])
txt1 = txt1[width:]
txt2 = txt2[width:]
assert op1.getopnum() == op2.getopnum()
assert op1.numargs() == op2.numargs()
for i in range(op1.numargs()):
x = op1.getarg(i)
y = op2.getarg(i)
> assert x.same_box(remap.get(y, y))
E assert <bound method BoxInt.same_box of i1(0)>(i0(0))
E + where <bound method BoxInt.same_box of i1(0)> = i1(0).same_box
E + and i0(0) = <bound method dict.get of {None: None, i1(0): i1(0), i0(0): i0(0)}>(i0(0), i0(0))
E + where <bound method dict.get of {None: None, i1(0): i1(0), i0(0): i0(0)}> = {None: None, i0(0): i0(0), i1(0): i1(0)}.get
rpython/jit/metainterp/optimizeopt/util.py:151: AssertionError
Author
rpython/jit/metainterp/optimizeopt/util.py:151: AssertionError
------------------------------------------------------ Captured stdout ------------------------------------------------------
label(i0, i1, descr=<rpython.jit.metainterp.history.TargetToken object at 0x00000001063988e0>)
i3 = int_add_ovf(i1, i0)
jump(i2, i3, descr=<rpython.jit.metainterp.history.TargetToken object at 0x00000001063988e0>)
------------------------------- Comparing lists --------------------------------
optimized | expected
label(i0, i1, descr=<rpython.jit.metain| label(i0, i1, descr=<rpython.jit.metain
terp.history.TargetToken object at 0x00| terp.optimizeopt.test.test_util.FakeDes
000001063988e0>) | cr object at 0x0000000106398a30>)
i3 = int_add_ovf(i1, i0) | i2 = int_add_ovf(i0, i1)
------------------------------------------------------ Captured stderr ------------------------------------------------------
[172] {jit-optimize
[172] jit-optimize}
================================================== short test summary info ==================================================
FAIL rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py::TestLLtype::()::test_int_add_ovf_commutative
===================================== 1 failed, 226 passed, 27 skipped in 5.72 seconds ======================================
Author
(Pdb) print '\n'.join([str(o) for o in loop.operations])
label(i0, i1, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>)
i3 = int_add_ovf(i1, i0)
jump(i2, i3, descr=<rpython.jit.metainterp.history.TargetToken object at 0x000000010633c528>)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment