Using Array.newInstance still generates checkcast instructions

John Rose john.r.rose at oracle.com
Tue Oct 27 17:56:43 UTC 2015


On Oct 27, 2015, at 10:46 AM, Vitaly Davidovich <vitalyd at gmail.com> wrote:
> 
> The whole use case is inlined here, which is the case that bothers me.  If the underlying array access is inlined, couldn't its runtime type be checked? I don't understand the heap pollution issue in this case.  The field is not Object[] at JIT time.
> 

As a more more limited use case for Array.newInstance, see Arrays.copyOfRange (four argument version).

That is supposed to copyOfRange(new String[2], …) is supposed to feed through the right type to the return value, and it's a bug if it doesn't.

There's some relevant difference in your use case (even after inlining) and copyOfRange; I think it's the field.  Maybe our scalarization optimization is losing the type of the value; the rules for feeding types through fields (even after scalarization) are tricky.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20151027/ce9a3187/attachment.html>


More information about the hotspot-compiler-dev mailing list