Author: Armin Rigo <[email protected]>
Branch: py3k-faulthandler
Changeset: r87437:cabd383ef26c
Date: 2016-09-29 10:13 +0200
http://bitbucket.org/pypy/pypy/changeset/cabd383ef26c/

Log:    De-duplicate traceback entries after a LOC_JITTED

diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -18,6 +18,7 @@
 VMPROF_JITTED_TAG = 3
 VMPROF_JITTING_TAG = 4
 VMPROF_GC_TAG = 5
+VMPROF_ASSEMBLER_TAG = 6
 
 class VMProfError(Exception):
     def __init__(self, msg):
diff --git a/rpython/rlib/rvmprof/traceback.py 
b/rpython/rlib/rvmprof/traceback.py
--- a/rpython/rlib/rvmprof/traceback.py
+++ b/rpython/rlib/rvmprof/traceback.py
@@ -47,19 +47,40 @@
     'code_obj' may be None if it can't be determined.  'loc' is one
     of the LOC_xxx constants.
     """
+    dedup = 0
     i = 0
     while i < array_length - 1:
         tag = array_p[i]
         tagged_value = array_p[i + 1]
+
         if tag == rvmprof.VMPROF_CODE_TAG:
+            # VMPROF_CODE_TAG is from an interpreted frame.
+            # If the previously-printed frame was a LOC_JITTED, then it
+            # should be a duplicate of the very same frame here.  In
+            # that case, after checking that it is indeed the same frame
+            # for sanity, we don't print it again.
             loc = LOC_INTERPRETED
-            _traceback_one(CodeClass, callback, arg, tagged_value, loc)
+            if tagged_value != dedup or tagged_value == 0:
+                _traceback_one(CodeClass, callback, arg, tagged_value, loc)
+            dedup = 0
+
         elif tag == rvmprof.VMPROF_JITTED_TAG:
             if i + 2 >= array_length:  # skip last entry, can't determine if
                 break                  # it's LOC_JITTED_INLINED or LOC_JITTED
+
+            # A bunch of VMPROF_JITTED_TAG entries consecutively in the
+            # stack trace correspond to one piece of machine code with
+            # inlined frames.  There is a VMPROF_ASSEMBLER_TAG before,
+            # so we are sure that there is at least one non-JITTED_TAG
+            # between one such bunch and the next one.  De-duplicate
+            # like we do for LOC_INTERPRETED, and record in 'dedup' the
+            # code id if we're printing LOC_JITTED (i.e. the last frame
+            # of this bunch).
             if array_p[i + 2] == rvmprof.VMPROF_JITTED_TAG:
                 loc = LOC_JITTED_INLINED
             else:
                 loc = LOC_JITTED
-            _traceback_one(CodeClass, callback, arg, tagged_value, loc)
+            if tagged_value != dedup or tagged_value == 0:
+                _traceback_one(CodeClass, callback, arg, tagged_value, loc)
+            dedup = tagged_value if loc == LOC_JITTED else 0
         i += 2
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to