RFR(S): 8215265: C2: range check elimination may allow illegal out of bound access
vladimir.kozlov at oracle.com
Wed Dec 19 18:08:24 UTC 2018
On 12/19/18 7:35 AM, Roland Westrelin wrote:
> Hi Vladimir,
> Thanks for looking at this.
>> pre_limit = (low_limit - offset - (scale_con - 1)) / scale_con
> pre_limit = (low_limit - offset + (scale_con - 1)) / scale_con
> to round up?
Yes, my bad.
> But then there's a risk of overlow of low_limit - offset + (scale_con -
> So it would need to be:
> l = (low_limit - offset) / scale_con
> pre_limit = l + ((low_limit - offset - l * scale_con) != 0 ? 1 : 0)
> That's why I went with always +1 if scale > 1.
Okay. I was thinking about more complex solution since we can come up with some expressions to check overflow and
convert it into max_int (which will lead to use loop_limit). But on other hand this code is rarely (never) executed when
Loop Predicates are used (which is default). I agree for your solution.
More information about the hotspot-compiler-dev