def add_op_to_short(self, sb): sop = self.getfield_op preamble_arg = sb.produce_arg(sop.getarg(0)) if preamble_arg is None: return None if rop.is_getfield(sop.opnum): preamble_op = ResOperation(sop.getopnum(), [preamble_arg], descr=sop.getdescr()) else: preamble_op = ResOperation(sop.getopnum(), [preamble_arg, sop.getarg(1)], descr=sop.getdescr()) return ProducedShortOp(self, preamble_op)
def add_op_to_short(self, sb): sop = self.getfield_op preamble_arg = sb.produce_arg(sop.getarg(0)) if preamble_arg is None: return None if rop.is_getfield(sop.opnum): preamble_op = ResOperation(sop.getopnum(), [preamble_arg], descr=sop.getdescr()) else: preamble_op = ResOperation( sop.getopnum(), [preamble_arg, sop.getarg(1)], descr=sop.getdescr()) return ProducedShortOp(self, preamble_op)
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
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
def produce_op(self, opt, preamble_op, exported_infos, invented_name): optheap = opt.optimizer.optheap if optheap is None: return g = preamble_op.copy_and_change(preamble_op.getopnum(), args=self.getfield_op.getarglist()) if g.getarg(0) in exported_infos: opt.optimizer.setinfo_from_preamble(g.getarg(0), exported_infos[g.getarg(0)], exported_infos) opinfo = opt.optimizer.ensure_ptr_info_arg0(g) pop = PreambleOp(self.res, preamble_op, invented_name) assert not opinfo.is_virtual() descr = self.getfield_op.getdescr() if rop.is_getfield(g.opnum): cf = optheap.field_cache(descr) opinfo.setfield(preamble_op.getdescr(), g.getarg(0), pop, optheap, cf) else: index = g.getarg(1).getint() assert index >= 0 cf = optheap.arrayitem_cache(descr, index) opinfo.setitem(self.getfield_op.getdescr(), index, g.getarg(0), pop, optheap, cf)