Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dump v8 JIT output from node

Can node.js (or some other v8 interface or wrapper around v8) output the generated assembly from the v8 JIT?

I'd like to see what the generated assembly looks like for various snippets.

like image 765
slipheed Avatar asked Jun 08 '12 17:06

slipheed


1 Answers

You need to ensure that node.js is built with V8 disassembler enabled. Debug builds will have it enabled by default. For release builds (in recent enough node that uses GYP build) you can enable it by doing:

GYP_DEFINES="v8_enable_disassembler=1 v8_object_print=1" ./configure

and rebuilding node.

When disassembler is enabled you can use flags like --print-code, --print-code-stubs, --print-opt-code and --code-comments to check out the code generated by V8.

If you would like to investigate IR used by optimizing compiler use --trace-hydrogen and look at hydrogen.cfg (it can be viewed with C1 Visualizer).

like image 120
Vyacheslav Egorov Avatar answered Sep 20 '22 21:09

Vyacheslav Egorov