pypy/module/pypyjit/test_pypy_c/test_struct.py::TestStruct::()::test_struct_function
self = <pypy.module.pypyjit.test_pypy_c.test_struct.TestStruct object at 0x000001bd1b085130>
def test_struct_function(self):
def main(n):
import struct
i = 1
while i < n:
buf = struct.pack("<i", i) # ID: pack
x = struct.unpack("<i", buf)[0] # ID: unpack
i += x // i
return i
log = self.run(main, [1000])
assert log.result == main(1000)
loop, = log.loops_by_filename(self.filepath)
# This could, of course stand some improvement, to remove all these
# arithmatic ops, but we've removed all the core overhead.
if sys.byteorder == 'little':
# on little endian machines, we take the fast path and store the
# value using gc_store_indexed
assert loop.match_by_id("pack", """
dummy_get_utf8?
guard_not_invalidated(descr=...)
# struct.pack
%s
p75 = newstr(4)
gc_store_indexed(p75, 0, _, 1, _, 4, descr=...)
> """ % extra)
pypy\module\pypyjit\test_pypy_c\test_struct.py:43:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pypy\module\pypyjit\test_pypy_c\model.py:182: in match_by_id
return matcher.match(expected_src, ignore_ops=ignore_ops)
pypy\module\pypyjit\test_pypy_c\model.py:524: in match
self.match_loop(expected_ops, ignore_ops)
pypy\module\pypyjit\test_pypy_c\model.py:500: in match_loop
self.match_op(op, exp_op)
pypy\module\pypyjit\test_pypy_c\model.py:409: in match_op
self._assert(op.name == exp_opname, "operation mismatch")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pypy.module.pypyjit.test_pypy_c.model.OpMatcher object at 0x000001bd19b87d00>
cond = False, message = 'operation mismatch'
def _assert(self, cond, message):
if not cond:
> raise InvalidMatch(message, frame=sys._getframe(1))
E InvalidMatch: operation mismatch
pypy\module\pypyjit\test_pypy_c\model.py:402: InvalidMatch
---------- Captured stdout call ----------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Loops don't match
=================
loop id = 'pack'
('operation mismatch',)
<could not determine information>
Ignore ops: []
Got:
===== HERE =====
i68 = int_ge(i61, -2147483648)
guard_true(i68, descr=<Guard0x2058c5b3670>)
i70 = int_le(i61, 2147483647)
guard_true(i70, descr=<Guard0x2058c5b36d0>)
p72 = newstr(4)
gc_store_indexed(p72, 0, i61, 1, 24, 4, descr=<ArrayS 4>)
Expected:
dummy_get_utf8?
guard_not_invalidated(descr=...)
# struct.pack
i8 = int_ge(i4, -2147483648)
guard_true(i8, descr=...)
i9 = int_le(i4, 2147483647)
guard_true(i9, descr=...)
p75 = newstr(4)
gc_store_indexed(p75, 0, _, 1, _, 4, descr=...)
builder: pypy-c-jit-win-x86-64 build #2538+
test: pypy/module/pypyjit/test_pypy_c/test_struct.py::TestStruct::()::test_struct_function