def test_serialization(): from rpython.jit.tl.tlopcode import serialize_program, decode_program pool = ConstantPool() bytecode = compile(""" NEW foo,bar,meth=f SETATTR foobar f: RETURN """, pool) s = serialize_program(bytecode, pool) bytecode2, pool2 = decode_program(s) assert bytecode == bytecode2 assert pool == pool2
def load_bytecode(filename): from rpython.rlib.streamio import open_file_as_stream from rpython.jit.tl.tlopcode import decode_program f = open_file_as_stream(filename) return decode_program(f.readall())