def test_compute_bitstrings(): class FDescr: pass class ADescr: pass class CDescr: def __init__(self, ei): self._ei = ei def get_extra_info(self): return self._ei f1descr = FDescr() f2descr = FDescr() f3descr = FDescr() a1descr = ADescr() a2descr = ADescr() ei1 = EffectInfo(None, None, None, None, None, None, EffectInfo.EF_RANDOM_EFFECTS) ei2 = EffectInfo([f1descr], [], [], [], [], []) ei3 = EffectInfo([f1descr], [a1descr, a2descr], [], [f2descr], [], []) compute_bitstrings([CDescr(ei1), CDescr(ei2), CDescr(ei3), f1descr, f2descr, f3descr, a1descr, a2descr]) assert f1descr.ei_index in (0, 1) assert f2descr.ei_index == 1 - f1descr.ei_index assert f3descr.ei_index == sys.maxint assert a1descr.ei_index == 0 assert a2descr.ei_index == 0 assert ei1.bitstring_readonly_descrs_fields is None assert ei1.bitstring_readonly_descrs_arrays is None assert ei1.bitstring_write_descrs_fields is None def expand(bitstr): return [n for n in range(10) if bitcheck(bitstr, n)] assert expand(ei2.bitstring_readonly_descrs_fields) == [f1descr.ei_index] assert expand(ei2.bitstring_write_descrs_fields) == [] assert expand(ei2.bitstring_readonly_descrs_arrays) == [] assert expand(ei2.bitstring_write_descrs_arrays) == [] assert expand(ei3.bitstring_readonly_descrs_fields) == [f1descr.ei_index] assert expand(ei3.bitstring_write_descrs_fields) == [f2descr.ei_index] assert expand(ei3.bitstring_readonly_descrs_arrays) == [0] #a1descr,a2descr assert expand(ei3.bitstring_write_descrs_arrays) == [] for ei in [ei2, ei3]: for fdescr in [f1descr, f2descr]: assert ei.check_readonly_descr_field(fdescr) == ( fdescr in ei._readonly_descrs_fields) assert ei.check_write_descr_field(fdescr) == ( fdescr in ei._write_descrs_fields) for adescr in [a1descr, a2descr]: assert ei.check_readonly_descr_array(adescr) == ( adescr in ei._readonly_descrs_arrays) assert ei.check_write_descr_array(adescr) == ( adescr in ei._write_descrs_arrays)
def _do_optimize_loop(self, compile_data): from rpython.jit.metainterp.optimizeopt import optimize_trace metainterp_sd = FakeMetaInterpStaticData(self.cpu) if hasattr(self, 'vrefinfo'): metainterp_sd.virtualref_info = self.vrefinfo if hasattr(self, 'callinfocollection'): metainterp_sd.callinfocollection = self.callinfocollection compute_bitstrings(self.cpu.fetch_all_descrs()) # compile_data.enable_opts = self.enable_opts state = optimize_trace(metainterp_sd, None, compile_data) return state
def _do_optimize_loop(self, compile_data): from rpython.jit.metainterp.optimizeopt import optimize_trace metainterp_sd = FakeMetaInterpStaticData(self.cpu) if hasattr(self, 'vrefinfo'): metainterp_sd.virtualref_info = self.vrefinfo if hasattr(self, 'callinfocollection'): metainterp_sd.callinfocollection = self.callinfocollection compute_bitstrings(self.cpu.fetch_all_descrs()) # compile_data.enable_opts = self.enable_opts state = optimize_trace(metainterp_sd, None, compile_data) state[0]._check_no_forwarding() return state
def cls_attributes(self): metainterp_sd = FakeMetaInterpStaticData(self.cpu) metainterp_sd.virtualref_info = self.vrefinfo compute_bitstrings(self.cpu.fetch_all_descrs()) self.metainterp_sd = metainterp_sd
def test_compute_bitstrings(): class FDescr: pass class ADescr: pass class CDescr: def __init__(self, ei): self._ei = ei def get_extra_info(self): return self._ei f1descr = FDescr() f2descr = FDescr() f3descr = FDescr() a1descr = ADescr() a2descr = ADescr() ei1 = EffectInfo(None, None, None, None, None, None, EffectInfo.EF_RANDOM_EFFECTS) ei2 = EffectInfo([f1descr], [], [], [], [], []) ei3 = EffectInfo([f1descr], [a1descr, a2descr], [], [f2descr], [], []) compute_bitstrings([ CDescr(ei1), CDescr(ei2), CDescr(ei3), f1descr, f2descr, f3descr, a1descr, a2descr ]) assert f1descr.ei_index in (0, 1) assert f2descr.ei_index == 1 - f1descr.ei_index assert f3descr.ei_index == sys.maxint assert a1descr.ei_index == 0 assert a2descr.ei_index == 0 assert ei1.bitstring_readonly_descrs_fields is None assert ei1.bitstring_readonly_descrs_arrays is None assert ei1.bitstring_write_descrs_fields is None def expand(bitstr): return [n for n in range(10) if bitcheck(bitstr, n)] assert expand(ei2.bitstring_readonly_descrs_fields) == [f1descr.ei_index] assert expand(ei2.bitstring_write_descrs_fields) == [] assert expand(ei2.bitstring_readonly_descrs_arrays) == [] assert expand(ei2.bitstring_write_descrs_arrays) == [] assert expand(ei3.bitstring_readonly_descrs_fields) == [f1descr.ei_index] assert expand(ei3.bitstring_write_descrs_fields) == [f2descr.ei_index] assert expand(ei3.bitstring_readonly_descrs_arrays) == [0 ] #a1descr,a2descr assert expand(ei3.bitstring_write_descrs_arrays) == [] for ei in [ei2, ei3]: for fdescr in [f1descr, f2descr]: assert ei.check_readonly_descr_field(fdescr) == ( fdescr in ei._readonly_descrs_fields) assert ei.check_write_descr_field(fdescr) == ( fdescr in ei._write_descrs_fields) for adescr in [a1descr, a2descr]: assert ei.check_readonly_descr_array(adescr) == ( adescr in ei._readonly_descrs_arrays) assert ei.check_write_descr_array(adescr) == ( adescr in ei._write_descrs_arrays)