Exemplo n.º 1
0
def test_ResumeDataLoopMemo_other():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    const = ConstFloat(longlong.getfloatstorage(-1.0))
    tagged = memo.getconst(const)
    index, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert memo.consts[index - TAG_CONST_OFFSET] is const
Exemplo n.º 2
0
def test_ResumeDataLoopMemo_random(lst):
    inpargs = [box for box in lst if not isinstance(box, Const)]
    metainterp_sd = FakeMetaInterpStaticData()
    t = Trace(inpargs, metainterp_sd)
    t.append(0)
    i = t.get_iter()
    t.create_top_snapshot(FakeJitCode("", 0), 0, Frame(lst), False, [], [])
    memo = ResumeDataLoopMemo(metainterp_sd)
    numb_state = memo.number(0, i)
    numb = numb_state.create_numbering()
    l = unpack_numbering(numb)
    assert l[0] == len(l)
    assert l[1] == 0
    assert l[1] == 0
    assert l[2] == 0
    assert l[3] == 0
    assert l[4] == 0
    mapping = dict(zip(inpargs, i.inputargs))
    for i, item in enumerate(lst):
        v, tag = untag(l[i + 6])
        if tag == TAGBOX:
            assert l[i + 6] == numb_state.liveboxes[mapping[item]]
        elif tag == TAGCONST:
            assert memo.consts[v].getint() == item.getint()
        elif tag == TAGINT:
            assert v == item.getint()
Exemplo n.º 3
0
def test_virtual_adder_make_varray():
    b2s, b4s = [RefFrontendOp(0), IntFrontendOp(0)]
    b4s.setint(4)
    c1s = ConstInt(111)
    storage = Storage()
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, None,
                                      memo)
    modifier.liveboxes_from_env = {}
    modifier.liveboxes = {}
    modifier.vfieldboxes = {}

    v2 = info.ArrayPtrInfo(LLtypeMixin.arraydescr, size=2, is_virtual=True)
    b2s.set_forwarded(v2)
    v2._items = [b4s, c1s]
    modifier.register_virtual_fields(b2s, [b4s, c1s])
    liveboxes = []
    modifier._number_virtuals(liveboxes, 0)
    dump_storage(storage, liveboxes)
    storage.rd_consts = memo.consts[:]
    storage.rd_numb = Numbering([0])
    # resume
    b1t, b3t, b4t = [IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)]
    b1t.setint(11)
    b3t.setint(33)
    b4t.setint(44)
    newboxes = _resume_remap(
        liveboxes,
        [  #b2s -- virtual
            b4s
        ],
        b4t)
    # resume
    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    assert len(reader.virtuals_cache.virtuals_ptr_cache) == 1
    b2t = reader.decode_ref(tag(0, TAGVIRTUAL))
    trace = metainterp.trace
    expected = [
        (rop.NEW_ARRAY, [ConstInt(2)], b2t.getref_base(),
         LLtypeMixin.arraydescr),
        (rop.SETARRAYITEM_GC, [b2t, ConstInt(0),
                               b4t], None, LLtypeMixin.arraydescr),
        (rop.SETARRAYITEM_GC, [b2t, ConstInt(1),
                               c1s], None, LLtypeMixin.arraydescr),
    ]
    with CompareableConsts():
        for x, y in zip(expected, trace):
            assert x == y
    #
    ptr = b2t.getref_base()._obj.container._as_ptr()
    assert lltype.typeOf(ptr) == lltype.Ptr(lltype.GcArray(lltype.Signed))
    assert len(ptr) == 2
    assert ptr[0] == 44
    assert ptr[1] == 111
Exemplo n.º 4
0
def test_virtual_adder_make_vstruct():
    b2s, b4s = [RefFrontendOp(0), RefFrontendOp(0)]
    c1s = ConstInt(111)
    storage = Storage()
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, None,
                                      memo)
    modifier.liveboxes_from_env = {}
    modifier.liveboxes = {}
    modifier.vfieldboxes = {}
    v2 = info.StructPtrInfo(LLtypeMixin.ssize, is_virtual=True)
    b2s.set_forwarded(v2)
    v2.setfield(LLtypeMixin.adescr, b2s, c1s)
    v2.setfield(LLtypeMixin.abisdescr, b2s, c1s)
    v2.setfield(LLtypeMixin.bdescr, b2s, b4s)
    modifier.register_virtual_fields(b2s, [c1s, c1s, b4s])
    liveboxes = []
    modifier._number_virtuals(liveboxes, 0)
    dump_storage(storage, liveboxes)
    storage.rd_consts = memo.consts[:]
    storage.rd_numb = Numbering([0])
    b4t = RefFrontendOp(0)
    newboxes = _resume_remap(
        liveboxes,
        [  #b2s -- virtual
            b4s
        ],
        b4t)
    #
    NULL = ConstPtr.value
    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    assert len(reader.virtuals_cache.virtuals_ptr_cache) == 1
    b2t = reader.decode_ref(tag(0, TAGVIRTUAL))

    trace = metainterp.trace
    expected = [
        (rop.NEW, [], b2t.getref_base(), LLtypeMixin.ssize),
        (rop.SETFIELD_GC, [b2t, c1s], None, LLtypeMixin.adescr),
        (rop.SETFIELD_GC, [b2t, c1s], None, LLtypeMixin.abisdescr),
        (rop.SETFIELD_GC, [b2t, b4t], None, LLtypeMixin.bdescr),
    ]
    with CompareableConsts():
        for x, y in zip(expected, trace):
            assert x == y
    #
    ptr = b2t.getref_base()._obj.container._as_ptr()
    assert lltype.typeOf(ptr) == lltype.Ptr(LLtypeMixin.S)
    assert ptr.a == 111
    assert ptr.b == lltype.nullptr(LLtypeMixin.NODE)
Exemplo n.º 5
0
def test_virtual_adder_int_constants():
    b1s, b2s, b3s = [ConstInt(sys.maxint), ConstInt(2**16), ConstInt(-65)]
    storage, t = make_storage(b1s, b2s, b3s)
    metainterp_sd = FakeMetaInterpStaticData()
    memo = ResumeDataLoopMemo(metainterp_sd)
    i = t.get_iter()
    modifier = ResumeDataVirtualAdder(FakeOptimizer(i), storage, storage, i, memo)
    liveboxes = modifier.finish()
    cpu = MyCPU([])
    reader = ResumeDataDirectReader(MyMetaInterp(cpu), storage, "deadframe")
    reader.consume_vref_and_vable(None, None, None)
    reader.resumecodereader.jump(2) # framestack
    _next_section(reader, sys.maxint, 1, sys.maxint, 2**16)
    reader.resumecodereader.jump(2) # framestack
    _next_section(reader, 2, 3)
    reader.resumecodereader.jump(2) # framestack
    _next_section(reader, sys.maxint, 2**16, -65)
Exemplo n.º 6
0
def test_invalidation_needed():
    class options:
        failargs_limit = 10

    metainterp_sd = FakeMetaInterpStaticData()
    metainterp_sd.options = options
    memo = ResumeDataLoopMemo(metainterp_sd)
    modifier = ResumeDataVirtualAdder(None, None, None, None, memo)

    for i in range(5):
        assert not modifier._invalidation_needed(5, i)

    assert not modifier._invalidation_needed(7, 2)
    assert modifier._invalidation_needed(7, 3)

    assert not modifier._invalidation_needed(10, 2)
    assert not modifier._invalidation_needed(10, 3)
    assert modifier._invalidation_needed(10, 4)
Exemplo n.º 7
0
def test_virtual_adder_memo_const_sharing():
    b1s, b2s, b3s = [ConstInt(sys.maxint), ConstInt(2**23), ConstInt(-65)]
    storage, t = make_storage(b1s, b2s, b3s)
    metainterp_sd = FakeMetaInterpStaticData()
    memo = ResumeDataLoopMemo(metainterp_sd)
    i = t.get_iter()
    modifier = ResumeDataVirtualAdder(FakeOptimizer(i), storage, storage, i, memo)
    modifier.finish()
    assert len(memo.consts) == 2
    assert storage.rd_consts is memo.consts

    b1s, b2s, b3s = [ConstInt(sys.maxint), ConstInt(2**24), ConstInt(-65)]
    storage2, t = make_storage(b1s, b2s, b3s)
    i = t.get_iter()
    modifier2 = ResumeDataVirtualAdder(FakeOptimizer(i), storage2, storage2,
                                       i, memo)
    modifier2.finish()
    assert len(memo.consts) == 3
    assert storage2.rd_consts is memo.consts
Exemplo n.º 8
0
def test_virtual_adder_make_constant():
    py.test.skip("rewrite fake reader")
    b1s, b2s, b3s = [InputArgInt(1), InputArgRef(), InputArgInt(3)]
    b1s = ConstInt(111)
    storage = make_storage(b1s, b2s, b3s)
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, memo)
    liveboxes = modifier.finish()
    b2t, b3t = [InputArgRef(demo55o), InputArgInt(33)]
    newboxes = _resume_remap(liveboxes, [b2s, b3s], b2t, b3t)
    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    lst = reader.consume_boxes()
    c1t = ConstInt(111)
    assert_same(lst, [c1t, b2t, b3t])
    lst = reader.consume_boxes()
    assert_same(lst, [ConstInt(2), ConstInt(3)])
    lst = reader.consume_boxes()
    assert_same(lst, [c1t, ConstInt(1), c1t, b2t])
    assert metainterp.trace == []
Exemplo n.º 9
0
def test_ResumeDataLoopMemo_ints():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    tagged = memo.getconst(ConstInt(44))
    assert untag(tagged) == (44, TAGINT)
    tagged = memo.getconst(ConstInt(-3))
    assert untag(tagged) == (-3, TAGINT)
    const = ConstInt(5000000)
    tagged = memo.getconst(const)
    index, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert memo.consts[index - TAG_CONST_OFFSET] is const
    tagged = memo.getconst(ConstInt(5000000))
    index2, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert index2 == index
Exemplo n.º 10
0
def test_virtual_adder_pending_fields():
    b2s, b4s = [RefFrontendOp(0), RefFrontendOp(0)]
    storage = Storage()
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    modifier = ResumeDataVirtualAdder(None, storage, storage, None, memo)
    modifier.liveboxes_from_env = {}
    modifier.liveboxes = {}
    modifier.vfieldboxes = {}

    modifier.register_box(b2s)
    modifier.register_box(b4s)

    liveboxes = []
    modifier._number_virtuals(liveboxes, 0)
    assert liveboxes == [b2s, b4s] or liveboxes == [b4s, b2s]
    modifier._add_pending_fields([
        ResOperation(rop.SETFIELD_GC, [b2s, b4s], descr=LLtypeMixin.nextdescr)
    ])
    storage.rd_consts = memo.consts[:]
    storage.rd_numb = Numbering([0])
    # resume
    demo55.next = lltype.nullptr(LLtypeMixin.NODE)
    b2t = RefFrontendOp(0)
    b2t.setref_base(demo55o)
    b4t = RefFrontendOp(0)
    b4t.setref_base(demo66o)
    newboxes = _resume_remap(liveboxes, [b2s, b4s], b2t, b4t)

    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    assert reader.virtuals_cache is None
    trace = metainterp.trace
    b2set = (rop.SETFIELD_GC, [b2t, b4t], None, LLtypeMixin.nextdescr)
    expected = [b2set]

    for x, y in zip(expected, trace):
        assert x == y
    assert len(expected) == len(trace)
    assert demo55.next == demo66
Exemplo n.º 11
0
def test_ResumeDataLoopMemo_refs():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    const = ConstPtr(demo55o)
    tagged = memo.getconst(const)
    index, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert memo.consts[index - TAG_CONST_OFFSET] is const
    tagged = memo.getconst(ConstPtr(demo55o))
    index2, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert index2 == index
    tagged = memo.getconst(ConstPtr(demo66o))
    index3, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert index3 != index
    tagged = memo.getconst(CONST_NULL)
    assert tagged == NULLREF
Exemplo n.º 12
0
def test_virtual_adder_no_op_renaming():
    py.test.skip("rewrite fake reader")
    b1s, b2s, b3s = [InputArgInt(1), InputArgInt(2), InputArgInt(3)]
    storage = make_storage(b1s, b2s, b3s)
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    b1_2 = InputArgInt()
    modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, memo)

    b1s.set_forwarded(b1_2)
    b2s.set_forwarded(b1_2)
    liveboxes = modifier.finish()
    assert storage.rd_snapshot is None
    b1t, b3t = [InputArgInt(11), InputArgInt(33)]
    newboxes = _resume_remap(liveboxes, [b1_2, b3s], b1t, b3t)
    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    lst = reader.consume_boxes()
    assert_same(lst, [b1t, b1t, b3t])
    lst = reader.consume_boxes()
    assert_same(lst, [ConstInt(2), ConstInt(3)])
    lst = reader.consume_boxes()
    assert_same(lst, [b1t, ConstInt(1), b1t, b1t])
    assert metainterp.trace == []
Exemplo n.º 13
0
def test_virtual_adder_make_virtual():
    b2s, b3s, b4s, b5s = [RefFrontendOp(0), IntFrontendOp(0), RefFrontendOp(0),
                          RefFrontendOp(0)]
    c1s = ConstInt(111)
    storage = Storage()
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    modifier = ResumeDataVirtualAdder(FakeOptimizer(), storage, storage, None, memo)
    modifier.liveboxes_from_env = {}
    modifier.liveboxes = {}
    modifier.vfieldboxes = {}

    vdescr = LLtypeMixin.nodesize2
    ca = ConstInt(ptr2int(LLtypeMixin.node_vtable2))
    v4 = info.InstancePtrInfo(vdescr, ca, True)
    b4s.set_forwarded(v4)
    v4.setfield(LLtypeMixin.nextdescr, ca, b2s)
    v4.setfield(LLtypeMixin.valuedescr, ca, b3s)
    v4.setfield(LLtypeMixin.otherdescr, ca, b5s)
    ca = ConstInt(ptr2int(LLtypeMixin.node_vtable))
    v2 = info.InstancePtrInfo(LLtypeMixin.nodesize, ca, True)
    v2.setfield(LLtypeMixin.nextdescr, b4s, ca)
    v2.setfield(LLtypeMixin.valuedescr, c1s, ca)
    b2s.set_forwarded(v2)

    modifier.register_virtual_fields(b2s, [c1s, None, None, None, b4s])
    modifier.register_virtual_fields(b4s, [b3s, None, None, None, b2s, b5s])

    liveboxes = []
    modifier._number_virtuals(liveboxes, 0)
    storage.rd_consts = memo.consts[:]
    storage.rd_numb = Numbering([0])
    # resume
    b3t, b5t = [IntFrontendOp(0), RefFrontendOp(0)]
    b5t.setref_base(demo55o)
    b3t.setint(33)
    newboxes = _resume_remap(liveboxes, [#b2s -- virtual
                                         b3s,
                                         #b4s -- virtual
                                         #b2s -- again, shared
                                         #b3s -- again, shared
                                         b5s], b3t, b5t)

    metainterp = MyMetaInterp()
    reader = ResumeDataFakeReader(storage, newboxes, metainterp)
    assert len(reader.virtuals_cache.virtuals_ptr_cache) == 2
    b2t = reader.decode_ref(modifier._gettagged(b2s))
    b4t = reader.decode_ref(modifier._gettagged(b4s))
    trace = metainterp.trace
    b2new = (rop.NEW_WITH_VTABLE, [], b2t.getref_base(), LLtypeMixin.nodesize)
    b4new = (rop.NEW_WITH_VTABLE, [], b4t.getref_base(), LLtypeMixin.nodesize2)
    b2set = [(rop.SETFIELD_GC, [b2t, b4t],      None, LLtypeMixin.nextdescr),
             (rop.SETFIELD_GC, [b2t, c1s],      None, LLtypeMixin.valuedescr)]
    b4set = [(rop.SETFIELD_GC, [b4t, b2t],     None, LLtypeMixin.nextdescr),
             (rop.SETFIELD_GC, [b4t, b3t],     None, LLtypeMixin.valuedescr),
             (rop.SETFIELD_GC, [b4t, b5t],     None, LLtypeMixin.otherdescr)]
    expected = [b2new, b4new] + b4set + b2set

    # check that we get the operations in 'expected', in a possibly different
    # order.
    assert len(trace) == len(expected)
    orig = trace[:]
    with CompareableConsts():
        for x in trace:
            assert x in expected
            expected.remove(x)

    ptr = b2t.getref_base()._obj.container._as_ptr()
    assert lltype.typeOf(ptr) == lltype.Ptr(LLtypeMixin.NODE)
    assert ptr.value == 111
    ptr2 = ptr.next
    ptr2 = lltype.cast_pointer(lltype.Ptr(LLtypeMixin.NODE2), ptr2)
    assert ptr2.other == demo55
    assert ptr2.parent.value == 33
    assert ptr2.parent.next == ptr
Exemplo n.º 14
0
def test_ResumeDataLoopMemo_number_virtuals():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    b1, b2 = [IntFrontendOp(0), IntFrontendOp(0)]
    assert memo.num_cached_virtuals() == 0
    num = memo.assign_number_to_virtual(b1)
    assert num == -1
    assert memo.num_cached_virtuals() == 1
    num = memo.assign_number_to_virtual(b1)
    assert num == -1
    num = memo.assign_number_to_virtual(b2)
    assert num == -2

    assert memo.num_cached_virtuals() == 2
    num = memo.assign_number_to_virtual(b2)
    assert num == -2
    num = memo.assign_number_to_virtual(b1)
    assert num == -1

    memo.clear_box_virtual_numbers()
    assert memo.num_cached_virtuals() == 0
Exemplo n.º 15
0
def test_ResumeDataLoopMemo_number_boxes():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    b1, b2 = [IntFrontendOp(0), IntFrontendOp(0)]
    assert memo.num_cached_boxes() == 0
    boxes = []
    num = memo.assign_number_to_box(b1, boxes)
    assert num == -1
    assert boxes == [b1]
    assert memo.num_cached_boxes() == 1
    boxes = [None]
    num = memo.assign_number_to_box(b1, boxes)
    assert num == -1
    assert boxes == [b1]
    num = memo.assign_number_to_box(b2, boxes)
    assert num == -2
    assert boxes == [b1, b2]

    assert memo.num_cached_boxes() == 2
    boxes = [None, None]
    num = memo.assign_number_to_box(b2, boxes)
    assert num == -2
    assert boxes == [None, b2]
    num = memo.assign_number_to_box(b1, boxes)
    assert num == -1
    assert boxes == [b1, b2]

    memo.clear_box_virtual_numbers()
    assert memo.num_cached_boxes() == 0
Exemplo n.º 16
0
def test_ResumeDataLoopMemo_number():
    b1, b2, b3, b4, b5 = [IntFrontendOp(0), IntFrontendOp(1), IntFrontendOp(2),
                          RefFrontendOp(3), RefFrontendOp(4)]
    c1, c2, c3, c4 = [ConstInt(1), ConstInt(2), ConstInt(3), ConstInt(4)]

    env = [b1, c1, b2, b1, c2]
    metainterp_sd = FakeMetaInterpStaticData()
    t = Trace([b1, b2, b3, b4, b5], metainterp_sd)
    snap = t.create_snapshot(FakeJitCode("jitcode", 0), 0, Frame(env), False)
    env1 = [c3, b3, b1, c1]
    t.append(0) # descr index
    snap1 = t.create_top_snapshot(FakeJitCode("jitcode", 0), 2, Frame(env1), False,
        [], [])
    snap1.prev = snap

    env2 = [c3, b3, b1, c3]
    env3 = [c3, b3, b1, c3]
    env4 = [c3, b4, b1, c3]
    env5 = [b1, b4, b5]

    memo = ResumeDataLoopMemo(metainterp_sd)

    iter = t.get_iter()
    b1, b2, b3, b4, b5 = iter.inputargs
    numb_state = memo.number(0, iter)
    numb = numb_state.create_numbering()
    assert numb_state.num_virtuals == 0

    assert numb_state.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX),
                                    b3: tag(2, TAGBOX)}
    base = [0, 0, tag(0, TAGBOX), tag(1, TAGINT),
            tag(1, TAGBOX), tag(0, TAGBOX), tag(2, TAGINT)]

    assert unpack_numbering(numb) == [17, 0, 0, 0] + base + [0, 2, tag(3, TAGINT), tag(2, TAGBOX),
                                      tag(0, TAGBOX), tag(1, TAGINT)]
    t.append(0)
    snap2 = t.create_top_snapshot(FakeJitCode("jitcode", 0), 2, Frame(env2),
                                  False, [], [])
    snap2.prev = snap

    numb_state2 = memo.number(1, iter)
    numb2 = numb_state2.create_numbering()
    assert numb_state2.num_virtuals == 0

    assert numb_state2.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX),
                                     b3: tag(2, TAGBOX)}
    assert numb_state2.liveboxes is not numb_state.liveboxes
    assert unpack_numbering(numb2) == [17, 0, 0, 0] + base + [0, 2, tag(3, TAGINT), tag(2, TAGBOX),
                                       tag(0, TAGBOX), tag(3, TAGINT)]

    t.append(0)
    snap3 = t.create_top_snapshot(FakeJitCode("jitcode", 0), 2, Frame([]),
                                  False, [], env3)
    snap3.prev = snap

    class FakeVirtualInfo(info.AbstractVirtualPtrInfo):
        def __init__(self, virt):
            self._is_virtual = virt

        def is_virtual(self):
            return self._is_virtual

    # renamed
    b3.set_forwarded(c4)
    numb_state3 = memo.number(2, iter)
    numb3 = numb_state3.create_numbering()
    assert numb_state3.num_virtuals == 0

    assert numb_state3.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX)}
    assert unpack_numbering(numb3) == ([17, 0, 0, 2, tag(3, TAGINT), tag(4, TAGINT),
                                       tag(0, TAGBOX), tag(3, TAGINT)] +
                                       base + [0, 2])

    # virtual
    t.append(0)
    snap4 = t.create_top_snapshot(FakeJitCode("jitcode", 0), 2, Frame([]),
                                  False, [], env4)
    snap4.prev = snap

    b4.set_forwarded(FakeVirtualInfo(True))
    numb_state4 = memo.number(3, iter)
    numb4 = numb_state4.create_numbering()
    assert numb_state4.num_virtuals == 1

    assert numb_state4.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX),
                                     b4: tag(0, TAGVIRTUAL)}
    assert unpack_numbering(numb4) == [17, 0, 0, 2, tag(3, TAGINT), tag(0, TAGVIRTUAL),
                                       tag(0, TAGBOX), tag(3, TAGINT)] + base + [0, 2]

    t.append(0)
    snap4 = t.create_snapshot(FakeJitCode("jitcode", 2), 1, Frame(env4), False)
    t.append(0)
    snap4.prev = snap
    snap5 = t.create_top_snapshot(FakeJitCode("jitcode", 0), 0, Frame([]), False,
                                  env5, [])
    snap5.prev = snap4

    b4.set_forwarded(FakeVirtualInfo(True))
    b5.set_forwarded(FakeVirtualInfo(True))
    numb_state5 = memo.number(4, iter)
    numb5 = numb_state5.create_numbering()
    assert numb_state5.num_virtuals == 2

    assert numb_state5.liveboxes == {b1: tag(0, TAGBOX), b2: tag(1, TAGBOX),
                                     b4: tag(0, TAGVIRTUAL), b5: tag(1, TAGVIRTUAL)}
    assert unpack_numbering(numb5) == [22, 0,
        3, tag(0, TAGBOX), tag(0, TAGVIRTUAL), tag(1, TAGVIRTUAL),
        0] + base + [
        2, 1, tag(3, TAGINT), tag(0, TAGVIRTUAL), tag(0, TAGBOX), tag(3, TAGINT)
        ] + [0, 0]