// Return the maximum length of an array of BasicType.  The length can passed
 // to typeArrayOop::object_size(scale, length, header_size) without causing an
 // overflow. We substract an extra 2*wordSize to guard against double word
 // alignments. It gets the scale from the type2aelembytes array.
 static int32_t max_array_length(BasicType type) {
     assert(type >= 0 && type < T_CONFLICT, "wrong type");
     assert(type2aelembytes[type] != 0, "wrong type");
     const int bytes_per_element=type2aelembytes[type];
     return (((unsigned)1 << (BitsPerInt-1)) - header_size_in_bytes(type) - 2*HeapWordSize)
            / bytes_per_element;
 }
Esempio n. 2
0
bool arrayOopDesc::check_max_length_overflow(BasicType type) {
  julong length = max_array_length(type);
  julong bytes_per_element = type2aelembytes(type);
  julong bytes = length * bytes_per_element + header_size_in_bytes();
  return (julong)(size_t)bytes == bytes;
}
 static int base_offset_in_bytes(BasicType type) {
     return header_size_in_bytes(type);
 }