Search code examples
javascriptassemblyv8

when using V8 JS engine's --always-sparkplug flag and --print-code together to print out what machine code is executed by V8?


I'm using when using V8 JS engine's --always-sparkplug flag and --print-code together to print out the machine code generated by Sparkplug, I was wondering if the machine code printed by --print-code is exactly the executed machine code by V8.

If it is, can I execute the machine code outside of V8, say I can translate the machine code to llvm ir and then executed it in a llvm ir interpreter.


Solution

  • I was wondering if the machine code printed by --print-code is exactly the executed machine code by V8.

    Yes, at least for a while: the --always-sparkplug flag doesn't prevent tiering up to optimized compilation later.

    can I execute the machine code outside of V8, say I can translate the machine code to llvm ir and then executed it in a llvm ir interpreter.

    No, that's not supported: the code heavily relies on being executed in a V8 environment. (Which you'll find out quickly if you try to run it elsewhere.)

    V8 isn't, and doesn't try to be, a standalone compiler.