[pypy-commit] pypy default: some fixes

fijal noreply at buildbot.pypy.org
Tue Dec 27 10:37:20 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r50887:a91f8bee90b0
Date: 2011-12-27 11:37 +0200
http://bitbucket.org/pypy/pypy/changeset/a91f8bee90b0/

Log:	some fixes

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -147,17 +147,19 @@
     inline_level = None
 
     def __init__(self, operations, storage):
-        if operations[0].name == 'debug_merge_point':
-            self.inline_level = int(operations[0].args[0])
-            m = re.search('<code object ([<>\w]+)\. file \'(.+?)\'\. line (\d+)> #(\d+) (\w+)',
-                         operations[0].args[1])
-            if m is None:
-                # a non-code loop, like StrLiteralSearch or something
-                self.bytecode_name = operations[0].args[1][1:-1]
-            else:
-                self.name, self.filename, lineno, bytecode_no, self.bytecode_name = m.groups()
-                self.startlineno = int(lineno)
-                self.bytecode_no = int(bytecode_no)
+        for op in operations:
+            if op.name == 'debug_merge_point':
+                self.inline_level = int(op.args[0])
+                m = re.search('<code object ([<>\w]+)\. file \'(.+?)\'\. line (\d+)> #(\d+) (\w+)',
+                             op.args[1])
+                if m is None:
+                    # a non-code loop, like StrLiteralSearch or something
+                    self.bytecode_name = op.args[1][1:-1]
+                else:
+                    self.name, self.filename, lineno, bytecode_no, self.bytecode_name = m.groups()
+                    self.startlineno = int(lineno)
+                    self.bytecode_no = int(bytecode_no)
+                break
         self.operations = operations
         self.storage = storage
         self.code = storage.disassemble_code(self.filename, self.startlineno,
@@ -225,6 +227,7 @@
         Also detect inlined functions and make them Function
         """
         stack = []
+        seen_dmp = False
 
         def getpath(stack):
             return ",".join([str(len(v)) for v in stack])
@@ -245,11 +248,14 @@
         stack = []
         for op in operations:
             if op.name == 'debug_merge_point':
-                if so_far:
-                    append_to_res(cls.TraceForOpcode(so_far, storage))
-                    if limit:
-                        break
-                    so_far = []
+                if seen_dmp:
+                    if so_far:
+                        append_to_res(cls.TraceForOpcode(so_far, storage))
+                        if limit:
+                            break
+                        so_far = []
+                else:
+                    seen_dmp = True
             so_far.append(op)
         if so_far:
             append_to_res(cls.TraceForOpcode(so_far, storage))
@@ -405,6 +411,7 @@
         part = copy(trace)
         part.operations = trace.operations[start : stop + 1]
         part.descr = descrs[i]
+        part.comment = trace.comment
         parts.append(part)
     
     return parts
diff --git a/pypy/tool/jitlogparser/test/test_parser.py b/pypy/tool/jitlogparser/test/test_parser.py
--- a/pypy/tool/jitlogparser/test/test_parser.py
+++ b/pypy/tool/jitlogparser/test/test_parser.py
@@ -38,6 +38,7 @@
 def test_split():
     ops = parse('''
     [i0]
+    label()
     debug_merge_point(0, "<code object stuff. file '/I/dont/exist.py'. line 200> #10 ADD")
     debug_merge_point(0, "<code object stuff. file '/I/dont/exist.py'. line 200> #11 SUB")
     i1 = int_add(i0, 1)
@@ -46,7 +47,7 @@
     ''')
     res = Function.from_operations(ops.operations, LoopStorage())
     assert len(res.chunks) == 3
-    assert len(res.chunks[0].operations) == 1
+    assert len(res.chunks[0].operations) == 2
     assert len(res.chunks[1].operations) == 2
     assert len(res.chunks[2].operations) == 2
     assert res.chunks[2].bytecode_no == 11
@@ -96,7 +97,7 @@
     i2 = int_add(i1, 1)
     ''')
     res = Function.from_operations(ops.operations, LoopStorage())
-    assert res.repr() == res.chunks[1].repr()
+    assert res.repr() == res.chunks[0].repr()
 
 def test_lineno():
     fname = str(py.path.local(__file__).join('..', 'x.py'))


More information about the pypy-commit mailing list