Bug 168629 - Air should have a disassembly mode that dumps IR and assembly intermixed
Summary: Air should have a disassembly mode that dumps IR and assembly intermixed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-20 18:46 PST by Saam Barati
Modified: 2017-02-21 15:59 PST (History)
11 users (show)

See Also:


Attachments
WIP (17.33 KB, patch)
2017-02-21 12:58 PST, Saam Barati
no flags Details | Formatted Diff | Diff
patch (23.18 KB, patch)
2017-02-21 15:28 PST, Saam Barati
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2017-02-20 18:46:27 PST
Similar to the output you get from dumpDFGDisassembly, but for Air.

I'm going to be spending a lot of time looking at generated code, and it will make job easier to know where generated code came from.
Comment 1 Saam Barati 2017-02-21 12:58:26 PST
Created attachment 302296 [details]
WIP

It produces output like:

BB#0: ; frequency = 1.000000
      0x30b448402e00: push %rbp
      0x30b448402e01: mov %rsp, %rbp
      0x30b448402e04: add $0xffffffffffffffd0, %rsp
  Move $0x11456c960, %rax, $4636199264(@16)
      0x30b448402e08: mov $0x11456c960, %rax
  Move %rax, 16(%rbp), @19
      0x30b448402e12: mov %rax, 0x10(%rbp)
  Patch &Patchpoint2, %rbp, %rax, @20
      0x30b448402e16: lea -0x50(%rbp), %rax
      0x30b448402e1a: mov $0x1112081e0, %r11
      0x30b448402e24: cmp %rax, (%r11)
      0x30b448402e27: ja 0x30b448402e9a
  Move 56(%rbp), %rdx, @23
      0x30b448402e2d: mov 0x38(%rbp), %rdx
  Move $0xffff000000000002, %rax, $-281474976710654(@15)
      0x30b448402e31: mov $0xffff000000000002, %rax
  Patch &BranchTest64(3,SameAsRep)1, NonZero, %rdx, %rax, %rdx, @26
      0x30b448402e3b: test %rdx, %rax
      0x30b448402e3e: jnz 0x30b448402f08
  Move 48(%rbp), %rax, @29
      0x30b448402e44: mov 0x30(%rbp), %rax
  Move %rax, %rcx, @31
      0x30b448402e48: mov %rax, %rcx
  Xor64 $6, %rcx, @31
      0x30b448402e4b: xor $0x6, %rcx
  Patch &BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35
      0x30b448402e4f: test $0xfffffffffffffffe, %rcx
      0x30b448402e56: jnz 0x30b448402f12
  Patch &Branch32(3,SameAsRep)0, NotEqual, (%rdx), $266, %rdx, @45
      0x30b448402e5c: cmp $0x10a, (%rdx)
      0x30b448402e62: jnz 0x30b448402f1c
  BranchTest32 NonZero, %rax, $1, @49
      0x30b448402e68: test $0x1, %al
      0x30b448402e6a: jnz 0x30b448402e91
BB#1: ; frequency = 1.000000
  Predecessors: #0
  Move $0, %rcx, @65
      0x30b448402e70: xor %rcx, %rcx
BB#2: ; frequency = 1.000000
  Predecessors: #1, #3
  Move 24(%rdx), %rax, @58
      0x30b448402e73: mov 0x18(%rdx), %rax
  Patch &BranchAdd32(4,ForceLateUseUnlessRecoverable)3, Overflow, %rcx, %rax, %rcx, %rcx, %rax, @60
      0x30b448402e77: add %eax, %ecx
      0x30b448402e79: jo 0x30b448402f26
  Move $0xffff000000000000, %rax, $-281474976710656(@14)
      0x30b448402e7f: mov $0xffff000000000000, %rax
  Add64 %rcx, %rax, %rax, @62
      0x30b448402e89: add %rcx, %rax
  Ret64 %rax, @63
      0x30b448402e8c: mov %rbp, %rsp
      0x30b448402e8f: pop %rbp
      0x30b448402e90: ret
Comment 2 Caio Lima 2017-02-21 14:46:12 PST
This is really good!
Comment 3 Saam Barati 2017-02-21 15:22:28 PST
Ok, I revised the output a bit. It'll look like this when using dumpFTLDisassembly:

Generated FTL JIT code for foo#CUaFiQ:[0x10b76c960->0x10b76c2d0->0x10b7b6da0, FTLFunctionCall, 40 (NeverInline)], instruction count = 40:
BB#0: ; frequency = 1.000000
        0x469004e02e00: push %rbp
        0x469004e02e01: mov %rsp, %rbp
        0x469004e02e04: add $0xffffffffffffffd0, %rsp
    Move $0x10b76c960, %rax, $4487301472(@16)
        0x469004e02e08: mov $0x10b76c960, %rax
    Move %rax, 16(%rbp), @19
        0x469004e02e12: mov %rax, 0x10(%rbp)
    Patch &Patchpoint2, %rbp, %rax, @20
        0x469004e02e16: lea -0x50(%rbp), %rax
        0x469004e02e1a: mov $0x1084081e0, %r11
        0x469004e02e24: cmp %rax, (%r11)
        0x469004e02e27: ja 0x469004e02e9a
    Move 56(%rbp), %rdx, @23
        0x469004e02e2d: mov 0x38(%rbp), %rdx
    Move $0xffff000000000002, %rax, $-281474976710654(@15)
        0x469004e02e31: mov $0xffff000000000002, %rax
    Patch &BranchTest64(3,SameAsRep)1, NonZero, %rdx, %rax, %rdx, @26
        0x469004e02e3b: test %rdx, %rax
        0x469004e02e3e: jnz 0x469004e02f08
    Move 48(%rbp), %rax, @29
        0x469004e02e44: mov 0x30(%rbp), %rax
    Move %rax, %rcx, @31
        0x469004e02e48: mov %rax, %rcx
    Xor64 $6, %rcx, @31
        0x469004e02e4b: xor $0x6, %rcx
    Patch &BranchTest64(3,SameAsRep)1, NonZero, %rcx, $-2, %rax, @35
        0x469004e02e4f: test $0xfffffffffffffffe, %rcx
        0x469004e02e56: jnz 0x469004e02f12
    Patch &Branch32(3,SameAsRep)0, NotEqual, (%rdx), $266, %rdx, @45
        0x469004e02e5c: cmp $0x10a, (%rdx)
        0x469004e02e62: jnz 0x469004e02f1c
    BranchTest32 NonZero, %rax, $1, @49
        0x469004e02e68: test $0x1, %al
        0x469004e02e6a: jnz 0x469004e02e91
  Successors: #3, #1
BB#1: ; frequency = 1.000000
  Predecessors: #0
    Move $0, %rcx, @65
        0x469004e02e70: xor %rcx, %rcx
    Jump @66
  Successors: #2
BB#2: ; frequency = 1.000000
  Predecessors: #1, #3
    Move 24(%rdx), %rax, @58
        0x469004e02e73: mov 0x18(%rdx), %rax
    Patch &BranchAdd32(4,ForceLateUseUnlessRecoverable)3, Overflow, %rcx, %rax, %rcx, %rcx, %rax, @60
        0x469004e02e77: add %eax, %ecx
        0x469004e02e79: jo 0x469004e02f26
    Move $0xffff000000000000, %rax, $-281474976710656(@14)
        0x469004e02e7f: mov $0xffff000000000000, %rax
    Add64 %rcx, %rax, %rax, @62
        0x469004e02e89: add %rcx, %rax
    Ret64 %rax, @63
        0x469004e02e8c: mov %rbp, %rsp
        0x469004e02e8f: pop %rbp
        0x469004e02e90: ret 
BB#3: ; frequency = 1.000000
  Predecessors: #0
    Move 16(%rdx), %rcx, @52
        0x469004e02e91: mov 0x10(%rdx), %rcx
    Jump @55
        0x469004e02e95: jmp 0x469004e02e73
  Successors: #2
# Late paths
        0x469004e02e9a: mov $0x0, 0x24(%rbp)
        0x469004e02ea1: mov $0x108406618, %r9
        0x469004e02eab: mov (%r9), %r9
        0x469004e02eae: add $0xffffffffffffffd8, %r9
        0x469004e02eb2: mov %rbx, (%r9)
        0x469004e02eb5: mov %r12, 0x8(%r9)
        0x469004e02eb9: mov %r13, 0x10(%r9)
        0x469004e02ebd: mov %r14, 0x18(%r9)
        0x469004e02ec1: mov %r15, 0x20(%r9)
        0x469004e02ec5: mov %rbp, %rdi
        0x469004e02ec8: mov $0x10b76c960, %rsi
        0x469004e02ed2: mov $0x0, %r11
        0x469004e02edc: call *%r11
        0x469004e02edf: mov $0x108400000, %rdi
        0x469004e02ee9: mov %rbp, %rsi
        0x469004e02eec: mov $0x0, %r11
        0x469004e02ef6: call *%r11
        0x469004e02ef9: mov $0x1084080f0, %rsi
        0x469004e02f03: mov (%rsi), %rsi
        0x469004e02f06: jmp *%rsi
        0x469004e02f08: push $0x0
        0x469004e02f0d: jmp 0x469004e02f12
        0x469004e02f12: push $0x1
        0x469004e02f17: jmp 0x469004e02f1c
        0x469004e02f1c: push $0x2
        0x469004e02f21: jmp 0x469004e02f26
        0x469004e02f26: sub %eax, %ecx
        0x469004e02f28: push $0x3
        0x469004e02f2d: jmp 0x469004e02f32
Comment 4 Saam Barati 2017-02-21 15:28:22 PST
Created attachment 302320 [details]
patch
Comment 5 WebKit Commit Bot 2017-02-21 15:31:36 PST
Attachment 302320 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/air/AirGenerate.cpp:209:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/JavaScriptCore/b3/air/AirGenerate.cpp:213:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/JavaScriptCore/b3/air/AirGenerate.cpp:227:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 3 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Saam Barati 2017-02-21 15:59:03 PST
landed in:
https://trac.webkit.org/changeset/212775