Commits

Maciej Fijalkowski committed 0c723aa

initial checkin

Comments (0)

Files changed (2)

+
+from pypy.tool.logparser import parse_log_file, extract_category
+from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.metainterp.resoperation import rop
+
+class LoopChunk(object):
+    def __init__(self, operations):
+        self.operations = operations
+
+    def __repr__(self):
+        return "[%s]" % ", ".join([repr(op) for op in self.operations])
+
+class Loop(object):
+    def __init__(self, chunks):
+        self.chunks = chunks
+
+    def __repr__(self):
+        return "[%s]" % ", ".join([repr(chunk) for chunk in self.chunks])
+
+def slice_debug_merge_points(loop):
+    so_far = []
+    res = []
+    for op in loop.operations:
+        if op.getopnum() == rop.DEBUG_MERGE_POINT:
+            if so_far:
+                res.append(LoopChunk(so_far))
+                so_far = []
+        so_far.append(op)
+    if so_far:
+        res.append(LoopChunk(so_far))
+    return Loop(res)
+
+def main():
+    log = parse_log_file('log')
+    loops = [parse(l, no_namespace=True, nonstrict=True) for l in
+             extract_category(log, "jit-log-opt-")]
+    find_first_debug_merge_point(loops[0])
+
+if __name__ == '__main__':
+    main()

test/test_base.py

+
+from pypy.jit.metainterp.test.oparser import parse
+from baseviewer import slice_debug_merge_points
+
+def test_split():
+    ops = parse('''
+    [i0]
+    debug_merge_point("<code object stuff, file '/tmp/x.py', line 200> #10 ADD")
+    debug_merge_point("<code object stuf, file '/tmp/x.py', line 201> #11 SUB")
+    i1 = int_add(i0, 1)
+    debug_merge_point("<code object stuf, file '/tmp/x.py', line 202> #11 SUB")
+    i2 = int_add(i1, 1)
+    ''', no_namespace=True, nonstrict=True)
+    res = slice_debug_merge_points(ops)
+    assert len(res.chunks) == 3
+    assert len(res.chunks[0].operations) == 1
+    assert len(res.chunks[1].operations) == 2
+    assert len(res.chunks[2].operations) == 2
+    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.