RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles [v2]

Claes Redestad redestad at openjdk.java.net
Fri Jun 3 16:59:47 UTC 2022


On Fri, 3 Jun 2022 16:48:11 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> I'm not so sure. 
>> 
>> First of all we're no worse than before with the defensive copying here. Second of an optimizing compiler might theoretically be able to see that the array we get from the toArray is always fresh and not escaping anywhere in any well-behaved collection, so the clone could be elided. But if not then both toArray and clone are intrinsified operations that are heavily optimized and pretty fast even when interpreting, so emulating it with an external loop might end up taking more time even at peak. While likely taking longer to reach that peak. Using dumb, shared and common code (especially things that get JITted early anyhow) is nice in areas that see most action during startup/warmup.
>
> Ok, please keep it the way it is in your current patch then.

Correction: `toArray` isn't intrinsified, but common `List` implementations are likely to implement it with a `System.arraycopy`, which is.

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

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


More information about the core-libs-dev mailing list