diff options
Diffstat (limited to 'src/cmd/compile/internal/ssa/html.go')
| -rw-r--r-- | src/cmd/compile/internal/ssa/html.go | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go index ba37a80412..a9d52fa4ee 100644 --- a/src/cmd/compile/internal/ssa/html.go +++ b/src/cmd/compile/internal/ssa/html.go @@ -28,18 +28,23 @@ type HTMLWriter struct { } func NewHTMLWriter(path string, f *Func, cfgMask string) *HTMLWriter { + path = strings.Replace(path, "/", string(filepath.Separator), -1) out, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { f.Fatalf("%v", err) } - pwd, err := os.Getwd() - if err != nil { - f.Fatalf("%v", err) + reportPath := path + if !filepath.IsAbs(reportPath) { + pwd, err := os.Getwd() + if err != nil { + f.Fatalf("%v", err) + } + reportPath = filepath.Join(pwd, path) } html := HTMLWriter{ w: out, Func: f, - path: filepath.Join(pwd, path), + path: reportPath, dot: newDotWriter(cfgMask), } html.start() @@ -119,7 +124,8 @@ td.collapsed { } td.collapsed div { - /* TODO: Flip the direction of the phase's title 90 degrees on a collapsed column. */ + text-align: right; + transform: rotate(180deg); writing-mode: vertical-lr; white-space: pre; } @@ -357,6 +363,21 @@ body.darkmode ellipse.outline-black { outline: gray solid 2px; } </style> <script type="text/javascript"> + +// Contains phase names which are expanded by default. Other columns are collapsed. +let expandedDefault = [ + "start", + "deadcode", + "opt", + "lower", + "late-deadcode", + "regalloc", + "genssa", +]; +if (history.state === null) { + history.pushState({expandedDefault}, "", location.href); +} + // ordered list of all available highlight colors var highlights = [ "highlight-aquamarine", @@ -401,6 +422,9 @@ for (var i = 0; i < outlines.length; i++) { } window.onload = function() { + if (history.state !== null) { + expandedDefault = history.state.expandedDefault; + } if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) { toggleDarkMode(); document.getElementById("dark-mode-button").checked = true; @@ -409,9 +433,6 @@ window.onload = function() { var ssaElemClicked = function(elem, event, selections, selected) { event.stopPropagation(); - // TODO: pushState with updated state and read it on page load, - // so that state can survive across reloads - // find all values with the same name var c = elem.classList.item(0); var x = document.getElementsByClassName(c); @@ -489,21 +510,18 @@ window.onload = function() { lines[i].addEventListener('click', ssaValueClicked); } - // Contains phase names which are expanded by default. Other columns are collapsed. - var expandedDefault = [ - "start", - "deadcode", - "opt", - "lower", - "late-deadcode", - "regalloc", - "genssa", - ]; function toggler(phase) { return function() { toggle_cell(phase+'-col'); toggle_cell(phase+'-exp'); + const i = expandedDefault.indexOf(phase); + if (i !== -1) { + expandedDefault.splice(i, 1); + } else { + expandedDefault.push(phase); + } + history.pushState({expandedDefault}, "", location.href); }; } @@ -531,9 +549,13 @@ window.onload = function() { const len = combined.length; if (len > 1) { for (let i = 0; i < len; i++) { - if (expandedDefault.indexOf(combined[i]) !== -1) { - show = true; - break; + const num = expandedDefault.indexOf(combined[i]); + if (num !== -1) { + expandedDefault.splice(num, 1); + if (expandedDefault.indexOf(phase) === -1) { + expandedDefault.push(phase); + show = true; + } } } } |
