V8 不会打印出反汇编 [英] V8 will not print out disassembly

查看:39
本文介绍了V8 不会打印出反汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用反汇编选项编译了 v8:

I compiled v8 with the disassembler option:

tools/dev/v8gen.py x64.debug -- v8_enable_disassembler=true  v8_enable_object_print=true
ninja -C out.gn/x64.debug

但是,当我尝试打印反汇编时,d8 不输出任何内容(也没有错误消息):

However, when I attempt to print out the disassembly, d8 does not output anything (no error messages either):

./d8 --print-code test.js

test.js 包含以下内容:

test.js contains the following:

function add(a, b){
  return a + b;
}

推荐答案

V8 会延迟编译函数(即第一次调用时),所以当你的文件只包含 function add(...) {...},这是您看不到任何输出的原因之一.尝试添加呼叫,例如add(1, 1).

V8 compiles functions lazily (i.e. when they are first called), so when your file only contains function add(...) {...}, that is one reason why you're not seeing any output. Try adding a call, e.g. add(1, 1).

此外,最新版本的 V8 使用字节码解释器而不是立即生成机器码.您可以使用 --print-bytecode 打印字节码.

Also, recent versions of V8 use a bytecode interpreter instead of generating machine code right away. You can print the bytecode using --print-bytecode.

机器代码仅在函数热"时由优化编译器生成(对于像 add 这样的小函数在您的测试中,这意味着调用它几千次);--print-opt-code 打印优化后的机器码.

Machine code is only generated by the optimizing compiler once a function is "hot" (for a small function like add in your test, that means calling it a few thousand times); --print-opt-code prints the optimized machine code.

(旁注:在 V8 的调试版本中,反汇编器支持始终处于启用状态,因此您不需要任何自定义标志.)

(Side note: In Debug builds of V8, disassembler support is always enabled, so you don't need any custom flags.)

这篇关于V8 不会打印出反汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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