Beispiel #1
0
    def deserialize_optheap(self, triples_struct, triples_array):
        for box1, descr, box2 in triples_struct:
            parent_descr = descr.get_parent_descr()
            assert parent_descr.is_object()
            if box1.is_constant():
                structinfo = info.ConstPtrInfo(box1)
            else:
                structinfo = box1.get_forwarded()
                if not isinstance(structinfo, info.AbstractVirtualPtrInfo):
                    structinfo = info.InstancePtrInfo(parent_descr)
                    structinfo.init_fields(parent_descr, descr.get_index())
                    box1.set_forwarded(structinfo)
            cf = self.field_cache(descr)
            structinfo.setfield(descr, box1, box2, optheap=self, cf=cf)

        for box1, index, descr, box2 in triples_array:
            if box1.is_constant():
                arrayinfo = info.ConstPtrInfo(box1)
            else:
                arrayinfo = box1.get_forwarded()
                if not isinstance(arrayinfo, info.AbstractVirtualPtrInfo):
                    arrayinfo = info.ArrayPtrInfo(descr)
                    box1.set_forwarded(arrayinfo)
            cf = self.arrayitem_cache(descr, index)
            arrayinfo.setitem(descr, index, box1, box2, optheap=self, cf=cf)
Beispiel #2
0
 def getptrinfo(self, op, is_object=False):
     if op.type == 'i':
         return self.getrawptrinfo(op)
     elif op.type == 'f':
         return None
     assert op.type == 'r'
     op = self.get_box_replacement(op)
     assert op.type == 'r'
     if isinstance(op, ConstPtr):
         return info.ConstPtrInfo(op)
     fw = op.get_forwarded()
     if fw is not None:
         assert isinstance(fw, info.PtrInfo)
         return fw
     return None
Beispiel #3
0
 def getrawptrinfo(self, op, create=False, is_object=False):
     assert op.type == 'i'
     op = self.get_box_replacement(op)
     assert op.type == 'i'
     if isinstance(op, ConstInt):
         return info.ConstPtrInfo(op)
     fw = op.get_forwarded()
     if isinstance(fw, IntBound) and not create:
         return None
     if fw is not None:
         if isinstance(fw, info.AbstractRawPtrInfo):
             return fw
         fw = info.RawStructPtrInfo()
         op.set_forwarded(fw)
         assert isinstance(fw, info.AbstractRawPtrInfo)
         return fw
     return None
Beispiel #4
0
    def ensure_ptr_info_arg0(self, op):
        from rpython.jit.metainterp.optimizeopt import vstring

        arg0 = self.get_box_replacement(op.getarg(0))
        if arg0.is_constant():
            return info.ConstPtrInfo(arg0)
        opinfo = arg0.get_forwarded()
        if isinstance(opinfo, info.AbstractVirtualPtrInfo):
            return opinfo
        elif opinfo is not None:
            last_guard_pos = opinfo.get_last_guard_pos()
        else:
            last_guard_pos = -1
        assert opinfo is None or opinfo.__class__ is info.NonNullPtrInfo
        opnum = op.opnum
        if (rop.is_getfield(opnum) or opnum == rop.SETFIELD_GC
                or opnum == rop.QUASIIMMUT_FIELD):
            descr = op.getdescr()
            parent_descr = descr.get_parent_descr()
            if parent_descr.is_object():
                opinfo = info.InstancePtrInfo(parent_descr)
            else:
                opinfo = info.StructPtrInfo(parent_descr)
            opinfo.init_fields(parent_descr, descr.get_index())
        elif (rop.is_getarrayitem(opnum) or opnum == rop.SETARRAYITEM_GC
              or opnum == rop.ARRAYLEN_GC):
            opinfo = info.ArrayPtrInfo(op.getdescr())
        elif opnum in (rop.GUARD_CLASS, rop.GUARD_NONNULL_CLASS):
            opinfo = info.InstancePtrInfo()
        elif opnum in (rop.STRLEN, ):
            opinfo = vstring.StrPtrInfo(vstring.mode_string)
        elif opnum in (rop.UNICODELEN, ):
            opinfo = vstring.StrPtrInfo(vstring.mode_unicode)
        else:
            assert False, "operations %s unsupported" % op
        assert isinstance(opinfo, info.NonNullPtrInfo)
        opinfo.last_guard_pos = last_guard_pos
        arg0.set_forwarded(opinfo)
        return opinfo