提交 0d459bfa 编写于 作者: J jmasa

8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders

Reviewed-by: johnc, coleenp
上级 73ee7ee2
......@@ -330,10 +330,19 @@ Metaspace* ClassLoaderData::metaspace_non_null() {
}
if (this == the_null_class_loader_data()) {
assert (class_loader() == NULL, "Must be");
size_t word_size = Metaspace::first_chunk_word_size();
set_metaspace(new Metaspace(_metaspace_lock, word_size));
set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType));
} else if (is_anonymous()) {
if (TraceClassLoaderData && Verbose && class_loader() != NULL) {
tty->print_cr("is_anonymous: %s", class_loader()->klass()->internal_name());
}
set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType));
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
if (TraceClassLoaderData && Verbose && class_loader() != NULL) {
tty->print_cr("is_reflection: %s", class_loader()->klass()->internal_name());
}
set_metaspace(new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType));
} else {
set_metaspace(new Metaspace(_metaspace_lock)); // default size for now.
set_metaspace(new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType));
}
}
return _metaspace;
......@@ -672,8 +681,8 @@ void ClassLoaderData::initialize_shared_metaspaces() {
"only supported for null loader data for now");
assert (!_shared_metaspaces_initialized, "only initialize once");
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
_ro_metaspace = new Metaspace(_metaspace_lock, SharedReadOnlySize/wordSize);
_rw_metaspace = new Metaspace(_metaspace_lock, SharedReadWriteSize/wordSize);
_ro_metaspace = new Metaspace(_metaspace_lock, Metaspace::ROMetaspaceType);
_rw_metaspace = new Metaspace(_metaspace_lock, Metaspace::ReadWriteMetaspaceType);
_shared_metaspaces_initialized = true;
}
......
......@@ -67,7 +67,8 @@ void TreeChunk<Chunk_t, FreeList_t>::verify_tree_chunk_list() const {
}
template <class Chunk_t, template <class> class FreeList_t>
TreeList<Chunk_t, FreeList_t>::TreeList() {}
TreeList<Chunk_t, FreeList_t>::TreeList() : _parent(NULL),
_left(NULL), _right(NULL) {}
template <class Chunk_t, template <class> class FreeList_t>
TreeList<Chunk_t, FreeList_t>*
......@@ -82,7 +83,7 @@ TreeList<Chunk_t, FreeList_t>::as_TreeList(TreeChunk<Chunk_t,FreeList_t>* tc) {
tl->link_head(tc);
tl->link_tail(tc);
tl->set_count(1);
assert(tl->parent() == NULL, "Should be clear");
return tl;
}
......
......@@ -777,6 +777,15 @@ MetaWord* CollectorPolicy::satisfy_failed_metadata_allocation(
full_gc_count,
GCCause::_metadata_GC_threshold);
VMThread::execute(&op);
// If GC was locked out, try again. Check
// before checking success because the prologue
// could have succeeded and the GC still have
// been locked out.
if (op.gc_locked()) {
continue;
}
if (op.prologue_succeeded()) {
return op.result();
}
......
......@@ -56,6 +56,7 @@ Metachunk* Metachunk::initialize(MetaWord* ptr, size_t word_size) {
assert(chunk_end > chunk_bottom, "Chunk must be too small");
chunk->set_end(chunk_end);
chunk->set_next(NULL);
chunk->set_prev(NULL);
chunk->set_word_size(word_size);
#ifdef ASSERT
size_t data_word_size = pointer_delta(chunk_end, chunk_bottom, sizeof(MetaWord));
......@@ -76,15 +77,15 @@ MetaWord* Metachunk::allocate(size_t word_size) {
}
// _bottom points to the start of the chunk including the overhead.
size_t Metachunk::used_word_size() {
size_t Metachunk::used_word_size() const {
return pointer_delta(_top, _bottom, sizeof(MetaWord));
}
size_t Metachunk::free_word_size() {
size_t Metachunk::free_word_size() const {
return pointer_delta(_end, _top, sizeof(MetaWord));
}
size_t Metachunk::capacity_word_size() {
size_t Metachunk::capacity_word_size() const {
return pointer_delta(_end, _bottom, sizeof(MetaWord));
}
......@@ -93,6 +94,10 @@ void Metachunk::print_on(outputStream* st) const {
" bottom " PTR_FORMAT " top " PTR_FORMAT
" end " PTR_FORMAT " size " SIZE_FORMAT,
bottom(), top(), end(), word_size());
if (Verbose) {
st->print_cr(" used " SIZE_FORMAT " free " SIZE_FORMAT,
used_word_size(), free_word_size());
}
}
#ifndef PRODUCT
......
......@@ -67,9 +67,11 @@ class Metachunk VALUE_OBJ_CLASS_SPEC {
void set_word_size(size_t v) { _word_size = v; }
public:
#ifdef ASSERT
Metachunk() : _bottom(NULL), _end(NULL), _top(NULL), _is_free(false) {}
Metachunk() : _bottom(NULL), _end(NULL), _top(NULL), _is_free(false),
_next(NULL), _prev(NULL) {}
#else
Metachunk() : _bottom(NULL), _end(NULL), _top(NULL) {}
Metachunk() : _bottom(NULL), _end(NULL), _top(NULL),
_next(NULL), _prev(NULL) {}
#endif
// Used to add a Metachunk to a list of Metachunks
......@@ -102,15 +104,15 @@ class Metachunk VALUE_OBJ_CLASS_SPEC {
}
// Reset top to bottom so chunk can be reused.
void reset_empty() { _top = (_bottom + _overhead); }
void reset_empty() { _top = (_bottom + _overhead); _next = NULL; _prev = NULL; }
bool is_empty() { return _top == (_bottom + _overhead); }
// used (has been allocated)
// free (available for future allocations)
// capacity (total size of chunk)
size_t used_word_size();
size_t free_word_size();
size_t capacity_word_size();
size_t used_word_size() const;
size_t free_word_size() const;
size_t capacity_word_size()const;
// Debug support
#ifdef ASSERT
......
此差异已折叠。
......@@ -87,11 +87,23 @@ class Metaspace : public CHeapObj<mtClass> {
public:
enum MetadataType {ClassType, NonClassType};
enum MetaspaceType {
StandardMetaspaceType,
BootMetaspaceType,
ROMetaspaceType,
ReadWriteMetaspaceType,
AnonymousMetaspaceType,
ReflectionMetaspaceType
};
private:
void initialize(Mutex* lock, size_t initial_size = 0);
void initialize(Mutex* lock, MetaspaceType type);
// Align up the word size to the allocation word size
static size_t align_word_size_up(size_t);
static size_t _first_chunk_word_size;
static size_t _first_class_chunk_word_size;
SpaceManager* _vsm;
SpaceManager* vsm() const { return _vsm; }
......@@ -110,8 +122,7 @@ class Metaspace : public CHeapObj<mtClass> {
public:
Metaspace(Mutex* lock, size_t initial_size);
Metaspace(Mutex* lock);
Metaspace(Mutex* lock, MetaspaceType type);
~Metaspace();
// Initialize globals for Metaspace
......@@ -119,6 +130,7 @@ class Metaspace : public CHeapObj<mtClass> {
static void initialize_class_space(ReservedSpace rs);
static size_t first_chunk_word_size() { return _first_chunk_word_size; }
static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; }
char* bottom() const;
size_t used_words(MetadataType mdtype) const;
......
......@@ -2217,7 +2217,8 @@ class CommandLineFlags {
develop(bool, TraceClassLoaderData, false, \
"Trace class loader loader_data lifetime") \
\
product(uintx, InitialBootClassLoaderMetaspaceSize, 3*M, \
product(uintx, InitialBootClassLoaderMetaspaceSize, \
NOT_LP64(2200*K) LP64_ONLY(4*M), \
"Initial size of the boot class loader data metaspace") \
\
product(bool, TraceGen0Time, false, \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册