v8/tools/turbolizer
Sigurd Schneider 753ff7f3ba [turbolizer] Rework keydown event handling
This CL simplifies the keydown handling code and fixes
several issues:

 - Input to the search box was not reliably working, because
   the SVG keydown handler was attached to the window and its
   repeat-key detection was supressing key events.
 - Selecting the input of a node via keys 1-9 did not select the
   input, but always enabled the corresponding input node.
   1-9 now select the input node, and CTRL+1 through CTRL+9 can
   be used to toggle the input edge.

Bug: v8:7327
Notry: true
Change-Id: Ifedc8b703f6552e101ad00fee2f3c50f29b325b5
Reviewed-on: https://chromium-review.googlesource.com/c/1397666
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58579}
2019-01-07 12:07:28 +00:00
..
src [turbolizer] Rework keydown event handling 2019-01-07 12:07:28 +00:00
test [turbolizer] Add test suite 2018-10-11 13:29:23 +00:00
deploy.sh [turbolizer] Make deploy script nicer 2018-11-06 17:46:58 +00:00
expand-all.jpg
hide-selected.png
hide-unselected.png
index.html [tools] Clean up HTML for tools 2019-01-06 14:20:33 +00:00
layout-icon.png
left-arrow.png
live.png [turbolizer] Visualize also the dead nodes. 2016-08-09 16:20:32 +00:00
OWNERS
package-lock.json [turbolizer] Version bumps for dependencies 2019-01-04 14:17:04 +00:00
package.json [turbolizer] Version bumps for dependencies 2019-01-04 14:17:04 +00:00
README.md [turbolizer] Add comment about deployment 2018-11-22 13:16:09 +00:00
right-arrow.png
rollup.config.js [turbolizer] Version bumps for dependencies 2019-01-04 14:17:04 +00:00
search2.png
search.png
tabs.css [turbolizer] Add tabs to left and right pane 2018-11-08 14:00:01 +00:00
tsconfig.json [turbolizer] Move Resizer to its own file 2019-01-07 11:58:51 +00:00
tsconfig.test.json [turbolizer] Add test suite 2018-10-11 13:29:23 +00:00
tsfmt.json [turbolizer] Display instruction ranges in turbolizer 2018-06-13 18:06:32 +00:00
turbo-visualizer.css [turbolizer] Remember pane width in session storage 2019-01-07 11:51:42 +00:00
turbolizer.png [turbolizer] Add support for inlined functions 2018-05-16 13:43:14 +00:00
types.png
upload-icon.png

Turbolizer

Turbolizer is a HTML-based tool that visualizes optimized code along the various phases of Turbofan's optimization pipeline, allowing easy navigation between source code, Turbofan IR graphs, scheduled IR nodes and generated assembly code.

Turbolizer consumes .json files that are generated per-function by d8 by passing the '--trace-turbo' command-line flag.

Turbolizer is build using npm:

cd tools/turbolizer
npm i
npm run-script build

Afterwards, turbolizer can be hosted locally by starting a web server that serve the contents of the turbolizer directory, e.g.:

python -m SimpleHTTPServer 8000

To deploy to a directory that can be hosted the script deploy can be used. The following command will deploy to the directory /www/turbolizer:

npm run deploy -- /www/turbolizer

Optionally, profiling data generated by the perf tools in linux can be merged with the .json files using the turbolizer-perf.py file included. The following command is an example of using the perf script:

perf script -i perf.data.jitted -s turbolizer-perf.py turbo-main.json

The output of the above command is a json object that can be piped to a file which, when uploaded to turbolizer, will display the event counts from perf next to each instruction in the disassembly. Further detail can be found in the bottom of this document under "Using Perf with Turbo."

Using the python interface in perf script requires python-dev to be installed and perf be recompiled with python support enabled. Once recompiled, the variable PERF_EXEC_PATH must be set to the location of the recompiled perf binaries.

Graph visualization and manipulation based on Mike Bostock's sample code for an interactive tool for creating directed graphs. Original source is at https://github.com/metacademy/directed-graph-creator and released under the MIT/X license.

Icons derived from the "White Olive Collection" created by Breezi released under the Creative Commons BY license.

Using Perf with Turbo

In order to generate perf data that matches exactly with the turbofan trace, you must use either a debug build of v8 or a release build with the flag 'disassembler=on'. This flag ensures that the '--trace-turbo' will output the necessary disassembly for linking with the perf profile.

The basic example of generating the required data is as follows:

perf record -k mono /path/to/d8 --trace-turbo --perf-prof main.js
perf inject -j -i perf.data -o perf.data.jitted
perf script -i perf.data.jitted -s turbolizer-perf.py turbo-main.json

These commands combined will run and profile d8, merge the output into a single 'perf.data.jitted' file, then take the event data from that and link them to the disassembly in the 'turbo-main.json'. Note that, as above, the output of the script command must be piped to a file for uploading to turbolizer.

There are many options that can be added to the first command, for example '-e' can be used to specify the counting of specific events (default: cycles), as well as '--cpu' to specify which CPU to sample.

Turbolizer build process

Turbolizer is currently migrating to TypeScript. The typescript sources reside in tools/turbolizer/src, and the typescript compiler will put the JavaScript output into tools/turbolizer/build/. The index.html file is set up to load the JavaScript from that directory.