6964458: Reimplement class meta-data storage to use native memory

Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes

Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
This commit is contained in:
Jon Masamitsu 2012-09-01 13:25:18 -04:00 committed by Coleen Phillimore
parent 36eee7c8c8
commit 5c58d27aac
853 changed files with 26124 additions and 82956 deletions

View file

@ -31,17 +31,8 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.inline.hpp"
#include "oops/compiledICHolderKlass.hpp"
#include "oops/constMethodKlass.hpp"
#include "oops/constantPoolKlass.hpp"
#include "oops/cpCacheKlass.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/instanceKlassKlass.hpp"
#include "oops/instanceOop.hpp"
#include "oops/klassKlass.hpp"
#include "oops/klassOop.hpp"
#include "oops/methodDataKlass.hpp"
#include "oops/methodKlass.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
@ -55,135 +46,45 @@ typeArrayOop oopFactory::new_charArray(const char* utf8_str, TRAPS) {
return result;
}
typeArrayOop oopFactory::new_permanent_charArray(int length, TRAPS) {
return typeArrayKlass::cast(Universe::charArrayKlassObj())->allocate_permanent(length, THREAD);
typeArrayOop oopFactory::new_tenured_charArray(int length, TRAPS) {
return typeArrayKlass::cast(Universe::charArrayKlassObj())->allocate(length, THREAD);
}
typeArrayOop oopFactory::new_permanent_byteArray(int length, TRAPS) {
return typeArrayKlass::cast(Universe::byteArrayKlassObj())->allocate_permanent(length, THREAD);
}
typeArrayOop oopFactory::new_permanent_shortArray(int length, TRAPS) {
return typeArrayKlass::cast(Universe::shortArrayKlassObj())->allocate_permanent(length, THREAD);
}
typeArrayOop oopFactory::new_permanent_intArray(int length, TRAPS) {
return typeArrayKlass::cast(Universe::intArrayKlassObj())->allocate_permanent(length, THREAD);
}
typeArrayOop oopFactory::new_typeArray(BasicType type, int length, TRAPS) {
klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
typeArrayOop result = type_asArrayKlass->allocate(length, THREAD);
return result;
}
// Create a Java array that points to metadata.
// As far as Java code is concerned, a metaData array is either an array of
// int or long depending on pointer size. Only a few things use this, like
// stack trace elements in Throwable. They cast Method* into this type.
// Note:can't point to symbols because there's no way to unreference count
// them when this object goes away.
typeArrayOop oopFactory::new_metaDataArray(int length, TRAPS) {
BasicType type = LP64_ONLY(T_LONG) NOT_LP64(T_INT);
Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
typeArrayOop result = type_asArrayKlass->allocate_common(length, true, THREAD);
return result;
}
typeArrayOop oopFactory::new_typeArray_nozero(BasicType type, int length, TRAPS) {
klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
Klass* type_asKlassOop = Universe::typeArrayKlassObj(type);
typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
typeArrayOop result = type_asArrayKlass->allocate_common(length, false, THREAD);
return result;
}
objArrayOop oopFactory::new_objArray(klassOop klass, int length, TRAPS) {
objArrayOop oopFactory::new_objArray(Klass* klass, int length, TRAPS) {
assert(klass->is_klass(), "must be instance class");
if (klass->klass_part()->oop_is_array()) {
return ((arrayKlass*)klass->klass_part())->allocate_arrayArray(1, length, THREAD);
if (klass->oop_is_array()) {
return ((arrayKlass*)klass)->allocate_arrayArray(1, length, THREAD);
} else {
assert (klass->klass_part()->oop_is_instance(), "new object array with klass not an instanceKlass");
return ((instanceKlass*)klass->klass_part())->allocate_objArray(1, length, THREAD);
assert (klass->oop_is_instance(), "new object array with klass not an InstanceKlass");
return ((InstanceKlass*)klass)->allocate_objArray(1, length, THREAD);
}
}
objArrayOop oopFactory::new_system_objArray(int length, TRAPS) {
int size = objArrayOopDesc::object_size(length);
KlassHandle klass (THREAD, Universe::systemObjArrayKlassObj());
objArrayOop o = (objArrayOop)
Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL);
// initialization not needed, allocated cleared
return o;
}
constantPoolOop oopFactory::new_constantPool(int length,
bool is_conc_safe,
TRAPS) {
constantPoolKlass* ck = constantPoolKlass::cast(Universe::constantPoolKlassObj());
return ck->allocate(length, is_conc_safe, CHECK_NULL);
}
constantPoolCacheOop oopFactory::new_constantPoolCache(int length,
TRAPS) {
constantPoolCacheKlass* ck = constantPoolCacheKlass::cast(Universe::constantPoolCacheKlassObj());
return ck->allocate(length, CHECK_NULL);
}
klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
int static_field_size,
unsigned int nonstatic_oop_map_count,
AccessFlags access_flags,
ReferenceType rt,
KlassHandle host_klass, TRAPS) {
instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
return ikk->allocate_instance_klass(name, vtable_len, itable_len,
static_field_size, nonstatic_oop_map_count,
access_flags, rt, host_klass, CHECK_NULL);
}
constMethodOop oopFactory::new_constMethod(int byte_code_size,
int compressed_line_number_size,
int localvariable_table_length,
int exception_table_length,
int checked_exceptions_length,
bool is_conc_safe,
TRAPS) {
klassOop cmkObj = Universe::constMethodKlassObj();
constMethodKlass* cmk = constMethodKlass::cast(cmkObj);
return cmk->allocate(byte_code_size, compressed_line_number_size,
localvariable_table_length, exception_table_length,
checked_exceptions_length, is_conc_safe,
CHECK_NULL);
}
methodOop oopFactory::new_method(int byte_code_size, AccessFlags access_flags,
int compressed_line_number_size,
int localvariable_table_length,
int exception_table_length,
int checked_exceptions_length,
bool is_conc_safe,
TRAPS) {
methodKlass* mk = methodKlass::cast(Universe::methodKlassObj());
assert(!access_flags.is_native() || byte_code_size == 0,
"native methods should not contain byte codes");
constMethodOop cm = new_constMethod(byte_code_size,
compressed_line_number_size,
localvariable_table_length,
exception_table_length,
checked_exceptions_length,
is_conc_safe, CHECK_NULL);
constMethodHandle rw(THREAD, cm);
return mk->allocate(rw, access_flags, CHECK_NULL);
}
methodDataOop oopFactory::new_methodData(methodHandle method, TRAPS) {
methodDataKlass* mdk = methodDataKlass::cast(Universe::methodDataKlassObj());
return mdk->allocate(method, CHECK_NULL);
}
compiledICHolderOop oopFactory::new_compiledICHolder(methodHandle method, KlassHandle klass, TRAPS) {
compiledICHolderKlass* ck = (compiledICHolderKlass*) Universe::compiledICHolderKlassObj()->klass_part();
compiledICHolderOop c = ck->allocate(CHECK_NULL);
c->set_holder_method(method());
c->set_holder_klass(klass());
return c;
}