nodejs/V8是否将已编译的机器代码存储在磁盘上的任何位置? [英] Does nodejs/V8 store compiled machine code anywhere on disk?
问题描述
编辑:从Node 8.3开始,Node使用字节码,在此之前,源代码直接编译为机器代码.
Edit: Node uses bytecode since Node 8.3, before that, sources were compiled directly to machine code.
我做了很多Python编码,并且.pyc文件中总是存在字节码.
I do a lot of Python coding, and there's always bytecode lying around in .pyc files.
我想知道节点是否将其机器代码存储在相似的文件中,例如,将机器代码表示保留在磁盘上并在文件源未更改的情况下重新使用它是有意义的.
I was wondering if node stores its machine code in similar files, eg it would make sense to keep the machine code representation around on disk and re-use it if a file's source is unchanged.
如果是,那么node/v8将此机器代码存储在哪里?
If so, where does node/v8 store this machine code?
Edit 2: As @dystroy mentions below this is a dupe of How can I see the machine code generated by v8?
推荐答案
V8在2016年推出了字节码解释器Ignition.您可以使用-print-bytecode
(Node 8.3及更高版本)打印字节码.
V8 introduced a bytecode interpreter, Ignition, in 2016.
You can print the bytecode with --print-bytecode
(Node 8.3 and newer).
$ node --print-bytecode incrementX.js -e 'function incrementX(obj) {return 1 + obj.x;} incrementX({x: 42});`
...
[generating bytecode for function: incrementX]
Parameter count 2
Frame size 8
12 E> 0x2ddf8802cf6e @ StackCheck
19 S> 0x2ddf8802cf6f @ LdaSmi [1]
0x2ddf8802cf71 @ Star r0
34 E> 0x2ddf8802cf73 @ LdaNamedProperty a0, [0], [4]
28 E> 0x2ddf8802cf77 @ Add r0, [6]
36 S> 0x2ddf8802cf7a @ Return
Constant pool (size = 1)
0x2ddf8802cf21: [FixedArray] in OldSpace
- map = 0x2ddfb2d02309 <Map(HOLEY_ELEMENTS)>
- length: 1
0: 0x2ddf8db91611 <String[1]: x>
Handler Table (size = 16)
请参见了解V8的字节码.
要查看机器代码,请使用-print-opt-code --code-comments
.
To see the machine code, use --print-opt-code --code-comments
.
这篇关于nodejs/V8是否将已编译的机器代码存储在磁盘上的任何位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!