Exemplo n.º 1
0
def test_nclc_nongc_not_passed_on():
    # +--- inputargs: pointer_to_gc
    # | v0 <- op_getsubstruct pointer_to_gc 'b'
    # +--- exitargs: pointer_to_gc (i.e. the pointer to non-gc doesn't leave the block)
    llops = LowLevelOpList()
    ptr_a = varoftype(lltype.Ptr(GcA))
    v_res = llops.genop("getsubstruct", [ptr_a, model.Constant('b', lltype.Void)],
                        resulttype=lltype.Ptr(NonGcB))
    block = model.Block([ptr_a])
    block.operations.extend(llops)
    block.closeblock(model.Link([ptr_a], None))
    assert not needs_conservative_livevar_calculation(block)
Exemplo n.º 2
0
def test_nclc_should_be_true():
    # this is testing a block like:
    # +--- inputargs: pointer_to_gc
    # | v0 <- op_getsubstruct pointer_to_gc 'b'
    # +--- exitargs: v0 (i.e. pointer to non-gc)
    llops = LowLevelOpList()
    ptr_a = varoftype(lltype.Ptr(GcA))
    v_res = llops.genop("getsubstruct", [ptr_a, model.Constant('b', lltype.Void)],
                        resulttype=lltype.Ptr(NonGcB))
    block = model.Block([ptr_a])
    block.operations.extend(llops)
    block.closeblock(model.Link([v_res], None))
    assert needs_conservative_livevar_calculation(block)
Exemplo n.º 3
0
def test_nclc_ignore_functype():
    # +--- inputargs: pointer_to_gc
    # | v0 <- op_getfield pointer_to_gc 'c'
    # +--- exitargs: v0 (i.e. a pointer to function)
    # pointers to functions are 'not gc' but functions are also
    # immortal so you don't need to muck around inserting keepalives
    # so *they* don't die!
    llops = LowLevelOpList()
    ptr_a = varoftype(lltype.Ptr(GcA))
    v_res = llops.genop("getfield", [ptr_a, model.Constant('c', lltype.Void)],
                        resulttype=GcA.c)
    block = model.Block([ptr_a])
    block.operations.extend(llops)
    block.closeblock(model.Link([v_res], None))
    assert not needs_conservative_livevar_calculation(block)