]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use expandable columns in ssa.html
authorYury Smolsky <yury@smolsky.by>
Thu, 7 Jun 2018 21:25:12 +0000 (00:25 +0300)
committerKeith Randall <khr@golang.org>
Wed, 13 Jun 2018 21:02:54 +0000 (21:02 +0000)
Display just a few columns in ssa.html, other
columns can be expanded by clicking on collapsed column.

Use sans serif font for the text, slightly smaller font size
for non program text.

Fixes #25286

Change-Id: I1094695135401602d90b97b69e42f6dda05871a2
Reviewed-on: https://go-review.googlesource.com/117275
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/html.go

index a64d21223307e4eab7511ce831fc79bfb16ff28b..3c15c8e555a842e966b34e6ef7da02bf88f98332 100644 (file)
@@ -4985,7 +4985,7 @@ func genssa(f *ssa.Func, pp *Progs) {
                        }
                        buf.WriteString("</dl>")
                        buf.WriteString("</code>")
-                       f.HTMLWriter.WriteColumn("genssa", "ssa-prog", buf.String())
+                       f.HTMLWriter.WriteColumn("genssa", "genssa", "ssa-prog", buf.String())
                        // pp.Text.Ctxt.LineHist.PrintFilenameOnly = saved
                }
        }
index 4bd9ade4799b4ab6b4c3a4d43ff8385cc636dc45..c7797d79e92a8cdde8b91c0a66fad587d7d4b5df 100644 (file)
@@ -43,7 +43,7 @@ func Compile(f *Func) {
 
        // Run all the passes
        printFunc(f)
-       f.HTMLWriter.WriteFunc("start", f)
+       f.HTMLWriter.WriteFunc("start", "start", f)
        if BuildDump != "" && BuildDump == f.Name {
                f.dumpFile("build")
        }
@@ -86,7 +86,7 @@ func Compile(f *Func) {
 
                        f.Logf("  pass %s end %s\n", p.name, stats)
                        printFunc(f)
-                       f.HTMLWriter.WriteFunc(fmt.Sprintf("after %s <span class=\"stats\">%s</span>", phaseName, stats), f)
+                       f.HTMLWriter.WriteFunc(phaseName, fmt.Sprintf("%s <span class=\"stats\">%s</span>", phaseName, stats), f)
                }
                if p.time || p.mem {
                        // Surround timing information w/ enough context to allow comparisons.
index 85d97ba4970bfc6da093b02965972772e04f8d26..d37e69977e767d42a6b9ff44ec77a23d9a133b14 100644 (file)
@@ -38,6 +38,11 @@ func (w *HTMLWriter) start(name string) {
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
 <style>
 
+body {
+    font-size: 14px;
+    font-family: Arial, sans-serif;
+}
+
 #helplink {
     margin-bottom: 15px;
     display: block;
@@ -66,6 +71,32 @@ th, td {
     padding: 5px;
 }
 
+td > h2 {
+    cursor: pointer;
+    font-size: 120%;
+}
+
+td.collapsed {
+    font-size: 12px;
+    width: 12px;
+    border: 0px;
+    padding: 0;
+    cursor: pointer;
+    background: #fafafa;
+}
+
+td.collapsed  div {
+     -moz-transform: rotate(-90.0deg);  /* FF3.5+ */
+       -o-transform: rotate(-90.0deg);  /* Opera 10.5 */
+  -webkit-transform: rotate(-90.0deg);  /* Saf3.1+, Chrome */
+             filter:  progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);  /* IE6,IE7 */
+         -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)"; /* IE8 */
+         margin-top: 10.3em;
+         margin-left: -10em;
+         margin-right: -10em;
+         text-align: right;
+}
+
 td.ssa-prog {
     width: 600px;
     word-wrap: break-word;
@@ -263,6 +294,56 @@ window.onload = function() {
     for (var i = 0; i < ssablocks.length; i++) {
         ssablocks[i].addEventListener('click', ssaBlockClicked);
     }
+   var expandedDefault = [
+        "start",
+        "deadcode",
+        "opt",
+        "lower",
+        "late deadcode",
+        "regalloc",
+        "genssa",
+    ]
+    function isExpDefault(id) {
+        for (var i = 0; i < expandedDefault.length; i++) {
+            if (id.startsWith(expandedDefault[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+    function toggler(phase) {
+        return function() {
+            toggle_cell(phase+'-col');
+            toggle_cell(phase+'-exp');
+        };
+    }
+    function toggle_cell(id) {
+       var e = document.getElementById(id);
+       if(e.style.display == 'table-cell')
+          e.style.display = 'none';
+       else
+          e.style.display = 'table-cell';
+    }
+
+    var td = document.getElementsByTagName("td");
+    for (var i = 0; i < td.length; i++) {
+        var id = td[i].id;
+        var def = isExpDefault(id);
+        var phase = id.substr(0, id.length-4);
+        if (id.endsWith("-exp")) {
+            var h2 = td[i].getElementsByTagName("h2");
+            if (h2 && h2[0]) {
+                h2[0].addEventListener('click', toggler(phase));
+            }
+        } else {
+               td[i].addEventListener('click', toggler(phase));
+        }
+        if (id.endsWith("-col") && def || id.endsWith("-exp") && !def) {
+               td[i].style.display = 'none';
+               continue
+        }
+        td[i].style.display = 'table-cell';
+    }
 };
 
 function toggle_visibility(id) {
@@ -316,24 +397,28 @@ func (w *HTMLWriter) Close() {
 }
 
 // WriteFunc writes f in a column headed by title.
-func (w *HTMLWriter) WriteFunc(title string, f *Func) {
+func (w *HTMLWriter) WriteFunc(phase, title string, f *Func) {
        if w == nil {
                return // avoid generating HTML just to discard it
        }
-       w.WriteColumn(title, "", f.HTML())
+       w.WriteColumn(phase, title, "", f.HTML())
        // TODO: Add visual representation of f's CFG.
 }
 
 // WriteColumn writes raw HTML in a column headed by title.
 // It is intended for pre- and post-compilation log output.
-func (w *HTMLWriter) WriteColumn(title, class, html string) {
+func (w *HTMLWriter) WriteColumn(phase, title, class, html string) {
        if w == nil {
                return
        }
+       id := strings.Replace(phase, " ", "-", -1)
+       // collapsed column
+       w.Printf("<td id=\"%v-col\" class=\"collapsed\"><div>%v</div></td>", id, phase)
+
        if class == "" {
-               w.WriteString("<td>")
+               w.Printf("<td id=\"%v-exp\">", id)
        } else {
-               w.WriteString("<td class=\"" + class + "\">")
+               w.Printf("<td id=\"%v-exp\" class=\"%v\">", id, class)
        }
        w.WriteString("<h2>" + title + "</h2>")
        w.WriteString(html)