--- old/src/hotspot/share/c1/c1_LIRGenerator.cpp 2018-11-27 23:21:12.752695815 -0800 +++ new/src/hotspot/share/c1/c1_LIRGenerator.cpp 2018-11-27 23:21:12.632691243 -0800 @@ -1570,9 +1570,17 @@ #ifndef _LP64 LIR_Opr index_op = index.result(); + // FIXME -- on 32-bit, the shift below can overflow, so we need to check that + // the top (value_array_klass->log2_element_size()+1) bits of index_op must be zero, or + // else throw ArrayIndexOutOfBoundsException #else LIR_Opr index_op = new_register(T_LONG); - __ convert(Bytecodes::_i2l, index.result(), index_op); + if (index.result()->is_constant()) { + jint const_index = index.result()->as_jint(); + __ move(LIR_OprFact::longConst(const_index), index_op); + } else { + __ convert(Bytecodes::_i2l, index.result(), index_op); + } #endif // Need to shift manually, as LIR_Address can scale only up to 3. __ shift_left(index_op, value_array_klass->log2_element_size(), index_op);