Example #1
0
def test_jitted():
    from rpython.jit.backend import detect_cpu
    if not detect_cpu.autodetect().startswith('x86'):
        py.test.skip("HAS_CODEMAP is only in the x86 jit backend for now")

    class MyCode:
        pass

    def get_name(mycode):
        raise NotImplementedError

    rvmprof.register_code_object_class(MyCode, get_name)

    jitdriver = jit.JitDriver(
        greens=['code'],
        reds='auto',
        is_recursive=True,
        get_unique_id=lambda code: rvmprof.get_unique_id(code))

    @rvmprof.vmprof_execute_code("mycode", lambda code, level, total_i: code)
    def mainloop(code, level, total_i):
        i = 20
        while i > 0:
            jitdriver.jit_merge_point(code=code)
            i -= 1
            if level > 0:
                mainloop(code, level - 1, total_i + i)
        if level == 0 and total_i == 0:
            p, length = traceback.traceback(20)
            traceback.walk_traceback(MyCode, my_callback, 42, p, length)
            lltype.free(p, flavor='raw')

    def my_callback(code, loc, arg):
        print code, loc, arg
        return 0

    def f(argv):
        jit.set_param(jitdriver, "inlining", 0)
        code1 = MyCode()
        rvmprof.register_code(code1, "foo")
        mainloop(code1, 2, 0)
        return 0

    t = Translation(f, None, gc="boehm")
    t.rtype()
    t.driver.pyjitpl_lltype()
    t.compile_c()
    stdout = t.driver.cbuilder.cmdexec('')
    r = re.compile("[<]MyCode object at 0x([0-9a-f]+)[>] (\d) 42\n")
    got = r.findall(stdout)
    addr = got[0][0]
    assert got == [(addr, '1'), (addr, '1'), (addr, '0')]
Example #2
0
def test_jitted():
    from rpython.jit.backend import detect_cpu

    if not detect_cpu.autodetect().startswith("x86"):
        py.test.skip("HAS_CODEMAP is only in the x86 jit backend for now")

    class MyCode:
        pass

    def get_name(mycode):
        raise NotImplementedError

    rvmprof.register_code_object_class(MyCode, get_name)

    jitdriver = jit.JitDriver(
        greens=["code"], reds="auto", is_recursive=True, get_unique_id=lambda code: rvmprof.get_unique_id(code)
    )

    @rvmprof.vmprof_execute_code("mycode", lambda code, level, total_i: code)
    def mainloop(code, level, total_i):
        i = 20
        while i > 0:
            jitdriver.jit_merge_point(code=code)
            i -= 1
            if level > 0:
                mainloop(code, level - 1, total_i + i)
        if level == 0 and total_i == 0:
            p, length = traceback.traceback(20)
            traceback.walk_traceback(MyCode, my_callback, 42, p, length)
            lltype.free(p, flavor="raw")

    def my_callback(code, loc, arg):
        print code, loc, arg
        return 0

    def f(argv):
        jit.set_param(jitdriver, "inlining", 0)
        code1 = MyCode()
        rvmprof.register_code(code1, "foo")
        mainloop(code1, 2, 0)
        return 0

    t = Translation(f, None, gc="boehm")
    t.rtype()
    t.driver.pyjitpl_lltype()
    t.compile_c()
    stdout = t.driver.cbuilder.cmdexec("")
    r = re.compile("[<]MyCode object at 0x([0-9a-f]+)[>] (\d) 42\n")
    got = r.findall(stdout)
    addr = got[0][0]
    assert got == [(addr, "1"), (addr, "1"), (addr, "0")]
Example #3
0
def get_unique_id(pc, block, module, unit, exc, function):
    return rvmprof.get_unique_id(function)
Example #4
0
def get_unique_id(next_instr, is_being_profiled, bytecode):
    from rpython.rlib import rvmprof
    return rvmprof.get_unique_id(bytecode)
 def get_unique_id(pc, ops):
     from rpython.rlib import rvmprof
     return rvmprof.get_unique_id(ops)
Example #6
0
 def get_unique_id(code):
     return rvmprof.get_unique_id(code)
Example #7
0
 def get_unique_id(code):
     return rvmprof.get_unique_id(code)