There are four main stages that code inside V8 passes through :
- JavaScript Code - this is what you wrote
- Hydrogen - intermediate code representation where optimizations are applied
- Lithium - machine specific code used to generate native code
- Machine Code - this is what the computer understands
- Awesome Medium article about it (the quote above is from it)
- jsvu : README is well documented
- Learn about v8 ByteCode (picture related)
- Follow the Medium article
- Instead of manually compile the engine, use
jsvu
- Do NOT select "QuickJS" engine, it's integration is currently broken (7 January 2020)
- I only selected v8-debug (non-debug version doesn't seem to support
--print-bytecode
and some fun stuff like this) - Assuming you dutifully followed the
jsvu
README, you've updated your $PATH already. Now you can just: v8-debug --print-bytecode myFile.js
- It will display in standard output (console): from there you can cat (concatenate) into a file or whatever
- Gist (may be outdated)
- $
v8-debug --help
(won't be outdated)
- User-friendly way to display the aforementioned steps (some frontend)