Closed toaler closed 5 years ago
Hi Brian, I see you're using JMH which processes the benchmarking annotations to produce the final bytecode that includes the test loops etc. I see from the screenshot that the class and method names don't appear to be mangled (I think JMH produces synthetic method names). Is there any chance you could send me the source / hotspot log file and I'll investigate? Thanks, Chris
I think JMH generates various classes that eventually call down to bench.jit.InliningTest.testBigMethod to avoid DCE and other jit optimizations from happening. Here's what you asked for.
@chriswhocodes let me know if you need anything else. I can see that bench.jit.InlingTest.bigMethod is being inlined (call chain and bytecode pane of triview are green) into bench.jit.InliningTest.testBigMethod. I just don't get why I don't see the ASM for bigMethod inlined in testBigMethod assembly.
@toaler I think you need to say:
public long testBigMethod() {
return bigMethod(1, 1);
}
to actually avoid DCE. Stands to reason there is no generated code for the method otherwise -- it was optimized away. See JMHSample_08_DeadCode.
Hi Brian, I've run your test class and I get the same result: with TriView: where you can see no assembly from bigMethod(). I thought this might be because the inlined method body had been eliminated due to DCE because the result of bigMethod() is not used.
When I change your testBigMethod() code to return the result of the call to bigMethod() I get this
If you look at the line
mov $0xe, eax
you will see the result of your calculations (return 14) so the compiler has done a good job of reducing your call to bigMethod(1, 1) to a constant return of 14 (0xe in hex).
Hope this helps?
If you throw in a java.util.Random
then the calc will be less reducible and easier to spot the inlined assembly :)
I've been using JITWatch to understand how to discover JIT opportunties and so far it's been a great tool. My question pertains to the assembly view and inlined ASM.
I have a method testBigMethod that calls bigMethod. Using FreqInlineSize I was able to get bigMethod inlined into the caller testBigMethod.
Using JitWatch confirms this via the call chain view as well as the bytecode view invokespecial high lighted as green. So i'm 100% sure the inlining of bigMethod in testBigMethod is occuring.
Naively, I was expecting the asm for bigMethod to show up in the assembly view, but to my surprise I can't see it nor any obvious reasons as to why it's not there. Is this by design? I'm looking for details as why it's not there. Screenshot of what i'm seeing below.
Thanks in advance,