-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miscellaneous Explore tool improvements #8649
base: main
Are you sure you want to change the base?
Conversation
dabb932
to
94ef8b5
Compare
(Will hold off on looking at this until #8639 merges) |
280884e
to
6fe57dc
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good, just a few comments below.
crates/explorer/src/index.js
Outdated
const existingHueForOffset = offset => { | ||
return offsetToHue.get(offset); | ||
}; | ||
const state = (window.STATE = new State(window.WAT, window.ASM)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you avoid stylistic changes? Or configure your editor to avoid them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent a PR to add formatting/linting for this JS, so that we don't have to nitpick about it anymore in PRs: #8675
crates/explorer/src/index.js
Outdated
anyByOffset.set(offset, []); | ||
} | ||
anyByOffset.get(offset).push(elem); | ||
const rgbToLuma = (rgb) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar about matching existing code style: none of the rest of the code is adding parens to single-arg arrow functions.
crates/explorer/src/index.js
Outdated
const eachElementWithSameWasmOff = (event, closure) => { | ||
let offset = event.target.dataset.wasmOffset; | ||
if (offset !== null) { | ||
for (const elem of selector(offset)) closure(elem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Walking the DOM every time seems more expensive than the old approach of maintaining a map from offset to list of elements associated with that offset. I'd prefer sticking with the previous approach unless there is strong motivation to do otherwise.
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.)
Instead of using opacity, which slow down rendering, use a solid outline, which looks nicer and is more efficient!
Sometimes the ASM block contains disjoint sets of instructions that relate to one WASM instruction, so link all of them at the same time.
Some instructions with NULL wasm_offset were being group together with the first instruction in the stream that had an offset.
This saves quite a bit of memory!
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.
6fe57dc
to
2aaa7b4
Compare
Rebased (to get your patch with |
31cfc61
to
055ef03
Compare
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>
055ef03
to
0c9ee7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding all the comments, that helps a bunch!
.hovered { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this?
@fitzgen Could you please merge this? (It's unlikely I'll continue working on this as this was done as part of a job, but I don't want this to bitrot.) |
I had some time last night, so I decided to clean up the explore tool frontend code. This is almost a full rewrite, that:
This is just a draft for now, because there are still a couple of bugs I have to fix, but I'm happy with how this is turning out, and I'd like some feedback. (This builds on #8639.)