Skip to content

Commit 00a4556

Browse files
lpereirafitzgen
authored andcommitted
Rebase, fix conflicts, and remove the bridge because it doesn't support the CLIF view
Auto-format explorer index.js Use CRC24 to pick colors for offsets in explore Make better use of the DOM In the ASM view, instead of creating one element per instruction, create one per WASM chunk. This significantly reduces the amount of elements we have to take care of, including event listeners. For both views, get rid of all the maps to look up DOM elements by WASM offset and use CSS selectors to find them. This made things quite a bit smoother. To highlight items, we now add a class to elements with the same WASM offset, and remove it when we don't want to highlight them anymore. In addition to this, use a bit more tricks to get brighter colors from the CRC24 algorithm we're now using to pick the colors. (Since the colors can now be very dark, we get the luminance by using the NTSC color space, or YIQ, and use contrasting colors.) Draw polygon bridging WAT and ASM views Scale luma calculation to a power of two to avoid integer division Outline hovered lines Instead of using opacity, which slow down rendering, use a solid outline, which looks nicer and is more efficient! Adjust bridge width to account for different scrollbar widths Use simpler math in rgbToLuma() to avoid multiplications too Slight improvement to crc24 calculation Draw multiple conections from WAT to ASM views Sometimes the ASM block contains disjoint sets of instructions that relate to one WASM instruction, so link all of them at the same time. Show WASM offset on hover in the ASM view Fix grouping of ASM instructions Some instructions with NULL wasm_offset were being group together with the first instruction in the stream that had an offset. Only set the title attribute to show WASM offset on hover This saves quite a bit of memory! Fix grouping of instructions in ASM mode Add note about the origin of the CRC-24 calculation Tweak color generation (let some brighter colors pass the filter) Ensure we have enough elements to compute the bridge polygon I don't know why this happens, but sometimes, a block of instructions in the ASM side, that have a WASM offset in the generated JSON, won't have an equivalent in the WAT side. Guard against this. Don't obscure the hovered line with the outline Simplify bridge width calculation Optimize hovering of blocks when one 1 WAT element matches with 1 ASM element Address review comments Make eslint happy Since this code runs in a browser, we need to tell eslint that it's going to run in a browser enviroment so things like `window` and `document` are defined. Signed-off-by: L. Pereira <l.pereira@fastly.com>
1 parent 84477fc commit 00a4556

File tree

5 files changed

+233
-219
lines changed

5 files changed

+233
-219
lines changed

crates/explorer/eslint.config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import js from "@eslint/js";
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
23

34
export default [
4-
js.configs.recommended,
5-
65
{
6+
files: ["**/*.js"],
7+
languageOptions: {
8+
sourceType: "module",
9+
globals: globals.browser,
10+
},
711
rules: {
812
"no-unused-vars": "error",
913
"no-undef": "error",
1014
},
1115
},
16+
pluginJs.configs.recommended,
1217
];

crates/explorer/package-lock.json

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/explorer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"@eslint/js": "^9.3.0",
2424
"eslint": "^9.3.0",
25+
"globals": "^15.3.0",
2526
"prettier": "3.2.5"
2627
},
2728
"type": "module"

crates/explorer/src/index.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ body {
1414
height: 100%;
1515
}
1616

17+
.highlight {
18+
white-space: pre;
19+
font-family: monospace;
20+
}
21+
.hovered {
22+
}
23+
.light-text {
24+
color: #eeeeee;
25+
}
26+
.dark-text {
27+
color: #101010;
28+
}
29+
1730
#wat {
1831
flex: 1;
1932
height: 100%;

0 commit comments

Comments
 (0)