| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 for (var i = 0; i < jsonObj.phases.length; ++i) { | 181 for (var i = 0; i < jsonObj.phases.length; ++i) { |
| 182 var optionElement = document.createElement("option"); | 182 var optionElement = document.createElement("option"); |
| 183 optionElement.text = jsonObj.phases[i].name; | 183 optionElement.text = jsonObj.phases[i].name; |
| 184 if (optionElement.text == 'disassembly') { | 184 if (optionElement.text == 'disassembly') { |
| 185 disassemblyPhase = jsonObj.phases[i]; | 185 disassemblyPhase = jsonObj.phases[i]; |
| 186 } else { | 186 } else { |
| 187 selectMenu.add(optionElement, null); | 187 selectMenu.add(optionElement, null); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 var eventMenu = document.getElementById('event-selector'); | |
| 192 eventMenu.innerHTML = ''; | |
| 193 for (var event in jsonObj.eventCounts) { | |
| 194 var optionElement = document.createElement("option"); | |
| 195 optionElement.text = event; | |
| 196 eventMenu.add(optionElement, null); | |
| 197 } | |
| 198 disassemblyView.initializePerfProfile(jsonObj.eventCounts); | 191 disassemblyView.initializePerfProfile(jsonObj.eventCounts); |
| 199 disassemblyView.show(disassemblyPhase.data, null); | 192 disassemblyView.show(disassemblyPhase.data, null); |
| 200 | 193 |
| 201 var initialPhaseIndex = +window.sessionStorage.getItem("lastSelected
Phase"); | 194 var initialPhaseIndex = +window.sessionStorage.getItem("lastSelected
Phase"); |
| 202 if (!(initialPhaseIndex in jsonObj.phases)) { | 195 if (!(initialPhaseIndex in jsonObj.phases)) { |
| 203 initialPhaseIndex = 0; | 196 initialPhaseIndex = 0; |
| 204 } | 197 } |
| 205 | 198 |
| 206 // We wish to show the remembered phase {lastSelectedPhase}, but | 199 // We wish to show the remembered phase {lastSelectedPhase}, but |
| 207 // this will crash if the first view we switch to is a | 200 // this will crash if the first view we switch to is a |
| 208 // ScheduleView. So we first switch to the first phase, which | 201 // ScheduleView. So we first switch to the first phase, which |
| 209 // should never be a ScheduleView. | 202 // should never be a ScheduleView. |
| 210 displayPhase(jsonObj.phases[0]); | 203 displayPhase(jsonObj.phases[0]); |
| 211 displayPhase(jsonObj.phases[initialPhaseIndex]); | 204 displayPhase(jsonObj.phases[initialPhaseIndex]); |
| 212 selectMenu.selectedIndex = initialPhaseIndex; | 205 selectMenu.selectedIndex = initialPhaseIndex; |
| 213 | 206 |
| 214 selectMenu.onchange = function(item) { | 207 selectMenu.onchange = function(item) { |
| 215 window.sessionStorage.setItem("lastSelectedPhase", selectMenu.sele
ctedIndex); | 208 window.sessionStorage.setItem("lastSelectedPhase", selectMenu.sele
ctedIndex); |
| 216 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); | 209 displayPhase(jsonObj.phases[selectMenu.selectedIndex]); |
| 217 } | 210 } |
| 218 | 211 |
| 219 eventMenu.onchange = function(item) { | |
| 220 disassemblyView.show(disassemblyView.data, null); | |
| 221 } | |
| 222 | |
| 223 fitPanesToParents(); | 212 fitPanesToParents(); |
| 224 | 213 |
| 225 d3.select("#search-input").attr("value", window.sessionStorage.getIt
em("lastSearch") || ""); | 214 d3.select("#search-input").attr("value", window.sessionStorage.getIt
em("lastSearch") || ""); |
| 226 | 215 |
| 227 } | 216 } |
| 228 catch(err) { | 217 catch(err) { |
| 229 window.console.log("caught exception, clearing session storage just
in case"); | 218 window.console.log("caught exception, clearing session storage just
in case"); |
| 230 window.sessionStorage.clear(); // just in case | 219 window.sessionStorage.clear(); // just in case |
| 231 window.console.log("showing error"); | 220 window.console.log("showing error"); |
| 232 window.alert("Invalid TurboFan JSON file\n" + | 221 window.alert("Invalid TurboFan JSON file\n" + |
| (...skipping 15 matching lines...) Expand all Loading... |
| 248 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); | 237 empty = new EmptyView(EMPTY_PANE_ID, selectionBroker); |
| 249 | 238 |
| 250 initializeHandlers(graph); | 239 initializeHandlers(graph); |
| 251 | 240 |
| 252 setSourceExpanded(getLastExpandedState("source", true)); | 241 setSourceExpanded(getLastExpandedState("source", true)); |
| 253 setDisassemblyExpanded(getLastExpandedState("disassembly", false)); | 242 setDisassemblyExpanded(getLastExpandedState("disassembly", false)); |
| 254 | 243 |
| 255 displayPhaseView(empty, null); | 244 displayPhaseView(empty, null); |
| 256 fitPanesToParents(); | 245 fitPanesToParents(); |
| 257 })(window.d3); | 246 })(window.d3); |
| OLD | NEW |