summaryrefslogtreecommitdiff
path: root/deps/v8/tools/turbolizer/src/disassembly-view.ts
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/tools/turbolizer/src/disassembly-view.ts')
-rw-r--r--deps/v8/tools/turbolizer/src/disassembly-view.ts58
1 files changed, 49 insertions, 9 deletions
diff --git a/deps/v8/tools/turbolizer/src/disassembly-view.ts b/deps/v8/tools/turbolizer/src/disassembly-view.ts
index 4b8fc6ea2d..0455437002 100644
--- a/deps/v8/tools/turbolizer/src/disassembly-view.ts
+++ b/deps/v8/tools/turbolizer/src/disassembly-view.ts
@@ -13,6 +13,7 @@ const toolboxHTML = `<div id="disassembly-toolbox">
<form>
<label><input id="show-instruction-address" type="checkbox" name="instruction-address">Show addresses</label>
<label><input id="show-instruction-binary" type="checkbox" name="instruction-binary">Show binary literal</label>
+ <label><input id="highlight-gap-instructions" type="checkbox" name="instruction-binary">Highlight gap instructions</label>
</form>
</div>`;
@@ -26,13 +27,14 @@ export class DisassemblyView extends TextView {
offsetSelection: MySelection;
showInstructionAddressHandler: () => void;
showInstructionBinaryHandler: () => void;
+ highlightGapInstructionsHandler: () => void;
createViewElement() {
const pane = document.createElement('div');
pane.setAttribute('id', "disassembly");
pane.innerHTML =
`<pre id='disassembly-text-pre' class='prettyprint prettyprinted'>
- <ul id='disassembly-list' class='nolinenums noindent'>
+ <ul class='disassembly-list nolinenums noindent'>
</ul>
</pre>`;
@@ -46,6 +48,19 @@ export class DisassemblyView extends TextView {
associateData: (text, fragment: HTMLElement) => {
const matches = text.match(/(?<address>0?x?[0-9a-fA-F]{8,16})(?<addressSpace>\s+)(?<offset>[0-9a-f]+)(?<offsetSpace>\s*)/);
const offset = Number.parseInt(matches.groups["offset"], 16);
+ const instructionKind = view.sourceResolver.getInstructionKindForPCOffset(offset);
+ fragment.dataset.instructionKind = instructionKind;
+ fragment.title = view.sourceResolver.instructionKindToReadableName(instructionKind);
+ const blockIds = view.sourceResolver.getBlockIdsForOffset(offset);
+ const blockIdElement = document.createElement("SPAN");
+ blockIdElement.className = "block-id com linkable-text";
+ blockIdElement.innerText = "";
+ if (blockIds && blockIds.length > 0) {
+ blockIds.forEach(blockId => view.addHtmlElementForBlockId(blockId, fragment));
+ blockIdElement.innerText = `B${blockIds.join(",")}:`;
+ blockIdElement.dataset.blockId = `${blockIds.join(",")}`;
+ }
+ fragment.appendChild(blockIdElement);
const addressElement = document.createElement("SPAN");
addressElement.className = "instruction-address";
addressElement.innerText = matches.groups["address"];
@@ -58,11 +73,13 @@ export class DisassemblyView extends TextView {
fragment.classList.add('tag');
if (!Number.isNaN(offset)) {
- const pcOffset = view.sourceResolver.getKeyPcOffset(offset);
+ let pcOffset = view.sourceResolver.getKeyPcOffset(offset);
+ if (pcOffset == -1) pcOffset = Number(offset);
fragment.dataset.pcOffset = `${pcOffset}`;
addressElement.classList.add('linkable-text');
offsetElement.classList.add('linkable-text');
}
+ return true;
}
};
const UNCLASSIFIED_STYLE = {
@@ -79,11 +96,20 @@ export class DisassemblyView extends TextView {
fragment.innerHTML = text;
const replacer = (match, hexOffset) => {
const offset = Number.parseInt(hexOffset, 16);
- const keyOffset = view.sourceResolver.getKeyPcOffset(offset);
- return `<span class="tag linkable-text" data-pc-offset="${keyOffset}">${match}</span>`;
+ let keyOffset = view.sourceResolver.getKeyPcOffset(offset);
+ if (keyOffset == -1) keyOffset = Number(offset);
+ const blockIds = view.sourceResolver.getBlockIdsForOffset(offset);
+ let block = "";
+ let blockIdData = "";
+ if (blockIds && blockIds.length > 0) {
+ block = `B${blockIds.join(",")} `;
+ blockIdData = `data-block-id="${blockIds.join(",")}"`;
+ }
+ return `<span class="tag linkable-text" data-pc-offset="${keyOffset}" ${blockIdData}>${block}${match}</span>`;
};
const html = text.replace(/<.0?x?([0-9a-fA-F]+)>/g, replacer);
fragment.innerHTML = html;
+ return true;
}
};
const OPCODE_STYLE = {
@@ -91,12 +117,14 @@ export class DisassemblyView extends TextView {
};
const BLOCK_HEADER_STYLE = {
associateData: function (text, fragment) {
+ if (view.sourceResolver.hasBlockStartInfo()) return false;
const matches = /\d+/.exec(text);
- if (!matches) return;
+ if (!matches) return true;
const blockId = matches[0];
fragment.dataset.blockId = blockId;
fragment.innerHTML = text;
fragment.className = "com block";
+ return true;
}
};
const SOURCE_POSITION_HEADER_STYLE = {
@@ -135,7 +163,7 @@ export class DisassemblyView extends TextView {
const linkHandler = (e: MouseEvent) => {
if (!(e.target instanceof HTMLElement)) return;
- const offsetAsString = e.target.dataset.pcOffset ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset;
+ const offsetAsString = typeof e.target.dataset.pcOffset != "undefined" ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset;
const offset = Number.parseInt(offsetAsString, 10);
if ((typeof offsetAsString) != "undefined" && !Number.isNaN(offset)) {
view.offsetSelection.select([offset], true);
@@ -156,12 +184,12 @@ export class DisassemblyView extends TextView {
const linkHandlerBlock = e => {
const blockId = e.target.dataset.blockId;
- if (typeof blockId != "undefined" && !Number.isNaN(blockId)) {
- e.stopPropagation();
+ if (typeof blockId != "undefined") {
+ const blockIds = blockId.split(",");
if (!e.shiftKey) {
view.selectionHandler.clear();
}
- view.blockSelectionHandler.select([blockId], true);
+ view.blockSelectionHandler.select(blockIds, true);
}
};
view.divNode.addEventListener('click', linkHandlerBlock);
@@ -219,6 +247,17 @@ export class DisassemblyView extends TextView {
};
instructionBinaryInput.addEventListener("change", showInstructionBinaryHandler);
this.showInstructionBinaryHandler = showInstructionBinaryHandler;
+
+ const highlightGapInstructionsInput: HTMLInputElement = view.divNode.querySelector("#highlight-gap-instructions");
+ const lastHighlightGapInstructions = window.sessionStorage.getItem("highlight-gap-instructions");
+ highlightGapInstructionsInput.checked = lastHighlightGapInstructions == 'true';
+ const highlightGapInstructionsHandler = () => {
+ window.sessionStorage.setItem("highlight-gap-instructions", `${highlightGapInstructionsInput.checked}`);
+ view.divNode.classList.toggle("highlight-gap-instructions", highlightGapInstructionsInput.checked);
+ };
+
+ highlightGapInstructionsInput.addEventListener("change", highlightGapInstructionsHandler);
+ this.highlightGapInstructionsHandler = highlightGapInstructionsHandler;
}
updateSelection(scrollIntoView: boolean = false) {
@@ -285,6 +324,7 @@ export class DisassemblyView extends TextView {
super.initializeContent(data, null);
this.showInstructionAddressHandler();
this.showInstructionBinaryHandler();
+ this.highlightGapInstructionsHandler();
console.timeEnd("disassembly-view");
}