コード例 #1
0
ファイル: test_parser.py プロジェクト: sota/pypy-old
def test_import_log_2():
    if not autodetect().startswith('x86'):
        py.test.skip('x86 only test')
    _, loops = import_log(
        str(py.path.local(__file__).join('..', 'logtest2.log')))
    for loop in loops:
        loop.force_asm()
    assert 'cmp' in loops[1].operations[2].asm
コード例 #2
0
def test_import_log_2():
    _, loops = import_log(str(py.path.local(__file__).join('..',
                                                           'logtest2.log')))
    for loop in loops:
        loop.force_asm()
    assert 'cmp' in loops[1].operations[1].asm
    # bridge
    assert 'jo' in loops[3].operations[3].asm
コード例 #3
0
ファイル: test_parser.py プロジェクト: purepython/pypy
def test_import_log_2():
    _, loops = import_log(
        str(py.path.local(__file__).join('..', 'logtest2.log')))
    for loop in loops:
        loop.force_asm()
    assert 'cmp' in loops[1].operations[1].asm
    # bridge
    assert 'jo' in loops[3].operations[3].asm
コード例 #4
0
def getMySources(filename):
    extra_path = os.path.dirname(filename)
    storage = LoopStorage(extra_path)

    log, loops = import_log(filename, ParserWithHtmlRepr)
    parse_log_counts(extract_category(log, "jit-backend-count"), loops)
    storage.loops = [loop for loop in loops if not loop.descr.startswith("bridge")]
    [l.force_asm() for l in storage.loops]
    storage.loop_dict = create_loop_dict(loops)
    loops = index(storage)
    ids = [item.descr for item in loops]

    mySources = []
    for item in ids:
        source, name, up, filename, startline, callstack = loopfunc(item, storage)
        i = 1
        mySource = []
        pending = False
        pendingLine = 0
        pendingCode = ""
        for sourceline in source.lines:
            # print  str(i) + ": " + sourceline.line
            line = sourceline.line
            chunks = []
            if sourceline.in_loop and line.strip != "":
                if sourceline.chunks:
                    makePending = True
                    for chunk in sourceline.chunks:
                        if chunk.is_bytecode:
                            ops = []
                            for op in chunk.operations:
                                if op.name != "debug_merge_point":
                                    op_repr = (op.html_repr(), op.asm)
                                    ops.append(op_repr)
                            chunks.append((chunk.html_repr(), chunk, ops))

            if len(chunks) == 0:
                if pending:
                    pendingCode += "\n" + line
                else:
                    pendingCode = line
                    pendingLine = i
                    pending = True
            else:
                if pending:
                    pending = False
                    mySource.append((pendingLine, pendingCode, None))
                mySource.append((i, line, chunks))
            i += 1
        if pending:
            pending = False
            mySource.append((pendingLine, pendingCode, None))
        mySources.append((filename, mySource))

    return mySources
コード例 #5
0
def main():
    filename = sys.argv[1]
    extra_path = os.path.dirname(filename)
    storage = LoopStorage(extra_path)
    
    log, loops = import_log(filename, ParserWithHtmlRepr)
    parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
    storage.loops = [loop for loop in loops
                     if not loop.descr.startswith('bridge')]
    storage.loop_dict = create_loop_dict(loops)
    print loops,log,storage
    server = Server(filename, storage)
コード例 #6
0
ファイル: app.py プロジェクト: michielbaird/VisJitViewer
def main():
    if not '__pypy__' in sys.builtin_module_names:
        print "Please run it using pypy-c"
        sys.exit(1)
    #
    server_mode = True
    if '--qt' in sys.argv:
        server_mode = False
        sys.argv.remove('--qt')
    #
    if len(sys.argv) != 2 and len(sys.argv) != 3:
        print __doc__
        sys.exit(1)
    filename = sys.argv[1]
    extra_path = os.path.dirname(filename)
    if len(sys.argv) != 3:
        port = 5000
    else:
        port = int(sys.argv[2])
    storage = LoopStorage(extra_path)
    log, loops = import_log(filename, ParserWithHtmlRepr)
    parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
    storage.loops = [loop for loop in loops
                     if not loop.descr.startswith('bridge')]
    storage.loop_dict = create_loop_dict(loops)
    print loops,log,storage
    app = OverrideFlask('_jitviewer')
    server = Server(filename, storage)
    app.debug = True
    app.route('/')(server.index)
    app.route('/loop')(server.loop)
    def run():
        app.run(use_reloader=False, host='0.0.0.0', port=port)

    if server_mode:
        run()
    else:
        url = "http://localhost:%d/" % port
        run_server_and_browser(app, run, url, filename)
コード例 #7
0
ファイル: test_jitlogparser.py プロジェクト: charred/pypy
    def test(self):
        def fn_with_bridges(N):
            def is_prime(x):
                for y in xrange(2, x):
                    if x % y == 0:
                        return False
                return True
            result = 0
            for x in xrange(N):
                if x % 3 == 0:
                    result += 5
                elif x % 5 == 0:
                    result += 3
                elif is_prime(x):
                    result += x
                elif x == 99:
                    result *= 2
            return result
        #
        N = 10000
        _log = self.run(fn_with_bridges, [N])
        log, loops = import_log(_log.logfile)
        parse_log_counts(extract_category(log, 'jit-backend-count'), loops)

        is_prime_loops = []
        fn_with_bridges_loops = []
        bridges = {}

        lib_re = re.compile("file '.*lib-python.*'")
        for loop in loops:
            if hasattr(loop, 'force_asm'):
                try:
                    loop.force_asm()
                except ObjdumpNotFound:
                    py.test.skip("ObjDump was not found, skipping")
            if lib_re.search(loop.comment) or \
                    lib_re.search(loop.operations[0].repr()):
                # do not care for _optimize_charset or _mk_bitmap
                continue
            assert loop.count > 0
            if ' is_prime, ' in loop.comment:
                is_prime_loops.append(loop)
            elif ' fn_with_bridges, ' in loop.comment:
                fn_with_bridges_loops.append(loop)
            else:
                assert ' bridge ' in loop.comment
                key = mangle_descr(loop.descr)
                assert key not in bridges
                bridges[key] = loop

        by_count = lambda l: -l.count
        is_prime_loops.sort(key=by_count)
        fn_with_bridges_loops.sort(key=by_count)

        # check that we can find bridges corresponding to " % 3" and " % 5"
        mod_bridges = []
        for op in fn_with_bridges_loops[0].operations:
            if op.descr is not None:
                bridge = bridges.get(mangle_descr(op.descr))
                if bridge is not None:
                    mod_bridges.append(bridge)
        assert len(mod_bridges) in (1, 2)

        # check that counts are reasonable (precise # may change in the future)
        assert N - 2000 < sum(l.count for l in fn_with_bridges_loops) < N
コード例 #8
0
ファイル: test_parser.py プロジェクト: purepython/pypy
def test_import_log():
    _, loops = import_log(
        str(py.path.local(__file__).join('..', 'logtest.log')))
    for loop in loops:
        loop.force_asm()
    assert 'jge' in loops[0].operations[3].asm
コード例 #9
0
def test_import_log():
    _, loops = import_log(str(py.path.local(__file__).join('..',
                                                           'logtest.log')))
    for loop in loops:
        loop.force_asm()
    assert 'jge' in loops[0].operations[3].asm