8066103: C2's range check smearing allows out of bound array accesses

Roland Westrelin roland.westrelin at oracle.com
Tue Dec 2 12:45:11 UTC 2014


> The propose fix is correct. Comments are good.
> 
> (nb_checks == 0) check and rc0 could be moved before (index1) to avoid duplication on both paths.
> 
> Add tests with i-c negative constants (and combinations -c and +c) when i starts with > c value.

Thanks for the review. Here is a new webrev:

http://cr.openjdk.java.net/~roland/8066103/webrev.01/

Roland.

> 
> Thanks,
> Vladimir
> 
> On 12/1/14 6:46 AM, Roland Westrelin wrote:
>> http://cr.openjdk.java.net/~roland/8066103/webrev.00/
>> 
>> Given a list of range checks of the form i + constant <u array.length, Range check smearing adjusts the top 2 dominating range checks to cover all range checks that post dominate. It’s incorrect to adjust the first range check because it allows the accesses that it guards to access out of bounds. If the first range check’s constant is the min of all constants, then it’s sufficient to adjust the second range check to test on the max of all constants. If the first range check’s constant is the max of all constants, then it’s sufficient to adjust the second range check to test on the min of all constants. In the general case, 3 range checks are needed to cover the rest of the series of range checks.
>> 
>> Roland.
>> 



More information about the hotspot-compiler-dev mailing list