Ejemplo n.º 1
0
def degenerate_item(item, ITEM_TYPE):
    if isinstance(ITEM_TYPE, lltype.ContainerType):
        hs = item.s_value
        assert isinstance(hs, hintmodel.SomeLLAbstractContainer)
        hs.contentdef.mark_degenerated()
    else:
        item.generalize(hintmodel.SomeLLAbstractVariable(ITEM_TYPE))
Ejemplo n.º 2
0
 def consider_op_new(self, hs_TYPE):
     TYPE = hs_TYPE.const
     if self.policy.novirtualcontainer:
         return hintmodel.SomeLLAbstractVariable(TYPE)
     else:
         # XXX: ootype
         vstructdef = self.bookkeeper.getvirtualcontainerdef(TYPE)
         return hintmodel.SomeLLAbstractContainer(vstructdef)
Ejemplo n.º 3
0
 def consider_op_malloc_varsize(self, hs_TYPE, hs_flags, hs_length):
     TYPE = hs_TYPE.const
     flags = hs_flags.const
     assert flags['flavor'] == 'gc'
     if self.policy.novirtualcontainer:
         return hintmodel.SomeLLAbstractVariable(lltype.Ptr(TYPE))
     else:
         vcontainerdef = self.bookkeeper.getvirtualcontainerdef(TYPE)
         return hintmodel.SomeLLAbstractContainer(vcontainerdef)
Ejemplo n.º 4
0
    def genop(self, block, opname, args, resulttype=None, result_like=None, red=False):
        # 'result_like' can be a template variable whose hintannotation is
        # copied
        if resulttype is not None:
            v_res = varoftype(resulttype)
            if red:
                hs = hintmodel.SomeLLAbstractVariable(resulttype)
            else:
                hs = hintmodel.SomeLLAbstractConstant(resulttype, {})
            self.hannotator.setbinding(v_res, hs)
        elif result_like is not None:
            v_res = copyvar(self.hannotator, result_like)
        else:
            v_res = self.new_void_var()

        spaceop = SpaceOperation(opname, args, v_res)
        if isinstance(block, list):
            block.append(spaceop)
        else:
            block.operations.append(spaceop)
        return v_res
Ejemplo n.º 5
0
    def handle_raisingop(self, block, i, opdesc):
        op = block.operations[i]
        if self.hannotator.binding(op.result).is_green():
            # case not really well supported
            v_red = Variable(op.result)
            v_red.concretetype = op.result.concretetype
            hs_red = hintmodel.SomeLLAbstractVariable(op.result.concretetype)
            self.hannotator.setbinding(v_red, hs_red)
            spaceop = SpaceOperation('revealconst', [v_red], op.result)
            op.result = v_red
            i += 1
            block.operations.insert(i, spaceop)

        link = split_block(self.hannotator, block, i+1)

        reds, greens = self.sort_by_color(link.args)
        self.genop(block, 'save_locals', reds)
        resumepoint = self.get_resume_point(link.target)
        c_resumepoint = inputconst(lltype.Signed, resumepoint)

        assert len(opdesc.canraise) == 1    # for now
        c_canraise = inputconst(lltype.Void, opdesc.canraise[0])
        self.genop(block, 'split_raisingop',
                   [self.c_dummy, c_resumepoint, c_canraise] + greens)