v8引擎如何查看机器码

laozhang233 2017-03-02 03:38:45
新人求助各位大神。因论文需要,需要获得v8引擎将js代码编译后的机器码。因为第一次接触v8引擎,想知道该如何操作。
...全文
254 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxlin_ 2019-12-25
  • 打赏
  • 举报
回复
--print-code 也是可以的
--- Raw source ---
// t(1, 2);


// var t = 9876345;
function t(){
    print("ha ha ha");
}

// print(a);
print(t);

t();

// function c(){
//     print("ha ha ha");
// }

// t();
// t();
// t();

--- Code ---
source_position = 0
kind = FUNCTION
compiler = full-codegen
Instructions (size = 260)
0x32e31db687e0     0  55             push rbp                ;; debug: position 0
0x32e31db687e1     1  4889e5         REX.W movq rbp,rsp
0x32e31db687e4     4  56             push rsi
0x32e31db687e5     5  57             push rdi
0x32e31db687e6     6  41ff75a0       push [r13-0x60]
0x32e31db687ea    10  49bab9d4fc297e230000 REX.W movq r10,0x237e29fcd4b9    ;; object: 0x237e29fcd4b9 <FixedArray[2]>
0x32e31db687f4    20  4152           push r10
0x32e31db687f6    22  6a00           push 0x0
0x32e31db687f8    24  b802000000     movl rax,0x2
0x32e31db687fd    29  48bb105da20000000000 REX.W movq rbx,0xa25d10
0x32e31db68807    39  e8d4d8f9ff     call 0x32e31db060e0     ;; code: STUB, CEntryStub, minor: 4
0x32e31db6880c    44  493ba5200b0000 REX.W cmpq rsp,[r13+0xb20]
0x32e31db68813    51  7305           jnc 58  (0x32e31db6881a)
0x32e31db68815    53  e8c6acfdff     call StackCheck  (0x32e31db434e0)    ;; code: BUILTIN
0x32e31db6881a    58  48b80000000005000000 REX.W movq rax,0x500000000    ;; debug: statement 87
0x32e31db68824    68  e897f9ffff     call 0x32e31db681c0     ;; code: LOAD_GLOBAL_IC
0x32e31db68829    73  50             push rax
0x32e31db6882a    74  49ba9943f0297e230000 REX.W movq r10,0x237e29f04399    ;; object: 0x237e29f04399 <undefined>
0x32e31db68834    84  4152           push r10
0x32e31db68836    86  48b80000000001000000 REX.W movq rax,0x100000000    ;; debug: position 93
0x32e31db68840    96  e87bf9ffff     call 0x32e31db681c0     ;; code: LOAD_GLOBAL_IC
0x32e31db68845   101  50             push rax
0x32e31db68846   102  48ba0000000003000000 REX.W movq rdx,0x300000000    ;; debug: position 87
0x32e31db68850   112  488b7c2410     REX.W movq rdi,[rsp+0x10]
0x32e31db68855   117  e8a6fcffff     call 0x32e31db68500     ;; code: CALL_IC
0x32e31db6885a   122  488b75f8       REX.W movq rsi,[rbp-0x8]
0x32e31db6885e   126  4883c408       REX.W addq rsp,0x8
0x32e31db68862   130  48b80000000001000000 REX.W movq rax,0x100000000    ;; debug: statement 98
0x32e31db6886c   140  e84ff9ffff     call 0x32e31db681c0     ;; code: LOAD_GLOBAL_IC
0x32e31db68871   145  50             push rax
0x32e31db68872   146  49ba9943f0297e230000 REX.W movq r10,0x237e29f04399    ;; object: 0x237e29f04399 <undefined>
0x32e31db6887c   156  4152           push r10
0x32e31db6887e   158  48ba0000000007000000 REX.W movq rdx,0x700000000
0x32e31db68888   168  488b7c2408     REX.W movq rdi,[rsp+0x8]
0x32e31db6888d   173  e8cefeffff     call 0x32e31db68760     ;; code: CALL_IC
0x32e31db68892   178  488b75f8       REX.W movq rsi,[rbp-0x8]
0x32e31db68896   182  4883c408       REX.W addq rsp,0x8
0x32e31db6889a   186  488945e8       REX.W movq [rbp-0x18],rax
0x32e31db6889e   190  488b45e8       REX.W movq rax,[rbp-0x18]
0x32e31db688a2   194  48bbe1d3fc297e230000 REX.W movq rbx,0x237e29fcd3e1    ;; object: 0x237e29fcd3e1 Cell for 6144
0x32e31db688ac   204  83430bd1       addl [rbx+0xb],0xd1
0x32e31db688b0   208  791f           jns 241  (0x32e31db688d1)
0x32e31db688b2   210  50             push rax
0x32e31db688b3   211  e8a8abfdff     call InterruptCheck  (0x32e31db43460)    ;; code: BUILTIN
0x32e31db688b8   216  58             pop rax
0x32e31db688b9   217  48bbe1d3fc297e230000 REX.W movq rbx,0x237e29fcd3e1    ;; object: 0x237e29fcd3e1 Cell for 6144
0x32e31db688c3   227  49ba0000000000180000 REX.W movq r10,0x180000000000
0x32e31db688cd   237  4c895307       REX.W movq [rbx+0x7],r10
0x32e31db688d1   241  c9             leavel                  ;; debug: statement 175
0x32e31db688d2   242  c20800         ret 0x8
0x32e31db688d5   245  498b45a0       REX.W movq rax,[r13-0x60]
0x32e31db688d9   249  e9c4ffffff     jmp 194  (0x32e31db688a2)
0x32e31db688de   254  6690           nop

Deoptimization Output Data (deopt points = 0)

Back edges (size = 0)
ast_id  pc_offset  loop_depth

0x237e29fcd599: [TypeFeedbackInfo]
 - ic_total_count: 5, ic_with_type_info_count: 0, ic_generic_count: 0

RelocInfo (size = 33)
0x32e31db687e0  position  (0)
0x32e31db687ec  embedded object  (0x237e29fcd4b9 <FixedArray[2]>)
0x32e31db68808  code target (STUB)  (0x32e31db060e0)
0x32e31db68816  code target (BUILTIN)  (0x32e31db434e0)
0x32e31db6881a  statement position  (87)
0x32e31db68825  code target (LOAD_GLOBAL_IC)  (0x32e31db681c0)
0x32e31db6882c  embedded object  (0x237e29f04399 <undefined>)
0x32e31db68836  position  (93)
0x32e31db68841  code target (LOAD_GLOBAL_IC)  (0x32e31db681c0)
0x32e31db68846  position  (87)
0x32e31db68856  code target (CALL_IC)  (0x32e31db68500)
0x32e31db68862  statement position  (98)
0x32e31db6886d  code target (LOAD_GLOBAL_IC)  (0x32e31db681c0)
0x32e31db68874  embedded object  (0x237e29f04399 <undefined>)
0x32e31db6888e  code target (CALL_IC)  (0x32e31db68760)
0x32e31db688a4  embedded object  (0x237e29fcd3e1 Cell for 6144)
0x32e31db688b4  code target (BUILTIN)  (0x32e31db43460)
0x32e31db688bb  embedded object  (0x237e29fcd3e1 Cell for 6144)
0x32e31db688d1  statement position  (175)

--- End code ---
zxlin_ 2019-12-24
  • 打赏
  • 举报
回复
--print-all-code
挨踢直男 2017-03-02
  • 打赏
  • 举报
回复
上知乎吧 这问在csdn太高端了

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧