diff options
Diffstat (limited to 'deps/v8/tools/turbolizer/src/sequence-view.ts')
-rw-r--r-- | deps/v8/tools/turbolizer/src/sequence-view.ts | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/deps/v8/tools/turbolizer/src/sequence-view.ts b/deps/v8/tools/turbolizer/src/sequence-view.ts index afddb56649..a796707c74 100644 --- a/deps/v8/tools/turbolizer/src/sequence-view.ts +++ b/deps/v8/tools/turbolizer/src/sequence-view.ts @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {Sequence} from "./source-resolver.js" -import {isIterable} from "./util.js" -import {PhaseView} from "./view.js" -import {TextView} from "./text-view.js" +import { Sequence } from "../src/source-resolver"; +import { isIterable } from "../src/util"; +import { TextView } from "../src/text-view"; -export class SequenceView extends TextView implements PhaseView { +export class SequenceView extends TextView { sequence: Sequence; - search_info: Array<any>; + searchInfo: Array<any>; createViewElement() { const pane = document.createElement('div'); @@ -18,7 +17,7 @@ export class SequenceView extends TextView implements PhaseView { } constructor(parentId, broker) { - super(parentId, broker, null); + super(parentId, broker); } attachSelection(s) { @@ -39,9 +38,17 @@ export class SequenceView extends TextView implements PhaseView { initializeContent(data, rememberedSelection) { this.divNode.innerHTML = ''; this.sequence = data.sequence; - this.search_info = []; + this.searchInfo = []; + this.divNode.addEventListener('click', (e: MouseEvent) => { + if (!(e.target instanceof HTMLElement)) return; + const instructionId = Number.parseInt(e.target.dataset.instructionId, 10); + if (!instructionId) return; + if (!e.shiftKey) this.broker.broadcastClear(null); + this.broker.broadcastInstructionSelect(null, [instructionId], true); + }); this.addBlocks(this.sequence.blocks); this.attachSelection(rememberedSelection); + this.show(); } elementForBlock(block) { @@ -75,23 +82,25 @@ export class SequenceView extends TextView implements PhaseView { return mkLinkHandler(text, view.selectionHandler); } - function elementForOperand(operand, search_info) { - var text = operand.text; + function elementForOperand(operand, searchInfo) { + const text = operand.text; const operandEl = createElement("div", ["parameter", "tag", "clickable", operand.type], text); if (operand.tooltip) { operandEl.setAttribute("title", operand.tooltip); } operandEl.onclick = mkOperandLinkHandler(text); - search_info.push(text); + searchInfo.push(text); view.addHtmlElementForNodeId(text, operandEl); return operandEl; } - function elementForInstruction(instruction, search_info) { + function elementForInstruction(instruction, searchInfo) { const instNodeEl = createElement("div", "instruction-node"); - const inst_id = createElement("div", "instruction-id", instruction.id); - instNodeEl.appendChild(inst_id); + const instId = createElement("div", "instruction-id", instruction.id); + instId.classList.add("clickable"); + instId.dataset.instructionId = instruction.id; + instNodeEl.appendChild(instId); const instContentsEl = createElement("div", "instruction-contents"); instNodeEl.appendChild(instContentsEl); @@ -103,11 +112,11 @@ export class SequenceView extends TextView implements PhaseView { const moves = createElement("div", ["comma-sep-list", "gap-move"]); for (const move of gap) { const moveEl = createElement("div", "move"); - const destinationEl = elementForOperand(move[0], search_info); + const destinationEl = elementForOperand(move[0], searchInfo); moveEl.appendChild(destinationEl); const assignEl = createElement("div", "assign", "="); moveEl.appendChild(assignEl); - const sourceEl = elementForOperand(move[1], search_info); + const sourceEl = elementForOperand(move[1], searchInfo); moveEl.appendChild(sourceEl); moves.appendChild(moveEl); } @@ -120,7 +129,7 @@ export class SequenceView extends TextView implements PhaseView { if (instruction.outputs.length > 0) { const outputs = createElement("div", ["comma-sep-list", "input-output-list"]); for (const output of instruction.outputs) { - const outputEl = elementForOperand(output, search_info); + const outputEl = elementForOperand(output, searchInfo); outputs.appendChild(outputEl); } instEl.appendChild(outputs); @@ -128,16 +137,16 @@ export class SequenceView extends TextView implements PhaseView { instEl.appendChild(assignEl); } - var text = instruction.opcode + instruction.flags; - const inst_label = createElement("div", "node-label", text); - search_info.push(text); - view.addHtmlElementForNodeId(text, inst_label); - instEl.appendChild(inst_label); + const text = instruction.opcode + instruction.flags; + const instLabel = createElement("div", "node-label", text); + searchInfo.push(text); + view.addHtmlElementForNodeId(text, instLabel); + instEl.appendChild(instLabel); if (instruction.inputs.length > 0) { const inputs = createElement("div", ["comma-sep-list", "input-output-list"]); for (const input of instruction.inputs) { - const inputEl = elementForOperand(input, search_info); + const inputEl = elementForOperand(input, searchInfo); inputs.appendChild(inputEl); } instEl.appendChild(inputs); @@ -146,7 +155,7 @@ export class SequenceView extends TextView implements PhaseView { if (instruction.temps.length > 0) { const temps = createElement("div", ["comma-sep-list", "input-output-list", "temps"]); for (const temp of instruction.temps) { - const tempEl = elementForOperand(temp, search_info); + const tempEl = elementForOperand(temp, searchInfo); temps.appendChild(tempEl); } instEl.appendChild(temps); @@ -155,20 +164,20 @@ export class SequenceView extends TextView implements PhaseView { return instNodeEl; } - const sequence_block = createElement("div", "schedule-block"); + const sequenceBlock = createElement("div", "schedule-block"); - const block_id = createElement("div", ["block-id", "com", "clickable"], block.id); - block_id.onclick = mkBlockLinkHandler(block.id); - sequence_block.appendChild(block_id); - const block_pred = createElement("div", ["predecessor-list", "block-list", "comma-sep-list"]); + const blockId = createElement("div", ["block-id", "com", "clickable"], block.id); + blockId.onclick = mkBlockLinkHandler(block.id); + sequenceBlock.appendChild(blockId); + const blockPred = createElement("div", ["predecessor-list", "block-list", "comma-sep-list"]); for (const pred of block.predecessors) { const predEl = createElement("div", ["block-id", "com", "clickable"], pred); predEl.onclick = mkBlockLinkHandler(pred); - block_pred.appendChild(predEl); + blockPred.appendChild(predEl); } - if (block.predecessors.length > 0) sequence_block.appendChild(block_pred); + if (block.predecessors.length > 0) sequenceBlock.appendChild(blockPred); const phis = createElement("div", "phis"); - sequence_block.appendChild(phis); + sequenceBlock.appendChild(phis); const phiLabel = createElement("div", "phi-label", "phi:"); phis.appendChild(phiLabel); @@ -180,7 +189,7 @@ export class SequenceView extends TextView implements PhaseView { const phiEl = createElement("div", "phi"); phiContents.appendChild(phiEl); - const outputEl = elementForOperand(phi.output, this.search_info); + const outputEl = elementForOperand(phi.output, this.searchInfo); phiEl.appendChild(outputEl); const assignEl = createElement("div", "assign", "="); @@ -194,18 +203,18 @@ export class SequenceView extends TextView implements PhaseView { const instructions = createElement("div", "instructions"); for (const instruction of block.instructions) { - instructions.appendChild(elementForInstruction(instruction, this.search_info)); + instructions.appendChild(elementForInstruction(instruction, this.searchInfo)); } - sequence_block.appendChild(instructions); - const block_succ = createElement("div", ["successor-list", "block-list", "comma-sep-list"]); + sequenceBlock.appendChild(instructions); + const blockSucc = createElement("div", ["successor-list", "block-list", "comma-sep-list"]); for (const succ of block.successors) { const succEl = createElement("div", ["block-id", "com", "clickable"], succ); succEl.onclick = mkBlockLinkHandler(succ); - block_succ.appendChild(succEl); + blockSucc.appendChild(succEl); } - if (block.successors.length > 0) sequence_block.appendChild(block_succ); - this.addHtmlElementForBlockId(block.id, sequence_block); - return sequence_block; + if (block.successors.length > 0) sequenceBlock.appendChild(blockSucc); + this.addHtmlElementForBlockId(block.id, sequenceBlock); + return sequenceBlock; } addBlocks(blocks) { @@ -223,13 +232,11 @@ export class SequenceView extends TextView implements PhaseView { const select = []; window.sessionStorage.setItem("lastSearch", query); const reg = new RegExp(query); - for (const item of this.search_info) { + for (const item of this.searchInfo) { if (reg.exec(item) != null) { select.push(item); } } this.selectionHandler.select(select, true); } - - onresize() { } } |