[pypy-svn] r78015 - in pypy/branch/leak-finder: dotviewer pypy/jit/metainterp

arigo at codespeak.net arigo at codespeak.net
Sat Oct 16 16:40:51 CEST 2010


Author: arigo
Date: Sat Oct 16 16:40:50 2010
New Revision: 78015

Modified:
   pypy/branch/leak-finder/dotviewer/drawgraph.py
   pypy/branch/leak-finder/pypy/jit/metainterp/graphpage.py
   pypy/branch/leak-finder/pypy/jit/metainterp/resoperation.py
Log:
Improve the readability of the JIT flow graphs by changing the color of
the prefix to the operations (the name of where it comes from).



Modified: pypy/branch/leak-finder/dotviewer/drawgraph.py
==============================================================================
--- pypy/branch/leak-finder/dotviewer/drawgraph.py	(original)
+++ pypy/branch/leak-finder/dotviewer/drawgraph.py	Sat Oct 16 16:40:50 2010
@@ -423,20 +423,43 @@
         else:
             for line in lines:
                 raw_line = line.replace('\\l','').replace('\r','') or ' '
-                img = TextSnippet(self, raw_line, (0, 0, 0), bgcolor)
-                w, h = img.get_size()
-                if w>wmax: wmax = w
-                if raw_line.strip():
-                    if line.endswith('\\l'):
-                        def cmd(img=img, y=hmax):
-                            img.draw(xleft, ytop+y)
-                    elif line.endswith('\r'):
-                        def cmd(img=img, y=hmax, w=w):
-                            img.draw(xright-w, ytop+y)
-                    else:
-                        def cmd(img=img, y=hmax, w=w):
-                            img.draw(xcenter-w//2, ytop+y)
+                if '\f' in raw_line:   # grayed out parts of the line
+                    imgs = []
+                    graytext = True
+                    h = 16
+                    w_total = 0
+                    for linepart in raw_line.split('\f'):
+                        graytext = not graytext
+                        if not linepart.strip():
+                            continue
+                        if graytext:
+                            fgcolor = (128, 160, 160)
+                        else:
+                            fgcolor = (0, 0, 0)
+                        img = TextSnippet(self, linepart, fgcolor, bgcolor)
+                        imgs.append((w_total, img))
+                        w, h = img.get_size()
+                        w_total += w
+                    if w_total > wmax: wmax = w_total
+                    def cmd(imgs=imgs, y=hmax):
+                        for x, img in imgs:
+                            img.draw(xleft+x, ytop+y)
                     commands.append(cmd)
+                else:
+                    img = TextSnippet(self, raw_line, (0, 0, 0), bgcolor)
+                    w, h = img.get_size()
+                    if w>wmax: wmax = w
+                    if raw_line.strip():
+                        if line.endswith('\\l'):
+                            def cmd(img=img, y=hmax):
+                                img.draw(xleft, ytop+y)
+                        elif line.endswith('\r'):
+                            def cmd(img=img, y=hmax, w=w):
+                                img.draw(xright-w, ytop+y)
+                        else:
+                            def cmd(img=img, y=hmax, w=w):
+                                img.draw(xcenter-w//2, ytop+y)
+                        commands.append(cmd)
                 hmax += h
                 #hmax += 8
 

Modified: pypy/branch/leak-finder/pypy/jit/metainterp/graphpage.py
==============================================================================
--- pypy/branch/leak-finder/pypy/jit/metainterp/graphpage.py	(original)
+++ pypy/branch/leak-finder/pypy/jit/metainterp/graphpage.py	Sat Oct 16 16:40:50 2010
@@ -153,7 +153,7 @@
         opindex = opstartindex
         while True:
             op = operations[opindex]
-            lines.append(repr(op))
+            lines.append(op.repr(graytext=True))
             if is_interesting_guard(op):
                 tgt = op.getdescr()._debug_suboperations[0]
                 tgt_g, tgt_i = self.all_operations[tgt]

Modified: pypy/branch/leak-finder/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/leak-finder/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/leak-finder/pypy/jit/metainterp/resoperation.py	Sat Oct 16 16:40:50 2010
@@ -93,7 +93,7 @@
     def __repr__(self):
         return self.repr()
 
-    def repr(self):
+    def repr(self, graytext=False):
         # RPython-friendly version
         if self.result is not None:
             sres = '%s = ' % (self.result,)
@@ -101,6 +101,8 @@
             sres = ''
         if self.name:
             prefix = "%s:%s   " % (self.name, self.pc)
+            if graytext:
+                prefix = "\f%s\f" % prefix
         else:
             prefix = ""
         args = self.getarglist()



More information about the Pypy-commit mailing list