pypy/module/pypyjit/test_pypy_c/test_struct.py::TestStruct::()::test_unpack_bytearray
self = <pypy.module.pypyjit.test_pypy_c.test_struct.TestStruct object at 0x7f906060da10>
def test_unpack_bytearray(self):
def main(n):
import struct
buf = struct.pack('H', 0x1234)
buf = bytearray(buf)
i = 1
res = 0
while i < n:
val = struct.unpack("h", buf)[0] # ID: unpack
res += val
i += 1
return res
log = self.run(main, [1000])
assert log.result == main(1000)
loop, = log.loops_by_filename(self.filepath)
# the offset of gc_load_indexed_i used to be the constant 0. However,
# now it is 'i46' because we need to add 0 to
# W_BytearrayObject._offset
assert loop.match_by_id('unpack', """
guard_not_invalidated(descr=...)
i70 = gc_load_indexed_i(p48, i46, 1, _, -2)
> """)
pypy/module/pypyjit/test_pypy_c/test_struct.py:159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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 0x7f905f368e90>
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 = 'unpack'
('operation mismatch',)
<could not determine information>
Ignore ops: []
Got:
guard_not_invalidated(descr=<Guard0x7f0526742bb8>)
===== HERE =====
setfield_gc(p12, i43, descr=<FieldS pypy.objspace.std.bytearrayobject.W_BytearrayObject.inst__exports 16>)
i74 = gc_load_indexed_i(p52, i46, 1, 16, -2)
Expected:
guard_not_invalidated(descr=...)
i70 = gc_load_indexed_i(p48, i46, 1, _, -2)
builder: pypy-c-jit-linux-x86-64 build #11813+
test: pypy/module/pypyjit/test_pypy_c/test_struct.py::TestStruct::()::test_unpack_bytearray