| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 document.onload = (function(d3){ | 5 document.onload = (function(d3){ |
| 6 "use strict"; | 6 "use strict"; |
| 7 var jsonObj; | 7 var jsonObj; |
| 8 var sourceExpandClassList = document.getElementById(SOURCE_EXPAND_ID).classLis
t; | 8 var sourceExpandClassList = document.getElementById(SOURCE_EXPAND_ID).classLis
t; |
| 9 var sourceCollapseClassList = document.getElementById(SOURCE_COLLAPSE_ID).clas
sList; | 9 var sourceCollapseClassList = document.getElementById(SOURCE_COLLAPSE_ID).clas
sList; |
| 10 var sourceExpanded = sourceCollapseClassList.contains(COLLAPSE_PANE_BUTTON_VIS
IBLE); | 10 var sourceExpanded = sourceCollapseClassList.contains(COLLAPSE_PANE_BUTTON_VIS
IBLE); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 selectMenu.innerHTML = ''; | 177 selectMenu.innerHTML = ''; |
| 178 for (var i = 0; i < jsonObj.phases.length; ++i) { | 178 for (var i = 0; i < jsonObj.phases.length; ++i) { |
| 179 var optionElement = document.createElement("option"); | 179 var optionElement = document.createElement("option"); |
| 180 optionElement.text = jsonObj.phases[i].name; | 180 optionElement.text = jsonObj.phases[i].name; |
| 181 if (optionElement.text == 'disassembly') { | 181 if (optionElement.text == 'disassembly') { |
| 182 disassemblyPhase = jsonObj.phases[i]; | 182 disassemblyPhase = jsonObj.phases[i]; |
| 183 } else { | 183 } else { |
| 184 selectMenu.add(optionElement, null); | 184 selectMenu.add(optionElement, null); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 |
| 188 var eventMenu = document.getElementById('event-selector'); |
| 189 eventMenu.innerHTML = ''; |
| 190 for (var event in jsonObj.eventCounts) { |
| 191 var optionElement = document.createElement("option"); |
| 192 optionElement.text = event; |
| 193 eventMenu.add(optionElement, null); |
| 194 } |
| 195 disassemblyView.initializePerfProfile(jsonObj.eventCounts); |
| 187 disassemblyView.setNodePositionMap(jsonObj.nodePositions); | 196 disassemblyView.setNodePositionMap(jsonObj.nodePositions); |
| 188 disassemblyView.show(disassemblyPhase.data, null); | 197 disassemblyView.show(disassemblyPhase.data, null); |
| 189 | 198 |
| 190 var initialPhaseIndex = +window.sessionStorage.getItem("lastSelected
Phase"); | 199 var initialPhaseIndex = +window.sessionStorage.getItem("lastSelected
Phase"); |
| 191 if (!(initialPhaseIndex in jsonObj.phases)) { | 200 if (!(initialPhaseIndex in jsonObj.phases)) { |
| 192 initialPhaseIndex = 0; | 201 initialPhaseIndex = 0; |
| 193 } | 202 } |
| 194 | 203 |
| 195 // We wish to show the remembered phase {lastSelectedPhase}, but | 204 // We wish to show the remembered phase {lastSelectedPhase}, but |
| 196 // this will crash if the first view we switch to is a | 205 // this will crash if the first view we switch to is a |
| 197 // ScheduleView. So we first switch to the first phase, which | 206 // ScheduleView. So we first switch to the first phase, which |
| 198 // should never be a ScheduleView. | 207 // should never be a ScheduleView. |
| 199 displayPhase(jsonObj.phases[0]); | 208 displayPhase(jsonObj.phases[0]); |
| 200 displayPhase(jsonObj.phases[initialPhaseIndex]); | 209 displayPhase(jsonObj.phases[initialPhaseIndex]); |
| 201 selectMenu.selectedIndex = initialPhaseIndex; | 210 selectMenu.selectedIndex = initialPhaseIndex; |
| 202 | 211 |
| 203 selectMenu.onchange = function(item) { | 212 selectMenu.onchange = function(item) { |
| 204 window.sessionStorage.setItem("lastSelectedPhase", selectMenu.sele
ctedIndex); | 213 window.sessionStorage.setItem("lastSelectedPhase", selectMenu.sele
ctedIndex); |
| 205 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); | 214 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); |
| 206 } | 215 } |
| 207 | 216 |
| 217 eventMenu.onchange = function(item) { |
| 218 disassemblyView.show(disassemblyView.data, null); |
| 219 } |
| 220 |
| 208 fitPanesToParents(); | 221 fitPanesToParents(); |
| 209 | 222 |
| 210 d3.select("#search-input").attr("value", window.sessionStorage.getIt
em("lastSearch") || ""); | 223 d3.select("#search-input").attr("value", window.sessionStorage.getIt
em("lastSearch") || ""); |
| 211 | 224 |
| 212 } | 225 } |
| 213 catch(err) { | 226 catch(err) { |
| 214 window.console.log("caught exception, clearing session storage just
in case"); | 227 window.console.log("caught exception, clearing session storage just
in case"); |
| 215 window.sessionStorage.clear(); // just in case | 228 window.sessionStorage.clear(); // just in case |
| 216 window.console.log("showing error"); | 229 window.console.log("showing error"); |
| 217 window.alert("Invalid TurboFan JSON file\n" + | 230 window.alert("Invalid TurboFan JSON file\n" + |
| (...skipping 15 matching lines...) Expand all Loading... |
| 233 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); | 246 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); |
| 234 | 247 |
| 235 initializeHandlers(graph); | 248 initializeHandlers(graph); |
| 236 | 249 |
| 237 setSourceExpanded(getLastExpandedState("source", true)); | 250 setSourceExpanded(getLastExpandedState("source", true)); |
| 238 setDisassemblyExpanded(getLastExpandedState("disassembly", false)); | 251 setDisassemblyExpanded(getLastExpandedState("disassembly", false)); |
| 239 | 252 |
| 240 displayPhaseView(empty, null); | 253 displayPhaseView(empty, null); |
| 241 fitPanesToParents(); | 254 fitPanesToParents(); |
| 242 })(window.d3); | 255 })(window.d3); |
| OLD | NEW |