I have read that Javascript source code first piles to the intermediate representation(bytecode). Then bytecode piles to the native code using jit. So I pile webkit on my linux machine, and want to get bytecode of source file. But I can't figure how to do that?
How can I see/access the intermediate byte code that a javascript interpreter produces?
I have read that Javascript source code first piles to the intermediate representation(bytecode). Then bytecode piles to the native code using jit. So I pile webkit on my linux machine, and want to get bytecode of source file. But I can't figure how to do that?
How can I see/access the intermediate byte code that a javascript interpreter produces?
Share Improve this question edited Nov 28, 2011 at 14:13 Jonathan M 17.5k9 gold badges60 silver badges94 bronze badges asked Nov 28, 2011 at 14:08 Vahag VardanyanVahag Vardanyan 3017 silver badges13 bronze badges 1- 2 related questions: stackoverflow./questions/1152367/… and stackoverflow./questions/5356786/… – Mister Smith Commented Nov 28, 2011 at 14:12
1 Answer
Reset to default 7If you use Chrome or Node, the JS Engine V8 generates bytecode. Safari has a similar flag.
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)
See Understanding V8's Bytecode.