为什么我从 --trace-opt/--trace-deopt 和 %GetOptimizationStatus V8 的 API 调用中得到不同的结果?

Why do I get differend results from --trace-opt/--trace-deopt and %GetOptimizationStatus V8's API call?

这是v8 --module --trace-opt index.js的输出。可以看到函数优化commonRandom and commonRandomJS完成

...
[completed optimizing 0x2b0e0824a769 <JSFunction commonRandom (sfi = 0x2b0e081d3985)> (target TURBOFAN)]
...
[completed optimizing 0x2b0e0824a789 <JSFunction commonRandomJS (sfi = 0x2b0e081d39b9)> (target TURBOFAN)]
...

这是v8 --module --trace-deopt index.js的输出。您可以看到函数 commonRandom and commonRandomJS 没有取消。

[bailout (kind: deopt-soft, reason: Insufficient type feedback for compare operation): begin. deoptimizing 0x3907082827f9 <JSFunction randomMatrix (sfi = 0x3907081d39ed)>, opt id 0, bytecode offset 167, deopt exit 35, FP to SP delta 208, caller SP 0x7ffee6068410, pc 0x39070004611c]
[bailout (kind: deopt-soft, reason: Insufficient type feedback for compare operation): begin. deoptimizing 0x39070824a839 <JSFunction randomMatrix (sfi = 0x3907081d39ed)>, opt id 2, bytecode offset 249, deopt exit 28, FP to SP delta 208, caller SP 0x7ffee6068410, pc 0x390700047265]
[bailout (kind: deopt-soft, reason: Insufficient type feedback for unary operation): begin. deoptimizing 0x39070824a839 <JSFunction randomMatrix (sfi = 0x3907081d39ed)>, opt id 3, bytecode offset 349, deopt exit 23, FP to SP delta 264, caller SP 0x7ffee6068410, pc 0x390700047d5b]

我已经根据 https://github.com/v8/v8/blob/207f489fc5df0cab30b9cde373181c0242c0874c/src/runtime/runtime.h#L897 %GetOptimizationStatus 当前实现实现了自己的跟踪脚本,并使用了与 --trace-opt/--trace-deopt 标志相同的迭代次数。然而,kTurboFanned 标志是 0,但 kOptimized and kMaglevved 都是 1s。为什么会这样? kTurbofannedkOptimizedkMaglevved 标志是什么意思?

版本: V8 version 9.9.67

V8 一如既往地处于积极开发阶段。要解释 9.9.67 的 %GetOptimizationStatus 输出,请参考 runtime.h 的正确版本:https://github.com/v8/v8/blob/9.9.67/src/runtime/runtime.h.

“Maglev”是一个新的编译器,仍在开发中,介于 Sparkplug 和 Turbofan 之间。版本 9.9.x 还没有。