Math.min(II) polluted compilation

Andrew Haley aph at redhat.com
Thu Feb 27 17:54:21 UTC 2025


On 2/27/25 16:28, Galder Zamarreno wrote:
> Is there a way to avoid this issue? Can JMH somehow instruct HotSpot to deopt Math.min(II) before the warmup phase of the benchmark runs to avoid pollution?

I don't think that would help, because even after deopt the MDO
remains. Surely you're asking for something completely unrealistic,
though? In the real world of real apps, Math.min() is bound to be
polluted by all of the different ways it's been called, from many
users.

You may be able to use WhiteBox in your JMH code. There is a way to
deoptimize a specific method or the whole call stack, which you can
call from Java. There are lots of examples of WhiteBox use in the
JDK test suite. Using WhiteBox is rather fiddly, though.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the jmh-dev mailing list