Beispiel #1
0
 def build_meta_interp(self,
                       CPUClass,
                       translate_support_code=False,
                       view="auto",
                       no_stats=False,
                       ProfilerClass=EmptyProfiler,
                       **kwds):
     assert CPUClass is not None
     opt = history.Options(**kwds)
     if no_stats:
         stats = history.NoStats()
     else:
         stats = history.Stats()
     self.stats = stats
     if translate_support_code:
         self.annhelper = MixLevelHelperAnnotator(self.translator.rtyper)
         annhelper = self.annhelper
     else:
         annhelper = None
     cpu = CPUClass(self.translator.rtyper,
                    self.stats,
                    translate_support_code,
                    gcdescr=self.gcdescr)
     self.cpu = cpu
     self.metainterp_sd = MetaInterpStaticData(
         self.portal_graph,  # xxx
         cpu,
         self.stats,
         opt,
         ProfilerClass=ProfilerClass,
         warmrunnerdesc=self)
Beispiel #2
0
 def build_cpu(self,
               CPUClass,
               translate_support_code=False,
               no_stats=False,
               supports_floats=True,
               supports_longlong=True,
               supports_singlefloats=True,
               **kwds):
     assert CPUClass is not None
     self.opt = history.Options(**kwds)
     if no_stats:
         stats = history.NoStats()
     else:
         stats = history.Stats()
     self.stats = stats
     if translate_support_code:
         self.annhelper = MixLevelHelperAnnotator(self.translator.rtyper)
     cpu = CPUClass(self.translator.rtyper,
                    self.stats,
                    self.opt,
                    translate_support_code,
                    gcdescr=self.gcdescr)
     if not supports_floats: cpu.supports_floats = False
     if not supports_longlong: cpu.supports_longlong = False
     if not supports_singlefloats: cpu.supports_singlefloats = False
     self.cpu = cpu
Beispiel #3
0
def _get_bare_metainterp(func, values, CPUClass, type_system, listops=False):
    from pypy.annotation.policy import AnnotatorPolicy
    from pypy.annotation.model import lltype_to_annotation
    from pypy.rpython.test.test_llinterp import gengraph

    rtyper = support.annotate(func, values, type_system=type_system)

    stats = history.Stats()
    cpu = CPUClass(rtyper, stats, None, False)
    graphs = rtyper.annotator.translator.graphs
    opt = history.Options(listops=listops)
    metainterp_sd = pyjitpl.MetaInterpStaticData(graphs[0], cpu, stats, opt)
    metainterp_sd.finish_setup(optimizer="bogus")
    metainterp = pyjitpl.MetaInterp(metainterp_sd)
    return metainterp, rtyper
Beispiel #4
0
def _run_with_pyjitpl(testself, args):
    class DoneWithThisFrame(Exception):
        pass

    class DoneWithThisFrameRef(DoneWithThisFrame):
        def __init__(self, cpu, *args):
            DoneWithThisFrame.__init__(self, *args)

    cw = testself.cw
    opt = history.Options(listops=True)
    metainterp_sd = pyjitpl.MetaInterpStaticData(cw.cpu, opt)
    metainterp_sd.finish_setup(cw)
    [jitdriver_sd] = metainterp_sd.jitdrivers_sd
    metainterp = pyjitpl.MetaInterp(metainterp_sd, jitdriver_sd)
    metainterp_sd.DoneWithThisFrameInt = DoneWithThisFrame
    metainterp_sd.DoneWithThisFrameRef = DoneWithThisFrameRef
    metainterp_sd.DoneWithThisFrameFloat = DoneWithThisFrame
    testself.metainterp = metainterp
    try:
        metainterp.compile_and_run_once(jitdriver_sd, *args)
    except DoneWithThisFrame, e:
        #if conftest.option.view:
        #    metainterp.stats.view()
        return e.args[0]