Ejemplo n.º 1
0
    def add_finish(self):
        def finish():
            if self.metainterp_sd.profiler.initialized:
                self.metainterp_sd.profiler.finish()
            self.metainterp_sd.cpu.finish_once()

        if self.cpu.translate_support_code:
            call_final_function(self.translator, finish,
                                annhelper=self.annhelper)
Ejemplo n.º 2
0
    def add_finish(self):
        def finish():
            if self.metainterp_sd.profiler.initialized:
                self.metainterp_sd.profiler.finish()
            self.metainterp_sd.cpu.finish_once()

        if self.cpu.translate_support_code:
            call_final_function(self.translator, finish,
                                annhelper=self.annhelper)
Ejemplo n.º 3
0
def test_call_final_function():
    tmpfile = str(udir.join('test_call_final_function'))
    def f(x):
        return x * 6
    def goodbye_world():
        if we_are_translated():
            fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
            os.close(fd)
    graph, t = translate(f, [int])
    call_final_function(t, goodbye_world)
    #
    if os.path.exists(tmpfile):
        os.unlink(tmpfile)
    interp = LLInterpreter(t.rtyper)
    result = interp.eval_graph(graph, [7])
    assert result == 42
    assert os.path.isfile(tmpfile)
Ejemplo n.º 4
0
def test_call_final_function():
    tmpfile = str(udir.join('test_call_final_function'))

    def f(x):
        return x * 6

    def goodbye_world():
        if we_are_translated():
            fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
            os.close(fd)

    graph, t = translate(f, [int])
    call_final_function(t, goodbye_world)
    #
    if os.path.exists(tmpfile):
        os.unlink(tmpfile)
    interp = LLInterpreter(t.rtyper)
    result = interp.eval_graph(graph, [7])
    assert result == 42
    assert os.path.isfile(tmpfile)