computer_enhance icon indicating copy to clipboard operation
computer_enhance copied to clipboard

Add instructions for viewing asm with v8

Open gautam1168 opened this issue 3 years ago • 2 comments

gautam1168 avatar Apr 23 '23 09:04 gautam1168

If you don't care about byte code then there's simpler way - just run node --print-opt-code test.js >output.txt and it will produce x64 asm in plain text file. No websites needed to view it.

Text file for this square function will contain these lines:

00007FF5DC94E91F    5f  c5fb104107           vmovsd xmm0,[rcx+0x7]
00007FF5DC94E924    64  c5fb59c0             vmulsd xmm0,xmm0,xmm0

address, offset, x64 instruction bytes, and text x64 assembly.

mmozeiko avatar Apr 23 '23 18:04 mmozeiko

Yes this is how I have added it to compiler explorer. But that output really isn't very friendly when I want to understand what is going on. The turbolizer output is much more understandable at my current level. The way I read that is,

  1. Look at the blocks marked in the bytecode as (B1, B2, etc)
  2. Look for those same blocks in the assembly code

Its much easier to spot which line of javascript generated which bytecodes than to spot which lines of js generated which lines of asm directly. I don't fully understand the blocks yet, but they have something to do with the sea of nodes method v8 uses to compile the bytecode to asm. I can't say I really get the things that go on in there, but I am trying. And Im hoping that by the end of this course I will have a much better understanding of how exactly v8 compiles/optimizes the bytecode.

gautam1168 avatar Apr 23 '23 23:04 gautam1168