8072061: Automatically determine optimal sizes for the CDS regions

See new C++ class MetaspaceClosure.

Reviewed-by: coleenp, jiangli, mseledtsov
This commit is contained in:
Ioi Lam 2017-08-02 18:06:38 -07:00
parent 4b983a51fd
commit f7f193ae71
82 changed files with 2010 additions and 1622 deletions

View file

@ -36,6 +36,7 @@
template <typename T>
class Array: public MetaspaceObj {
friend class MetadataFactory;
friend class MetaspaceShared;
friend class VMStructs;
friend class JVMCIVMStructs;
friend class MethodHandleCompiler; // special case
@ -53,13 +54,16 @@ protected:
Array(const Array<T>&);
void operator=(const Array<T>&);
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<T>) + MAX2(length - 1, 0) * sizeof(T); }
static size_t byte_sizeof(int length, size_t elm_byte_size) {
return sizeof(Array<T>) + 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,
@ -130,6 +134,9 @@ protected:
return (int)words;
}
static int size(int length, int elm_byte_size) {
return align_size_up(byte_sizeof(length, elm_byte_size), BytesPerWord) / BytesPerWord; // FIXME
}
int size() {
return size(_length);