Skip to content
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

Add instructions for viewing asm with v8 #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gautam1168
Copy link
Contributor

No description provided.

@mmozeiko
Copy link

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.

@gautam1168
Copy link
Contributor Author

gautam1168 commented Apr 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants