如何将Javascript代码转换为人类可读的操作码或asm? [英] How to convert Javascript code to human-readable opcodes or asm?

查看:203
本文介绍了如何将Javascript代码转换为人类可读的操作码或asm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,Javascript代码可以生成JS bytecodeasm指令(如果内部JIT编译器能够将代码直接转换为机器指令).

As far as I know, Javascript code can either result in JS bytecode or asm instructions (if the internal JIT-compiler was able to convert the code directly to machine instructions).

有什么方法可以将Javascript代码转换为人类可读的JS字节代码(或asm指令)-取决于V8引擎如何对其进行转换?

Is there any way to convert Javascript code to human-readable JS byte code (or asm instructions) - depending on how the V8 engine converts it?

推荐答案

您可以在--print-bytecode --print-opt-code上运行d8或节点,以在生成字节码和优化的汇编代码时将其输出到stdout.如果仅对功能foo感兴趣,可以使用--print-bytecode-filter=foo--print-opt-code-filter=foo.您将需要一个调试版本,或者是一个在其args.gn中带有v8_enable_disassembler = true的发行版本(常规发行版本不包含反汇编程序代码以节省二进制大小).当某个功能热"(即花了一些时间运行)时,将生成优化的代码.

You can run d8 or node with --print-bytecode --print-opt-code to print both bytecode and optimized assembly code to stdout when it is generated. You can use --print-bytecode-filter=foo and --print-opt-code-filter=foo if you're only interested in function foo. You will need a debug build, or a release build with v8_enable_disassembler = true in its args.gn (regular release builds don't include the disassembler code in order to save binary size). Optimized code will be generated when a function is "hot", i.e. has spent some time running.

这篇关于如何将Javascript代码转换为人类可读的操作码或asm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆