AdoptOpenJDK / jitwatch

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.
Other
3.06k stars 437 forks source link

Add a decompiler for the disassembly #321

Closed JCWasmx86 closed 4 years ago

JCWasmx86 commented 4 years ago

It would be quite cool to see a decompiler for the assembly. Suppose you have following method:

static int divideByTwo(int a){
   return a/2;
}

After that you have for example maybe this assembly for this snippet:

...
mov %rdi, %rax
shr $1,%rax
ret
...

And it would be more readable to see some C-like code:

int divideByTwo(int a){
   return a>>1;
}

You could embed radare or parts of ghidra as a decompiler, so you don't have to write one.

chriswhocodes commented 4 years ago

Hi, You can see the original Java source code alongside the bytecode and the disassembled native code in JITWatch's "TriView" pane.

If you have the real source, I don't think disassembling the native to a different set of Java instructions would be helpful?

Thanks for the suggestion,

Chris