[13] RFR (S): 8075052: Autobox elimination hinders loop unrolling
Vladimir Kozlov
vladimir.kozlov at oracle.com
Sat Feb 2 16:42:10 UTC 2019
So loop is not unrolled because of IntegerCache checks in valueOf()?
I assume valueOf() is inlined and the check is the only difference from new Integer(). Right?
And the check should be collapsing too if result is not used. So why loop is not counted?
The only issue I have with it is if you have exception path in code and you have to throw an exception (OOM, for
example) even when result is not used. But on other hand it is similar for normal scalar replaced allocation since
exception can come only from allocation in valueOf().
Code change is fine to me. I just want more information about the cause.
Thanks,
Vladimir
On 2/1/19 7:19 PM, Vladimir Ivanov wrote:
> http://cr.openjdk.java.net/~vlivanov/8075052/webrev.00/
> https://bugs.openjdk.java.net/browse/JDK-8075052
>
> C2 doesn't optimize Integer.valueOf() as good as new Integer().
> (There's a benchmark in the bug which demonstrates the difference.)
>
> It is caused by the fact that though Integer.intValue() can see through the call, the call itself isn't optimized away
> if the result (box) is not used. It is unconditionally inlined and hinders consequent optimizations.
>
> Proposed fix is to treat Integer.valueOf() as if it were a pure method and remove the call if its result (boxed value)
> isn't used.
>
> Testing: hs-precheckin-comp, tier1-7 (in progress)
>
> Best regards,
> Vladimir Ivanov
More information about the hotspot-compiler-dev
mailing list