RFR: 8255150: Add utility methods to check long indexes and ranges [v2]

Roland Westrelin roland at openjdk.java.net
Fri Nov 6 08:27:59 UTC 2020


On Fri, 6 Nov 2020 04:25:40 GMT, Dean Long <dlong at openjdk.org> wrote:

>> src/hotspot/share/opto/library_call.cpp line 1015:
>> 
>>> 1013:                   Deoptimization::Action_make_not_entrant);
>>> 1014:   }
>>> 1015: 
>> 
>> A comment here explaining what the code below is doing would be helpful.
>
> This code wasn't here before, so I'm guessing it's needed for T_LONG.  For T_INT is it just wasted work?

Code in IdealLoopTree::is_range_check_if() uses this check:
  if (range->Opcode() != Op_LoadRange && !iff->is_RangeCheck()) {
    const TypeInt* tint = phase->_igvn.type(range)->isa_int();
    if (tint == NULL || tint->empty() || tint->_lo < 0) {
      // Allow predication on positive values that aren't LoadRanges.
      // This allows optimization of loops where the length of the
      // array is a known value and doesn't need to be loaded back
      // from the array.
      return false;
that is it assumes that everything that's on the right hand size of the a RangeCheck test is positive. I think it's cleaner and less dangerous to explicitly cast the length to >= 0 when the intrinsic is built. In a subsequent patch I intend to drop the && !iff->is_RangeCheck() check above.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1003


More information about the core-libs-dev mailing list