[9] RFR(S): 8158228: C1 incorrectly folds mismatched loads from stable arrays

Tobias Hartmann tobias.hartmann at oracle.com
Fri Jun 3 13:07:21 UTC 2016

Hi Vladimir,

On 03.06.2016 12:26, Vladimir Ivanov wrote:
>>>> Like this we still have optimal code. What do you think?
>>> I suggest to completely disable constant folding in Canonicalizer::do_LoadIndexed if LoadIndexed node is marked as mismatched.
>>> Please, leave ciArray::element_value_impl as is.
>> Okay, I noticed that C2 also does not fold mismatched accesses. Could you please explain why that is?
> Primarily to keep the code sane :-) Unsafe accesses are the source of mismatched accesses and additional checks are required to filter out all problematic cases. So, I decided to leave them out when enabled constant folding of unsafe loads. My main motivation for the change was to make method handles for field / array element accesses as fast as using bytecode, and mismatched accesses didn't justify all the complications they cause.

Okay, but in the case of the getChar intrinsic it should be safe to fold the mismatched access without additional checks, right?

>> Here's the new webrev:
>> http://cr.openjdk.java.net/~thartmann/8158228/webrev.02/
> Looks good.

Thank you!

Best regards,

> Best regards,
> Vladimir Ivanov

More information about the hotspot-compiler-dev mailing list