[vector] Error message in the fromArray length check is misleading
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Wed Jan 30 22:09:21 UTC 2019
> I realise my code is blowing past the end of the array & triggering the
> exception (which is good, as my code was wrong), but I feel like the
> message should say "Index 50 is out of bounds for length 50", or
> something similar, rather than saying my array is of a different length
> to what's actually allocated.
>
> Maybe in VectorIntrinsics line 405
> case 2: return Objects.checkIndex(ix, length - (vlen - 1));
> it could be modified to check if ix + vlen is below length, rather than
> if ix is below length - (vlen -1)?
I fully agree that the message is misleading. It should be much clearer
and involve some vector-specific information (vector access spans a
range while Objects.checkIndex assumes a single element is accessed).
The check is written that way to improve range check elimination (upper
bound is invariant in loop body). As previous performance experiments
showed there's still some room for improvements, but those are unrelated
to the error message.
So, I'm in favor of improving error message itself leaving the check as
is for now.
Best regards,
Vladimir Ivanov
More information about the panama-dev
mailing list