最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Get JavaScript bytecode - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 7

If 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.

发布评论

评论列表(0)

  1. 暂无评论