11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciimport { Sequence } from "../src/source-resolver"; 61cb0ef41Sopenharmony_ciimport { createElement } from "../src/util"; 71cb0ef41Sopenharmony_ciimport { TextView } from "../src/text-view"; 81cb0ef41Sopenharmony_ciimport { RangeView } from "../src/range-view"; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciexport class SequenceView extends TextView { 111cb0ef41Sopenharmony_ci sequence: Sequence; 121cb0ef41Sopenharmony_ci searchInfo: Array<any>; 131cb0ef41Sopenharmony_ci phaseSelect: HTMLSelectElement; 141cb0ef41Sopenharmony_ci numInstructions: number; 151cb0ef41Sopenharmony_ci currentPhaseIndex: number; 161cb0ef41Sopenharmony_ci phaseIndexes: Set<number>; 171cb0ef41Sopenharmony_ci isShown: boolean; 181cb0ef41Sopenharmony_ci rangeView: RangeView; 191cb0ef41Sopenharmony_ci showRangeView: boolean; 201cb0ef41Sopenharmony_ci toggleRangeViewEl: HTMLElement; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci createViewElement() { 231cb0ef41Sopenharmony_ci const pane = document.createElement('div'); 241cb0ef41Sopenharmony_ci pane.setAttribute('id', "sequence"); 251cb0ef41Sopenharmony_ci pane.classList.add("scrollable"); 261cb0ef41Sopenharmony_ci pane.setAttribute("tabindex", "0"); 271cb0ef41Sopenharmony_ci return pane; 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci constructor(parentId, broker) { 311cb0ef41Sopenharmony_ci super(parentId, broker); 321cb0ef41Sopenharmony_ci this.numInstructions = 0; 331cb0ef41Sopenharmony_ci this.phaseIndexes = new Set<number>(); 341cb0ef41Sopenharmony_ci this.isShown = false; 351cb0ef41Sopenharmony_ci this.showRangeView = false; 361cb0ef41Sopenharmony_ci this.rangeView = null; 371cb0ef41Sopenharmony_ci this.toggleRangeViewEl = this.elementForToggleRangeView(); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci attachSelection(s) { 411cb0ef41Sopenharmony_ci const view = this; 421cb0ef41Sopenharmony_ci if (!(s instanceof Set)) return; 431cb0ef41Sopenharmony_ci view.selectionHandler.clear(); 441cb0ef41Sopenharmony_ci view.blockSelectionHandler.clear(); 451cb0ef41Sopenharmony_ci const selected = new Array(); 461cb0ef41Sopenharmony_ci for (const key of s) selected.push(key); 471cb0ef41Sopenharmony_ci view.selectionHandler.select(selected, true); 481cb0ef41Sopenharmony_ci } 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci detachSelection() { 511cb0ef41Sopenharmony_ci this.blockSelection.clear(); 521cb0ef41Sopenharmony_ci return this.selection.detachSelection(); 531cb0ef41Sopenharmony_ci } 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci show() { 561cb0ef41Sopenharmony_ci this.currentPhaseIndex = this.phaseSelect.selectedIndex; 571cb0ef41Sopenharmony_ci if (!this.isShown) { 581cb0ef41Sopenharmony_ci this.isShown = true; 591cb0ef41Sopenharmony_ci this.phaseIndexes.add(this.currentPhaseIndex); 601cb0ef41Sopenharmony_ci this.container.appendChild(this.divNode); 611cb0ef41Sopenharmony_ci this.container.getElementsByClassName("graph-toolbox")[0].appendChild(this.toggleRangeViewEl); 621cb0ef41Sopenharmony_ci } 631cb0ef41Sopenharmony_ci if (this.showRangeView) this.rangeView.show(); 641cb0ef41Sopenharmony_ci } 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci hide() { 671cb0ef41Sopenharmony_ci // A single SequenceView object is used for two phases (i.e before and after 681cb0ef41Sopenharmony_ci // register allocation), tracking the indexes lets the redundant hides and 691cb0ef41Sopenharmony_ci // shows be avoided when switching between the two. 701cb0ef41Sopenharmony_ci this.currentPhaseIndex = this.phaseSelect.selectedIndex; 711cb0ef41Sopenharmony_ci if (!this.phaseIndexes.has(this.currentPhaseIndex)) { 721cb0ef41Sopenharmony_ci this.isShown = false; 731cb0ef41Sopenharmony_ci this.container.removeChild(this.divNode); 741cb0ef41Sopenharmony_ci this.container.getElementsByClassName("graph-toolbox")[0].removeChild(this.toggleRangeViewEl); 751cb0ef41Sopenharmony_ci if (this.showRangeView) this.rangeView.hide(); 761cb0ef41Sopenharmony_ci } 771cb0ef41Sopenharmony_ci } 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci onresize() { 801cb0ef41Sopenharmony_ci if (this.showRangeView) this.rangeView.onresize(); 811cb0ef41Sopenharmony_ci } 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci initializeContent(data, rememberedSelection) { 841cb0ef41Sopenharmony_ci this.divNode.innerHTML = ''; 851cb0ef41Sopenharmony_ci this.sequence = data.sequence; 861cb0ef41Sopenharmony_ci this.searchInfo = []; 871cb0ef41Sopenharmony_ci this.divNode.onclick = (e: MouseEvent) => { 881cb0ef41Sopenharmony_ci if (!(e.target instanceof HTMLElement)) return; 891cb0ef41Sopenharmony_ci const instructionId = Number.parseInt(e.target.dataset.instructionId, 10); 901cb0ef41Sopenharmony_ci if (!instructionId) return; 911cb0ef41Sopenharmony_ci if (!e.shiftKey) this.broker.broadcastClear(null); 921cb0ef41Sopenharmony_ci this.broker.broadcastInstructionSelect(null, [instructionId], true); 931cb0ef41Sopenharmony_ci }; 941cb0ef41Sopenharmony_ci this.phaseSelect = (document.getElementById('phase-select') as HTMLSelectElement); 951cb0ef41Sopenharmony_ci this.currentPhaseIndex = this.phaseSelect.selectedIndex; 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci this.addBlocks(this.sequence.blocks); 981cb0ef41Sopenharmony_ci const lastBlock = this.sequence.blocks[this.sequence.blocks.length - 1]; 991cb0ef41Sopenharmony_ci this.numInstructions = lastBlock.instructions[lastBlock.instructions.length - 1].id + 1; 1001cb0ef41Sopenharmony_ci this.addRangeView(); 1011cb0ef41Sopenharmony_ci this.attachSelection(rememberedSelection); 1021cb0ef41Sopenharmony_ci this.show(); 1031cb0ef41Sopenharmony_ci } 1041cb0ef41Sopenharmony_ci 1051cb0ef41Sopenharmony_ci elementForBlock(block) { 1061cb0ef41Sopenharmony_ci const view = this; 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ci function mkLinkHandler(id, handler) { 1091cb0ef41Sopenharmony_ci return function (e) { 1101cb0ef41Sopenharmony_ci e.stopPropagation(); 1111cb0ef41Sopenharmony_ci if (!e.shiftKey) { 1121cb0ef41Sopenharmony_ci handler.clear(); 1131cb0ef41Sopenharmony_ci } 1141cb0ef41Sopenharmony_ci handler.select(["" + id], true); 1151cb0ef41Sopenharmony_ci }; 1161cb0ef41Sopenharmony_ci } 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci function mkBlockLinkHandler(blockId) { 1191cb0ef41Sopenharmony_ci return mkLinkHandler(blockId, view.blockSelectionHandler); 1201cb0ef41Sopenharmony_ci } 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ci function mkInstructionLinkHandler(instrId) { 1231cb0ef41Sopenharmony_ci return mkLinkHandler(instrId, view.registerAllocationSelectionHandler); 1241cb0ef41Sopenharmony_ci } 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ci function mkOperandLinkHandler(text) { 1271cb0ef41Sopenharmony_ci return mkLinkHandler(text, view.selectionHandler); 1281cb0ef41Sopenharmony_ci } 1291cb0ef41Sopenharmony_ci 1301cb0ef41Sopenharmony_ci function elementForOperandWithSpan(span, text, searchInfo, isVirtual) { 1311cb0ef41Sopenharmony_ci const selectionText = isVirtual ? "virt_" + text : text; 1321cb0ef41Sopenharmony_ci span.onclick = mkOperandLinkHandler(selectionText); 1331cb0ef41Sopenharmony_ci searchInfo.push(text); 1341cb0ef41Sopenharmony_ci view.addHtmlElementForNodeId(selectionText, span); 1351cb0ef41Sopenharmony_ci const container = createElement("div", ""); 1361cb0ef41Sopenharmony_ci container.appendChild(span); 1371cb0ef41Sopenharmony_ci return container; 1381cb0ef41Sopenharmony_ci } 1391cb0ef41Sopenharmony_ci 1401cb0ef41Sopenharmony_ci function elementForOperand(operand, searchInfo) { 1411cb0ef41Sopenharmony_ci let isVirtual = false; 1421cb0ef41Sopenharmony_ci let className = "parameter tag clickable " + operand.type; 1431cb0ef41Sopenharmony_ci if (operand.text[0] == 'v' && !(operand.tooltip && operand.tooltip.includes("Float"))) { 1441cb0ef41Sopenharmony_ci isVirtual = true; 1451cb0ef41Sopenharmony_ci className += " virtual-reg"; 1461cb0ef41Sopenharmony_ci } 1471cb0ef41Sopenharmony_ci const span = createElement("span", className, operand.text); 1481cb0ef41Sopenharmony_ci if (operand.tooltip) { 1491cb0ef41Sopenharmony_ci span.setAttribute("title", operand.tooltip); 1501cb0ef41Sopenharmony_ci } 1511cb0ef41Sopenharmony_ci return elementForOperandWithSpan(span, operand.text, searchInfo, isVirtual); 1521cb0ef41Sopenharmony_ci } 1531cb0ef41Sopenharmony_ci 1541cb0ef41Sopenharmony_ci function elementForPhiOperand(text, searchInfo) { 1551cb0ef41Sopenharmony_ci const span = createElement("span", "parameter tag clickable virtual-reg", text); 1561cb0ef41Sopenharmony_ci return elementForOperandWithSpan(span, text, searchInfo, true); 1571cb0ef41Sopenharmony_ci } 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ci function elementForInstruction(instruction, searchInfo) { 1601cb0ef41Sopenharmony_ci const instNodeEl = createElement("div", "instruction-node"); 1611cb0ef41Sopenharmony_ci 1621cb0ef41Sopenharmony_ci const instId = createElement("div", "instruction-id", instruction.id); 1631cb0ef41Sopenharmony_ci const offsets = view.sourceResolver.instructionToPcOffsets(instruction.id); 1641cb0ef41Sopenharmony_ci instId.classList.add("clickable"); 1651cb0ef41Sopenharmony_ci view.addHtmlElementForInstructionId(instruction.id, instId); 1661cb0ef41Sopenharmony_ci instId.onclick = mkInstructionLinkHandler(instruction.id); 1671cb0ef41Sopenharmony_ci instId.dataset.instructionId = instruction.id; 1681cb0ef41Sopenharmony_ci if (offsets) { 1691cb0ef41Sopenharmony_ci instId.setAttribute("title", `This instruction generated gap code at pc-offset 0x${offsets.gap.toString(16)}, code at pc-offset 0x${offsets.arch.toString(16)}, condition handling at pc-offset 0x${offsets.condition.toString(16)}.`); 1701cb0ef41Sopenharmony_ci } 1711cb0ef41Sopenharmony_ci instNodeEl.appendChild(instId); 1721cb0ef41Sopenharmony_ci 1731cb0ef41Sopenharmony_ci const instContentsEl = createElement("div", "instruction-contents"); 1741cb0ef41Sopenharmony_ci instNodeEl.appendChild(instContentsEl); 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_ci // Print gap moves. 1771cb0ef41Sopenharmony_ci const gapEl = createElement("div", "gap", "gap"); 1781cb0ef41Sopenharmony_ci let hasGaps = false; 1791cb0ef41Sopenharmony_ci for (const gap of instruction.gaps) { 1801cb0ef41Sopenharmony_ci const moves = createElement("div", "comma-sep-list gap-move"); 1811cb0ef41Sopenharmony_ci for (const move of gap) { 1821cb0ef41Sopenharmony_ci hasGaps = true; 1831cb0ef41Sopenharmony_ci const moveEl = createElement("div", "move"); 1841cb0ef41Sopenharmony_ci const destinationEl = elementForOperand(move[0], searchInfo); 1851cb0ef41Sopenharmony_ci moveEl.appendChild(destinationEl); 1861cb0ef41Sopenharmony_ci const assignEl = createElement("div", "assign", "="); 1871cb0ef41Sopenharmony_ci moveEl.appendChild(assignEl); 1881cb0ef41Sopenharmony_ci const sourceEl = elementForOperand(move[1], searchInfo); 1891cb0ef41Sopenharmony_ci moveEl.appendChild(sourceEl); 1901cb0ef41Sopenharmony_ci moves.appendChild(moveEl); 1911cb0ef41Sopenharmony_ci } 1921cb0ef41Sopenharmony_ci gapEl.appendChild(moves); 1931cb0ef41Sopenharmony_ci } 1941cb0ef41Sopenharmony_ci if (hasGaps) { 1951cb0ef41Sopenharmony_ci instContentsEl.appendChild(gapEl); 1961cb0ef41Sopenharmony_ci } 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci const instEl = createElement("div", "instruction"); 1991cb0ef41Sopenharmony_ci instContentsEl.appendChild(instEl); 2001cb0ef41Sopenharmony_ci 2011cb0ef41Sopenharmony_ci if (instruction.outputs.length > 0) { 2021cb0ef41Sopenharmony_ci const outputs = createElement("div", "comma-sep-list input-output-list"); 2031cb0ef41Sopenharmony_ci for (const output of instruction.outputs) { 2041cb0ef41Sopenharmony_ci const outputEl = elementForOperand(output, searchInfo); 2051cb0ef41Sopenharmony_ci outputs.appendChild(outputEl); 2061cb0ef41Sopenharmony_ci } 2071cb0ef41Sopenharmony_ci instEl.appendChild(outputs); 2081cb0ef41Sopenharmony_ci const assignEl = createElement("div", "assign", "="); 2091cb0ef41Sopenharmony_ci instEl.appendChild(assignEl); 2101cb0ef41Sopenharmony_ci } 2111cb0ef41Sopenharmony_ci 2121cb0ef41Sopenharmony_ci const text = instruction.opcode + instruction.flags; 2131cb0ef41Sopenharmony_ci const instLabel = createElement("div", "node-label", text); 2141cb0ef41Sopenharmony_ci if (instruction.opcode == "ArchNop" && instruction.outputs.length == 1 && instruction.outputs[0].tooltip) { 2151cb0ef41Sopenharmony_ci instLabel.innerText = instruction.outputs[0].tooltip; 2161cb0ef41Sopenharmony_ci } 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_ci searchInfo.push(text); 2191cb0ef41Sopenharmony_ci view.addHtmlElementForNodeId(text, instLabel); 2201cb0ef41Sopenharmony_ci instEl.appendChild(instLabel); 2211cb0ef41Sopenharmony_ci 2221cb0ef41Sopenharmony_ci if (instruction.inputs.length > 0) { 2231cb0ef41Sopenharmony_ci const inputs = createElement("div", "comma-sep-list input-output-list"); 2241cb0ef41Sopenharmony_ci for (const input of instruction.inputs) { 2251cb0ef41Sopenharmony_ci const inputEl = elementForOperand(input, searchInfo); 2261cb0ef41Sopenharmony_ci inputs.appendChild(inputEl); 2271cb0ef41Sopenharmony_ci } 2281cb0ef41Sopenharmony_ci instEl.appendChild(inputs); 2291cb0ef41Sopenharmony_ci } 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ci if (instruction.temps.length > 0) { 2321cb0ef41Sopenharmony_ci const temps = createElement("div", "comma-sep-list input-output-list temps"); 2331cb0ef41Sopenharmony_ci for (const temp of instruction.temps) { 2341cb0ef41Sopenharmony_ci const tempEl = elementForOperand(temp, searchInfo); 2351cb0ef41Sopenharmony_ci temps.appendChild(tempEl); 2361cb0ef41Sopenharmony_ci } 2371cb0ef41Sopenharmony_ci instEl.appendChild(temps); 2381cb0ef41Sopenharmony_ci } 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_ci return instNodeEl; 2411cb0ef41Sopenharmony_ci } 2421cb0ef41Sopenharmony_ci 2431cb0ef41Sopenharmony_ci const sequenceBlock = createElement("div", "schedule-block"); 2441cb0ef41Sopenharmony_ci sequenceBlock.classList.toggle("deferred", block.deferred); 2451cb0ef41Sopenharmony_ci 2461cb0ef41Sopenharmony_ci const blockId = createElement("div", "block-id com clickable", block.id); 2471cb0ef41Sopenharmony_ci blockId.onclick = mkBlockLinkHandler(block.id); 2481cb0ef41Sopenharmony_ci sequenceBlock.appendChild(blockId); 2491cb0ef41Sopenharmony_ci const blockPred = createElement("div", "predecessor-list block-list comma-sep-list"); 2501cb0ef41Sopenharmony_ci for (const pred of block.predecessors) { 2511cb0ef41Sopenharmony_ci const predEl = createElement("div", "block-id com clickable", pred); 2521cb0ef41Sopenharmony_ci predEl.onclick = mkBlockLinkHandler(pred); 2531cb0ef41Sopenharmony_ci blockPred.appendChild(predEl); 2541cb0ef41Sopenharmony_ci } 2551cb0ef41Sopenharmony_ci if (block.predecessors.length > 0) sequenceBlock.appendChild(blockPred); 2561cb0ef41Sopenharmony_ci const phis = createElement("div", "phis"); 2571cb0ef41Sopenharmony_ci sequenceBlock.appendChild(phis); 2581cb0ef41Sopenharmony_ci 2591cb0ef41Sopenharmony_ci const phiLabel = createElement("div", "phi-label", "phi:"); 2601cb0ef41Sopenharmony_ci phis.appendChild(phiLabel); 2611cb0ef41Sopenharmony_ci 2621cb0ef41Sopenharmony_ci const phiContents = createElement("div", "phi-contents"); 2631cb0ef41Sopenharmony_ci phis.appendChild(phiContents); 2641cb0ef41Sopenharmony_ci 2651cb0ef41Sopenharmony_ci for (const phi of block.phis) { 2661cb0ef41Sopenharmony_ci const phiEl = createElement("div", "phi"); 2671cb0ef41Sopenharmony_ci phiContents.appendChild(phiEl); 2681cb0ef41Sopenharmony_ci 2691cb0ef41Sopenharmony_ci const outputEl = elementForOperand(phi.output, this.searchInfo); 2701cb0ef41Sopenharmony_ci phiEl.appendChild(outputEl); 2711cb0ef41Sopenharmony_ci 2721cb0ef41Sopenharmony_ci const assignEl = createElement("div", "assign", "="); 2731cb0ef41Sopenharmony_ci phiEl.appendChild(assignEl); 2741cb0ef41Sopenharmony_ci 2751cb0ef41Sopenharmony_ci for (const input of phi.operands) { 2761cb0ef41Sopenharmony_ci const inputEl = elementForPhiOperand(input, this.searchInfo); 2771cb0ef41Sopenharmony_ci phiEl.appendChild(inputEl); 2781cb0ef41Sopenharmony_ci } 2791cb0ef41Sopenharmony_ci } 2801cb0ef41Sopenharmony_ci 2811cb0ef41Sopenharmony_ci const instructions = createElement("div", "instructions"); 2821cb0ef41Sopenharmony_ci for (const instruction of block.instructions) { 2831cb0ef41Sopenharmony_ci instructions.appendChild(elementForInstruction(instruction, this.searchInfo)); 2841cb0ef41Sopenharmony_ci } 2851cb0ef41Sopenharmony_ci sequenceBlock.appendChild(instructions); 2861cb0ef41Sopenharmony_ci const blockSucc = createElement("div", "successor-list block-list comma-sep-list"); 2871cb0ef41Sopenharmony_ci for (const succ of block.successors) { 2881cb0ef41Sopenharmony_ci const succEl = createElement("div", "block-id com clickable", succ); 2891cb0ef41Sopenharmony_ci succEl.onclick = mkBlockLinkHandler(succ); 2901cb0ef41Sopenharmony_ci blockSucc.appendChild(succEl); 2911cb0ef41Sopenharmony_ci } 2921cb0ef41Sopenharmony_ci if (block.successors.length > 0) sequenceBlock.appendChild(blockSucc); 2931cb0ef41Sopenharmony_ci this.addHtmlElementForBlockId(block.id, sequenceBlock); 2941cb0ef41Sopenharmony_ci return sequenceBlock; 2951cb0ef41Sopenharmony_ci } 2961cb0ef41Sopenharmony_ci 2971cb0ef41Sopenharmony_ci addBlocks(blocks) { 2981cb0ef41Sopenharmony_ci for (const block of blocks) { 2991cb0ef41Sopenharmony_ci const blockEl = this.elementForBlock(block); 3001cb0ef41Sopenharmony_ci this.divNode.appendChild(blockEl); 3011cb0ef41Sopenharmony_ci } 3021cb0ef41Sopenharmony_ci } 3031cb0ef41Sopenharmony_ci 3041cb0ef41Sopenharmony_ci addRangeView() { 3051cb0ef41Sopenharmony_ci const preventRangeView = reason => { 3061cb0ef41Sopenharmony_ci const toggleRangesInput = this.toggleRangeViewEl.firstChild as HTMLInputElement; 3071cb0ef41Sopenharmony_ci if (this.rangeView) { 3081cb0ef41Sopenharmony_ci toggleRangesInput.checked = false; 3091cb0ef41Sopenharmony_ci this.toggleRangeView(toggleRangesInput); 3101cb0ef41Sopenharmony_ci } 3111cb0ef41Sopenharmony_ci toggleRangesInput.disabled = true; 3121cb0ef41Sopenharmony_ci this.toggleRangeViewEl.style.textDecoration = "line-through"; 3131cb0ef41Sopenharmony_ci this.toggleRangeViewEl.setAttribute("title", reason); 3141cb0ef41Sopenharmony_ci }; 3151cb0ef41Sopenharmony_ci 3161cb0ef41Sopenharmony_ci if (this.sequence.register_allocation) { 3171cb0ef41Sopenharmony_ci if (!this.rangeView) { 3181cb0ef41Sopenharmony_ci this.rangeView = new RangeView(this); 3191cb0ef41Sopenharmony_ci } 3201cb0ef41Sopenharmony_ci const source = this.sequence.register_allocation; 3211cb0ef41Sopenharmony_ci if (source.fixedLiveRanges.size == 0 && source.liveRanges.size == 0) { 3221cb0ef41Sopenharmony_ci preventRangeView("No live ranges to show"); 3231cb0ef41Sopenharmony_ci } else if (this.numInstructions >= 249) { 3241cb0ef41Sopenharmony_ci // This is due to the css grid-column being limited to 1000 columns. 3251cb0ef41Sopenharmony_ci // Performance issues would otherwise impose some limit. 3261cb0ef41Sopenharmony_ci // TODO(george.wort@arm.com): Allow the user to specify an instruction range 3271cb0ef41Sopenharmony_ci // to display that spans less than 249 instructions. 3281cb0ef41Sopenharmony_ci preventRangeView( 3291cb0ef41Sopenharmony_ci "Live range display is only supported for sequences with less than 249 instructions"); 3301cb0ef41Sopenharmony_ci } 3311cb0ef41Sopenharmony_ci if (this.showRangeView) { 3321cb0ef41Sopenharmony_ci this.rangeView.initializeContent(this.sequence.blocks); 3331cb0ef41Sopenharmony_ci } 3341cb0ef41Sopenharmony_ci } else { 3351cb0ef41Sopenharmony_ci preventRangeView("No live range data provided"); 3361cb0ef41Sopenharmony_ci } 3371cb0ef41Sopenharmony_ci } 3381cb0ef41Sopenharmony_ci 3391cb0ef41Sopenharmony_ci elementForToggleRangeView() { 3401cb0ef41Sopenharmony_ci const toggleRangeViewEl = createElement("label", "", "show live ranges"); 3411cb0ef41Sopenharmony_ci const toggleRangesInput = createElement("input", "range-toggle-show") as HTMLInputElement; 3421cb0ef41Sopenharmony_ci toggleRangesInput.setAttribute("type", "checkbox"); 3431cb0ef41Sopenharmony_ci toggleRangesInput.oninput = () => this.toggleRangeView(toggleRangesInput); 3441cb0ef41Sopenharmony_ci toggleRangeViewEl.insertBefore(toggleRangesInput, toggleRangeViewEl.firstChild); 3451cb0ef41Sopenharmony_ci return toggleRangeViewEl; 3461cb0ef41Sopenharmony_ci } 3471cb0ef41Sopenharmony_ci 3481cb0ef41Sopenharmony_ci toggleRangeView(toggleRangesInput: HTMLInputElement) { 3491cb0ef41Sopenharmony_ci toggleRangesInput.disabled = true; 3501cb0ef41Sopenharmony_ci this.showRangeView = toggleRangesInput.checked; 3511cb0ef41Sopenharmony_ci if (this.showRangeView) { 3521cb0ef41Sopenharmony_ci this.rangeView.initializeContent(this.sequence.blocks); 3531cb0ef41Sopenharmony_ci this.rangeView.show(); 3541cb0ef41Sopenharmony_ci } else { 3551cb0ef41Sopenharmony_ci this.rangeView.hide(); 3561cb0ef41Sopenharmony_ci } 3571cb0ef41Sopenharmony_ci window.dispatchEvent(new Event('resize')); 3581cb0ef41Sopenharmony_ci toggleRangesInput.disabled = false; 3591cb0ef41Sopenharmony_ci } 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_ci searchInputAction(searchBar, e) { 3621cb0ef41Sopenharmony_ci e.stopPropagation(); 3631cb0ef41Sopenharmony_ci this.selectionHandler.clear(); 3641cb0ef41Sopenharmony_ci const query = searchBar.value; 3651cb0ef41Sopenharmony_ci if (query.length == 0) return; 3661cb0ef41Sopenharmony_ci const select = []; 3671cb0ef41Sopenharmony_ci window.sessionStorage.setItem("lastSearch", query); 3681cb0ef41Sopenharmony_ci const reg = new RegExp(query); 3691cb0ef41Sopenharmony_ci for (const item of this.searchInfo) { 3701cb0ef41Sopenharmony_ci if (reg.exec(item) != null) { 3711cb0ef41Sopenharmony_ci select.push(item); 3721cb0ef41Sopenharmony_ci } 3731cb0ef41Sopenharmony_ci } 3741cb0ef41Sopenharmony_ci this.selectionHandler.select(select, true); 3751cb0ef41Sopenharmony_ci } 3761cb0ef41Sopenharmony_ci} 377