RFR: 8286002: Add support for intel syntax to capstone hsdis

Jorn Vernee jvernee at openjdk.java.net
Mon May 2 14:47:00 UTC 2022


This patch adds support for outputting assembly in intel syntax to capstone hsdis, through the `-XX:PrintAssemblyOptions=intel` flag.

Snippet of example output:


[Verified Entry Point]
  # {method} {0x0000021c8a4002d8} 'add' '(II)I' in 'Main'
  # parm0:    rdx       = int
  # parm1:    r8        = int
  #           [sp+0x20]  (sp of caller)
  0x0000021cfa713780:   sub             rsp, 0x18
  0x0000021cfa713787:   mov             qword ptr [rsp + 0x10], rbp
  0x0000021cfa71378c:   mov             eax, edx
  0x0000021cfa71378e:   add             eax, r8d
  0x0000021cfa713791:   add             rsp, 0x10
  0x0000021cfa713795:   pop             rbp
  0x0000021cfa713796:   cmp             rsp, qword ptr [r15 + 0x338]
                                                            ;   {poll_return}
  0x0000021cfa71379d:   ja              0x21cfa7137a4
  0x0000021cfa7137a3:   ret
  0x0000021cfa7137a4:   movabs          r10, 0x21cfa713796  ;   {internal_word}
  0x0000021cfa7137ae:   mov             qword ptr [r15 + 0x350], r10
  0x0000021cfa7137b5:   jmp             0x21cfa6f3400       ;   {runtime_call SafepointBlob}
  ```
  
  Testing: 
  - Manual testing with and without `-XX:PrintAssemblyOptions=intel`, to make sure that both syntaxes work.
  - Manual testing with several different invalid options such as `-XX:PrintAssemblyOptions=asdf,,` to make sure that invalid options are handled correctly.
  
  Thanks,
  Jorn

-------------

Commit messages:
 - Remove unneeded stdio include
 - Print option errors through provided callback
 - Add defaults
 - Add support for intel syntax to capstone hsdis

Changes: https://git.openjdk.java.net/jdk/pull/8502/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8502&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8286002
  Stats: 37 lines in 1 file changed: 33 ins; 0 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8502.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8502/head:pull/8502

PR: https://git.openjdk.java.net/jdk/pull/8502


More information about the hotspot-compiler-dev mailing list