--- old/src/share/vm/oops/array.hpp 2017-06-29 15:57:36.544390001 -0700 +++ new/src/share/vm/oops/array.hpp 2017-06-29 15:57:36.364383081 -0700 @@ -35,6 +35,7 @@ template class Array: public MetaspaceObj { friend class MetadataFactory; + friend class MetaspaceShared; friend class VMStructs; friend class JVMCIVMStructs; friend class MethodHandleCompiler; // special case @@ -52,13 +53,16 @@ Array(const Array&); void operator=(const Array&); - void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) throw() { + void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() { size_t word_size = Array::size(length); - return (void*) Metaspace::allocate(loader_data, word_size, read_only, + return (void*) Metaspace::allocate(loader_data, word_size, MetaspaceObj::array_type(sizeof(T)), THREAD); } - static size_t byte_sizeof(int length) { return sizeof(Array) + MAX2(length - 1, 0) * sizeof(T); } + static size_t byte_sizeof(int length, size_t elm_byte_size) { + return sizeof(Array) + MAX2(length - 1, 0) * elm_byte_size; + } + static size_t byte_sizeof(int length) { return byte_sizeof(length, sizeof(T)); } // WhiteBox API helper. // Can't distinguish between array of length 0 and length 1, @@ -124,6 +128,9 @@ static int size(int length) { return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord; } + static int size(int length, int elm_byte_size) { + return align_size_up(byte_sizeof(length, elm_byte_size), BytesPerWord) / BytesPerWord; + } int size() { return size(_length);