mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
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:
parent
36eee7c8c8
commit
5c58d27aac
853 changed files with 26124 additions and 82956 deletions
|
@ -23,29 +23,36 @@
|
|||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/dictionary.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "gc_implementation/shared/markSweep.inline.hpp"
|
||||
#include "gc_interface/collectedHeap.inline.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/klass.inline.hpp"
|
||||
#include "oops/klassOop.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "oops/oop.inline2.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/stack.hpp"
|
||||
#ifndef SERIALGC
|
||||
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
|
||||
#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
|
||||
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
|
||||
#endif
|
||||
|
||||
void Klass::set_name(Symbol* n) {
|
||||
_name = n;
|
||||
if (_name != NULL) _name->increment_refcount();
|
||||
}
|
||||
|
||||
bool Klass::is_subclass_of(klassOop k) const {
|
||||
bool Klass::is_subclass_of(Klass* k) const {
|
||||
// Run up the super chain and check
|
||||
klassOop t = as_klassOop();
|
||||
if (this == k) return true;
|
||||
|
||||
if (t == k) return true;
|
||||
t = Klass::cast(t)->super();
|
||||
Klass* t = const_cast<Klass*>(this)->super();
|
||||
|
||||
while (t != NULL) {
|
||||
if (t == k) return true;
|
||||
|
@ -54,17 +61,17 @@ bool Klass::is_subclass_of(klassOop k) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Klass::search_secondary_supers(klassOop k) const {
|
||||
bool Klass::search_secondary_supers(Klass* k) const {
|
||||
// Put some extra logic here out-of-line, before the search proper.
|
||||
// This cuts down the size of the inline method.
|
||||
|
||||
// This is necessary, since I am never in my own secondary_super list.
|
||||
if (this->as_klassOop() == k)
|
||||
if (this == k)
|
||||
return true;
|
||||
// Scan the array-of-objects for a match
|
||||
int cnt = secondary_supers()->length();
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
if (secondary_supers()->obj_at(i) == k) {
|
||||
if (secondary_supers()->at(i) == k) {
|
||||
((Klass*)this)->set_secondary_super_cache(k);
|
||||
return true;
|
||||
}
|
||||
|
@ -89,10 +96,10 @@ Klass *Klass::up_cast_abstract() {
|
|||
Klass *Klass::LCA( Klass *k2 ) {
|
||||
Klass *k1 = this;
|
||||
while( 1 ) {
|
||||
if( k1->is_subtype_of(k2->as_klassOop()) ) return k2;
|
||||
if( k2->is_subtype_of(k1->as_klassOop()) ) return k1;
|
||||
k1 = k1->super()->klass_part();
|
||||
k2 = k2->super()->klass_part();
|
||||
if( k1->is_subtype_of(k2) ) return k2;
|
||||
if( k2->is_subtype_of(k1) ) return k1;
|
||||
k1 = k1->super();
|
||||
k2 = k2->super();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,13 +120,13 @@ void Klass::initialize(TRAPS) {
|
|||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
bool Klass::compute_is_subtype_of(klassOop k) {
|
||||
bool Klass::compute_is_subtype_of(Klass* k) {
|
||||
assert(k->is_klass(), "argument must be a class");
|
||||
return is_subclass_of(k);
|
||||
}
|
||||
|
||||
|
||||
methodOop Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
|
||||
Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
|
||||
#ifdef ASSERT
|
||||
tty->print_cr("Error: uncached_lookup_method called on a klass oop."
|
||||
" Likely error: reflection method does not correctly"
|
||||
|
@ -129,67 +136,45 @@ methodOop Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
klassOop Klass::base_create_klass_oop(KlassHandle& klass, int size,
|
||||
const Klass_vtbl& vtbl, TRAPS) {
|
||||
size = align_object_size(size);
|
||||
// allocate and initialize vtable
|
||||
Klass* kl = (Klass*) vtbl.allocate_permanent(klass, size, CHECK_NULL);
|
||||
klassOop k = kl->as_klassOop();
|
||||
void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) {
|
||||
return Metaspace::allocate(loader_data, word_size, /*read_only*/false,
|
||||
Metaspace::ClassType, CHECK_NULL);
|
||||
}
|
||||
|
||||
Klass::Klass() {
|
||||
Klass* k = this;
|
||||
|
||||
{ // Preinitialize supertype information.
|
||||
// A later call to initialize_supers() may update these settings:
|
||||
kl->set_super(NULL);
|
||||
set_super(NULL);
|
||||
for (juint i = 0; i < Klass::primary_super_limit(); i++) {
|
||||
kl->_primary_supers[i] = NULL;
|
||||
_primary_supers[i] = NULL;
|
||||
}
|
||||
kl->set_secondary_supers(NULL);
|
||||
oop_store_without_check((oop*) &kl->_primary_supers[0], k);
|
||||
kl->set_super_check_offset(in_bytes(primary_supers_offset()));
|
||||
set_secondary_supers(NULL);
|
||||
_primary_supers[0] = k;
|
||||
set_super_check_offset(in_bytes(primary_supers_offset()));
|
||||
}
|
||||
|
||||
kl->set_java_mirror(NULL);
|
||||
kl->set_modifier_flags(0);
|
||||
kl->set_layout_helper(Klass::_lh_neutral_value);
|
||||
kl->set_name(NULL);
|
||||
set_java_mirror(NULL);
|
||||
set_modifier_flags(0);
|
||||
set_layout_helper(Klass::_lh_neutral_value);
|
||||
set_name(NULL);
|
||||
AccessFlags af;
|
||||
af.set_flags(0);
|
||||
kl->set_access_flags(af);
|
||||
kl->set_subklass(NULL);
|
||||
kl->set_next_sibling(NULL);
|
||||
kl->set_alloc_count(0);
|
||||
kl->set_alloc_size(0);
|
||||
TRACE_SET_KLASS_TRACE_ID(kl, 0);
|
||||
set_access_flags(af);
|
||||
set_subklass(NULL);
|
||||
set_next_sibling(NULL);
|
||||
set_next_link(NULL);
|
||||
set_alloc_count(0);
|
||||
TRACE_SET_KLASS_TRACE_ID(this, 0);
|
||||
|
||||
kl->set_prototype_header(markOopDesc::prototype());
|
||||
kl->set_biased_lock_revocation_count(0);
|
||||
kl->set_last_biased_lock_bulk_revocation_time(0);
|
||||
set_prototype_header(markOopDesc::prototype());
|
||||
set_biased_lock_revocation_count(0);
|
||||
set_last_biased_lock_bulk_revocation_time(0);
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
KlassHandle Klass::base_create_klass(KlassHandle& klass, int size,
|
||||
const Klass_vtbl& vtbl, TRAPS) {
|
||||
klassOop ek = base_create_klass_oop(klass, size, vtbl, THREAD);
|
||||
return KlassHandle(THREAD, ek);
|
||||
}
|
||||
|
||||
void Klass_vtbl::post_new_init_klass(KlassHandle& klass,
|
||||
klassOop new_klass) const {
|
||||
assert(!new_klass->klass_part()->null_vtbl(), "Not a complete klass");
|
||||
CollectedHeap::post_allocation_install_obj_klass(klass, new_klass);
|
||||
}
|
||||
|
||||
void* Klass_vtbl::operator new(size_t ignored, KlassHandle& klass,
|
||||
int size, TRAPS) {
|
||||
// The vtable pointer is installed during the execution of
|
||||
// constructors in the call to permanent_obj_allocate(). Delay
|
||||
// the installation of the klass pointer into the new klass "k"
|
||||
// until after the vtable pointer has been installed (i.e., until
|
||||
// after the return of permanent_obj_allocate().
|
||||
klassOop k =
|
||||
(klassOop) CollectedHeap::permanent_obj_allocate_no_klass_install(klass,
|
||||
size, CHECK_NULL);
|
||||
return k->klass_part();
|
||||
// The klass doesn't have any references at this point.
|
||||
clear_modified_oops();
|
||||
clear_accumulated_modified_oops();
|
||||
}
|
||||
|
||||
jint Klass::array_layout_helper(BasicType etype) {
|
||||
|
@ -202,7 +187,7 @@ jint Klass::array_layout_helper(BasicType etype) {
|
|||
int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
|
||||
|
||||
assert(lh < (int)_lh_neutral_value, "must look like an array layout");
|
||||
assert(layout_helper_is_javaArray(lh), "correct kind");
|
||||
assert(layout_helper_is_array(lh), "correct kind");
|
||||
assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
|
||||
assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
|
||||
assert(layout_helper_header_size(lh) == hsize, "correct decode");
|
||||
|
@ -215,13 +200,13 @@ jint Klass::array_layout_helper(BasicType etype) {
|
|||
bool Klass::can_be_primary_super_slow() const {
|
||||
if (super() == NULL)
|
||||
return true;
|
||||
else if (super()->klass_part()->super_depth() >= primary_super_limit()-1)
|
||||
else if (super()->super_depth() >= primary_super_limit()-1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void Klass::initialize_supers(klassOop k, TRAPS) {
|
||||
void Klass::initialize_supers(Klass* k, TRAPS) {
|
||||
if (FastSuperclassLimit == 0) {
|
||||
// None of the other machinery matters.
|
||||
set_super(k);
|
||||
|
@ -229,35 +214,35 @@ void Klass::initialize_supers(klassOop k, TRAPS) {
|
|||
}
|
||||
if (k == NULL) {
|
||||
set_super(NULL);
|
||||
oop_store_without_check((oop*) &_primary_supers[0], (oop) this->as_klassOop());
|
||||
_primary_supers[0] = this;
|
||||
assert(super_depth() == 0, "Object must already be initialized properly");
|
||||
} else if (k != super() || k == SystemDictionary::Object_klass()) {
|
||||
assert(super() == NULL || super() == SystemDictionary::Object_klass(),
|
||||
"initialize this only once to a non-trivial value");
|
||||
set_super(k);
|
||||
Klass* sup = k->klass_part();
|
||||
Klass* sup = k;
|
||||
int sup_depth = sup->super_depth();
|
||||
juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
|
||||
if (!can_be_primary_super_slow())
|
||||
my_depth = primary_super_limit();
|
||||
for (juint i = 0; i < my_depth; i++) {
|
||||
oop_store_without_check((oop*) &_primary_supers[i], (oop) sup->_primary_supers[i]);
|
||||
_primary_supers[i] = sup->_primary_supers[i];
|
||||
}
|
||||
klassOop *super_check_cell;
|
||||
Klass* *super_check_cell;
|
||||
if (my_depth < primary_super_limit()) {
|
||||
oop_store_without_check((oop*) &_primary_supers[my_depth], (oop) this->as_klassOop());
|
||||
_primary_supers[my_depth] = this;
|
||||
super_check_cell = &_primary_supers[my_depth];
|
||||
} else {
|
||||
// Overflow of the primary_supers array forces me to be secondary.
|
||||
super_check_cell = &_secondary_super_cache;
|
||||
}
|
||||
set_super_check_offset((address)super_check_cell - (address) this->as_klassOop());
|
||||
set_super_check_offset((address)super_check_cell - (address) this);
|
||||
|
||||
#ifdef ASSERT
|
||||
{
|
||||
juint j = super_depth();
|
||||
assert(j == my_depth, "computed accessor gets right answer");
|
||||
klassOop t = as_klassOop();
|
||||
Klass* t = this;
|
||||
while (!Klass::cast(t)->can_be_primary_super()) {
|
||||
t = Klass::cast(t)->super();
|
||||
j = Klass::cast(t)->super_depth();
|
||||
|
@ -282,18 +267,23 @@ void Klass::initialize_supers(klassOop k, TRAPS) {
|
|||
// Secondaries can occasionally be on the super chain,
|
||||
// if the inline "_primary_supers" array overflows.
|
||||
int extras = 0;
|
||||
klassOop p;
|
||||
for (p = super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) {
|
||||
Klass* p;
|
||||
for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
|
||||
++extras;
|
||||
}
|
||||
|
||||
// Compute the "real" non-extra secondaries.
|
||||
objArrayOop secondary_oops = compute_secondary_supers(extras, CHECK);
|
||||
objArrayHandle secondaries (THREAD, secondary_oops);
|
||||
ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
|
||||
|
||||
// Store the extra secondaries in the first array positions:
|
||||
int fillp = extras;
|
||||
for (p = this_kh->super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) {
|
||||
// Compute the "real" non-extra secondaries.
|
||||
GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
|
||||
if (secondaries == NULL) {
|
||||
// secondary_supers set by compute_secondary_supers
|
||||
return;
|
||||
}
|
||||
|
||||
GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
|
||||
|
||||
for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
|
||||
int i; // Scan for overflow primaries being duplicates of 2nd'arys
|
||||
|
||||
// This happens frequently for very deeply nested arrays: the
|
||||
|
@ -303,39 +293,42 @@ void Klass::initialize_supers(klassOop k, TRAPS) {
|
|||
// secondary list already contains some primary overflows, they
|
||||
// (with the extra level of array-ness) will collide with the
|
||||
// normal primary superclass overflows.
|
||||
for( i = extras; i < secondaries->length(); i++ )
|
||||
if( secondaries->obj_at(i) == p )
|
||||
for( i = 0; i < secondaries->length(); i++ ) {
|
||||
if( secondaries->at(i) == p )
|
||||
break;
|
||||
}
|
||||
if( i < secondaries->length() )
|
||||
continue; // It's a dup, don't put it in
|
||||
secondaries->obj_at_put(--fillp, p);
|
||||
primaries->push(p);
|
||||
}
|
||||
// See if we had some dup's, so the array has holes in it.
|
||||
if( fillp > 0 ) {
|
||||
// Pack the array. Drop the old secondaries array on the floor
|
||||
// and let GC reclaim it.
|
||||
objArrayOop s2 = oopFactory::new_system_objArray(secondaries->length() - fillp, CHECK);
|
||||
for( int i = 0; i < s2->length(); i++ )
|
||||
s2->obj_at_put( i, secondaries->obj_at(i+fillp) );
|
||||
secondaries = objArrayHandle(THREAD, s2);
|
||||
// Combine the two arrays into a metadata object to pack the array.
|
||||
// The primaries are added in the reverse order, then the secondaries.
|
||||
int new_length = primaries->length() + secondaries->length();
|
||||
Array<Klass*>* s2 = MetadataFactory::new_array<Klass*>(
|
||||
class_loader_data(), new_length, CHECK);
|
||||
int fill_p = primaries->length();
|
||||
for (int j = 0; j < fill_p; j++) {
|
||||
s2->at_put(j, primaries->pop()); // add primaries in reverse order.
|
||||
}
|
||||
for( int j = 0; j < secondaries->length(); j++ ) {
|
||||
s2->at_put(j+fill_p, secondaries->at(j)); // add secondaries on the end.
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
if (secondaries() != Universe::the_array_interfaces_array()) {
|
||||
// We must not copy any NULL placeholders left over from bootstrap.
|
||||
for (int j = 0; j < secondaries->length(); j++) {
|
||||
assert(secondaries->obj_at(j) != NULL, "correct bootstrapping order");
|
||||
}
|
||||
for (int j = 0; j < s2->length(); j++) {
|
||||
assert(s2->at(j) != NULL, "correct bootstrapping order");
|
||||
}
|
||||
#endif
|
||||
|
||||
this_kh->set_secondary_supers(secondaries());
|
||||
this_kh->set_secondary_supers(s2);
|
||||
}
|
||||
}
|
||||
|
||||
objArrayOop Klass::compute_secondary_supers(int num_extra_slots, TRAPS) {
|
||||
GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
|
||||
assert(num_extra_slots == 0, "override for complex klasses");
|
||||
return Universe::the_empty_system_obj_array();
|
||||
set_secondary_supers(Universe::the_empty_klass_array());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -343,48 +336,48 @@ Klass* Klass::subklass() const {
|
|||
return _subklass == NULL ? NULL : Klass::cast(_subklass);
|
||||
}
|
||||
|
||||
instanceKlass* Klass::superklass() const {
|
||||
assert(super() == NULL || super()->klass_part()->oop_is_instance(), "must be instance klass");
|
||||
return _super == NULL ? NULL : instanceKlass::cast(_super);
|
||||
InstanceKlass* Klass::superklass() const {
|
||||
assert(super() == NULL || super()->oop_is_instance(), "must be instance klass");
|
||||
return _super == NULL ? NULL : InstanceKlass::cast(_super);
|
||||
}
|
||||
|
||||
Klass* Klass::next_sibling() const {
|
||||
return _next_sibling == NULL ? NULL : Klass::cast(_next_sibling);
|
||||
}
|
||||
|
||||
void Klass::set_subklass(klassOop s) {
|
||||
assert(s != as_klassOop(), "sanity check");
|
||||
oop_store_without_check((oop*)&_subklass, s);
|
||||
void Klass::set_subklass(Klass* s) {
|
||||
assert(s != this, "sanity check");
|
||||
_subklass = s;
|
||||
}
|
||||
|
||||
void Klass::set_next_sibling(klassOop s) {
|
||||
assert(s != as_klassOop(), "sanity check");
|
||||
oop_store_without_check((oop*)&_next_sibling, s);
|
||||
void Klass::set_next_sibling(Klass* s) {
|
||||
assert(s != this, "sanity check");
|
||||
_next_sibling = s;
|
||||
}
|
||||
|
||||
void Klass::append_to_sibling_list() {
|
||||
debug_only(if (!SharedSkipVerify) as_klassOop()->verify();)
|
||||
debug_only(if (!SharedSkipVerify) verify();)
|
||||
// add ourselves to superklass' subklass list
|
||||
instanceKlass* super = superklass();
|
||||
InstanceKlass* super = superklass();
|
||||
if (super == NULL) return; // special case: class Object
|
||||
assert(SharedSkipVerify ||
|
||||
(!super->is_interface() // interfaces cannot be supers
|
||||
&& (super->superklass() == NULL || !is_interface())),
|
||||
"an interface can only be a subklass of Object");
|
||||
klassOop prev_first_subklass = super->subklass_oop();
|
||||
Klass* prev_first_subklass = super->subklass_oop();
|
||||
if (prev_first_subklass != NULL) {
|
||||
// set our sibling to be the superklass' previous first subklass
|
||||
set_next_sibling(prev_first_subklass);
|
||||
}
|
||||
// make ourselves the superklass' first subklass
|
||||
super->set_subklass(as_klassOop());
|
||||
debug_only(if (!SharedSkipVerify) as_klassOop()->verify();)
|
||||
super->set_subklass(this);
|
||||
debug_only(if (!SharedSkipVerify) verify();)
|
||||
}
|
||||
|
||||
void Klass::remove_from_sibling_list() {
|
||||
// remove receiver from sibling list
|
||||
instanceKlass* super = superklass();
|
||||
assert(super != NULL || as_klassOop() == SystemDictionary::Object_klass(), "should have super");
|
||||
InstanceKlass* super = superklass();
|
||||
assert(super != NULL || this == SystemDictionary::Object_klass(), "should have super");
|
||||
if (super == NULL) return; // special case: class Object
|
||||
if (super->subklass() == this) {
|
||||
// first subklass
|
||||
|
@ -398,80 +391,131 @@ void Klass::remove_from_sibling_list() {
|
|||
}
|
||||
}
|
||||
|
||||
void Klass::follow_weak_klass_links( BoolObjectClosure* is_alive, OopClosure* keep_alive) {
|
||||
// This klass is alive but the subklass and siblings are not followed/updated.
|
||||
// We update the subklass link and the subklass' sibling links here.
|
||||
// Our own sibling link will be updated by our superclass (which must be alive
|
||||
// since we are).
|
||||
assert(is_alive->do_object_b(as_klassOop()), "just checking, this should be live");
|
||||
if (ClassUnloading) {
|
||||
klassOop sub = subklass_oop();
|
||||
if (sub != NULL && !is_alive->do_object_b(sub)) {
|
||||
// first subklass not alive, find first one alive
|
||||
do {
|
||||
bool Klass::is_loader_alive(BoolObjectClosure* is_alive) {
|
||||
assert(is_metadata(), "p is not meta-data");
|
||||
assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace");
|
||||
// The class is alive iff the class loader is alive.
|
||||
oop loader = class_loader();
|
||||
return (loader == NULL) || is_alive->do_object_b(loader);
|
||||
}
|
||||
|
||||
void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive) {
|
||||
if (!ClassUnloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
Klass* root = SystemDictionary::Object_klass();
|
||||
Stack<Klass*, mtGC> stack;
|
||||
|
||||
stack.push(root);
|
||||
while (!stack.is_empty()) {
|
||||
Klass* current = stack.pop();
|
||||
|
||||
assert(current->is_loader_alive(is_alive), "just checking, this should be live");
|
||||
|
||||
// Find and set the first alive subklass
|
||||
Klass* sub = current->subklass_oop();
|
||||
while (sub != NULL && !sub->is_loader_alive(is_alive)) {
|
||||
#ifndef PRODUCT
|
||||
if (TraceClassUnloading && WizardMode) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("[Unlinking class (subclass) %s]", sub->klass_part()->external_name());
|
||||
tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name());
|
||||
}
|
||||
#endif
|
||||
sub = sub->klass_part()->next_sibling_oop();
|
||||
} while (sub != NULL && !is_alive->do_object_b(sub));
|
||||
set_subklass(sub);
|
||||
sub = sub->next_sibling_oop();
|
||||
}
|
||||
// now update the subklass' sibling list
|
||||
while (sub != NULL) {
|
||||
klassOop next = sub->klass_part()->next_sibling_oop();
|
||||
if (next != NULL && !is_alive->do_object_b(next)) {
|
||||
// first sibling not alive, find first one alive
|
||||
do {
|
||||
#ifndef PRODUCT
|
||||
current->set_subklass(sub);
|
||||
if (sub != NULL) {
|
||||
stack.push(sub);
|
||||
}
|
||||
|
||||
// Find and set the first alive sibling
|
||||
Klass* sibling = current->next_sibling_oop();
|
||||
while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
|
||||
if (TraceClassUnloading && WizardMode) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("[Unlinking class (sibling) %s]", next->klass_part()->external_name());
|
||||
tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name());
|
||||
}
|
||||
#endif
|
||||
next = next->klass_part()->next_sibling_oop();
|
||||
} while (next != NULL && !is_alive->do_object_b(next));
|
||||
sub->klass_part()->set_next_sibling(next);
|
||||
sibling = sibling->next_sibling_oop();
|
||||
}
|
||||
sub = next;
|
||||
current->set_next_sibling(sibling);
|
||||
if (sibling != NULL) {
|
||||
stack.push(sibling);
|
||||
}
|
||||
|
||||
// Clean the implementors list and method data.
|
||||
if (current->oop_is_instance()) {
|
||||
InstanceKlass* ik = InstanceKlass::cast(current);
|
||||
ik->clean_implementors_list(is_alive);
|
||||
ik->clean_method_data(is_alive);
|
||||
}
|
||||
} else {
|
||||
// Always follow subklass and sibling link. This will prevent any klasses from
|
||||
// being unloaded (all classes are transitively linked from java.lang.Object).
|
||||
keep_alive->do_oop(adr_subklass());
|
||||
keep_alive->do_oop(adr_next_sibling());
|
||||
}
|
||||
}
|
||||
|
||||
void Klass::klass_update_barrier_set(oop v) {
|
||||
record_modified_oops();
|
||||
}
|
||||
|
||||
void Klass::klass_update_barrier_set_pre(void* p, oop v) {
|
||||
// This barrier used by G1, where it's used remember the old oop values,
|
||||
// so that we don't forget any objects that were live at the snapshot at
|
||||
// the beginning. This function is only used when we write oops into
|
||||
// Klasses. Since the Klasses are used as roots in G1, we don't have to
|
||||
// do anything here.
|
||||
}
|
||||
|
||||
void Klass::klass_oop_store(oop* p, oop v) {
|
||||
assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
|
||||
assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
|
||||
|
||||
// do the store
|
||||
if (always_do_update_barrier) {
|
||||
klass_oop_store((volatile oop*)p, v);
|
||||
} else {
|
||||
klass_update_barrier_set_pre((void*)p, v);
|
||||
*p = v;
|
||||
klass_update_barrier_set(v);
|
||||
}
|
||||
}
|
||||
|
||||
void Klass::klass_oop_store(volatile oop* p, oop v) {
|
||||
assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
|
||||
assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
|
||||
|
||||
klass_update_barrier_set_pre((void*)p, v);
|
||||
OrderAccess::release_store_ptr(p, v);
|
||||
klass_update_barrier_set(v);
|
||||
}
|
||||
|
||||
void Klass::oops_do(OopClosure* cl) {
|
||||
cl->do_oop(&_java_mirror);
|
||||
}
|
||||
|
||||
void Klass::remove_unshareable_info() {
|
||||
if (oop_is_instance()) {
|
||||
instanceKlass* ik = (instanceKlass*)this;
|
||||
if (ik->is_linked()) {
|
||||
ik->unlink_class();
|
||||
}
|
||||
}
|
||||
// Clear the Java vtable if the oop has one.
|
||||
// The vtable isn't shareable because it's in the wrong order wrt the methods
|
||||
// once the method names get moved and resorted.
|
||||
klassVtable* vt = vtable();
|
||||
if (vt != NULL) {
|
||||
assert(oop_is_instance() || oop_is_array(), "nothing else has vtable");
|
||||
vt->clear_vtable();
|
||||
}
|
||||
set_subklass(NULL);
|
||||
set_next_sibling(NULL);
|
||||
// Clear the java mirror
|
||||
set_java_mirror(NULL);
|
||||
set_next_link(NULL);
|
||||
|
||||
// Null out class_loader_data because we don't share that yet.
|
||||
set_class_loader_data(NULL);
|
||||
}
|
||||
|
||||
void Klass::restore_unshareable_info(TRAPS) {
|
||||
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
||||
// Restore class_loader_data to the null class loader data
|
||||
set_class_loader_data(loader_data);
|
||||
|
||||
void Klass::shared_symbols_iterate(SymbolClosure* closure) {
|
||||
closure->do_symbol(&_name);
|
||||
// Add to null class loader list first before creating the mirror
|
||||
// (same order as class file parsing)
|
||||
loader_data->add_class(this);
|
||||
|
||||
// Recreate the class mirror
|
||||
java_lang_Class::create_mirror(this, CHECK);
|
||||
}
|
||||
|
||||
|
||||
klassOop Klass::array_klass_or_null(int rank) {
|
||||
Klass* Klass::array_klass_or_null(int rank) {
|
||||
EXCEPTION_MARK;
|
||||
// No exception can be thrown by array_klass_impl when called with or_null == true.
|
||||
// (In anycase, the execption mark will fail if it do so)
|
||||
|
@ -479,7 +523,7 @@ klassOop Klass::array_klass_or_null(int rank) {
|
|||
}
|
||||
|
||||
|
||||
klassOop Klass::array_klass_or_null() {
|
||||
Klass* Klass::array_klass_or_null() {
|
||||
EXCEPTION_MARK;
|
||||
// No exception can be thrown by array_klass_impl when called with or_null == true.
|
||||
// (In anycase, the execption mark will fail if it do so)
|
||||
|
@ -487,26 +531,28 @@ klassOop Klass::array_klass_or_null() {
|
|||
}
|
||||
|
||||
|
||||
klassOop Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
|
||||
fatal("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass");
|
||||
Klass* Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
|
||||
fatal("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
klassOop Klass::array_klass_impl(bool or_null, TRAPS) {
|
||||
fatal("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass");
|
||||
Klass* Klass::array_klass_impl(bool or_null, TRAPS) {
|
||||
fatal("array_klass should be dispatched to InstanceKlass, objArrayKlass or typeArrayKlass");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void Klass::with_array_klasses_do(void f(klassOop k)) {
|
||||
f(as_klassOop());
|
||||
void Klass::with_array_klasses_do(void f(Klass* k)) {
|
||||
f(this);
|
||||
}
|
||||
|
||||
|
||||
oop Klass::class_loader() const { return class_loader_data()->class_loader(); }
|
||||
|
||||
const char* Klass::external_name() const {
|
||||
if (oop_is_instance()) {
|
||||
instanceKlass* ik = (instanceKlass*) this;
|
||||
InstanceKlass* ik = (InstanceKlass*) this;
|
||||
if (ik->is_anonymous()) {
|
||||
assert(EnableInvokeDynamic, "");
|
||||
intptr_t hash = ik->java_mirror()->identity_hash();
|
||||
|
@ -547,8 +593,17 @@ jint Klass::jvmti_class_status() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Printing
|
||||
|
||||
void Klass::print_on(outputStream* st) const {
|
||||
ResourceMark rm;
|
||||
// print title
|
||||
st->print("%s", internal_name());
|
||||
print_address_on(st);
|
||||
st->cr();
|
||||
}
|
||||
|
||||
void Klass::oop_print_on(oop obj, outputStream* st) {
|
||||
ResourceMark rm;
|
||||
// print title
|
||||
|
@ -573,21 +628,52 @@ void Klass::oop_print_value_on(oop obj, outputStream* st) {
|
|||
obj->print_address_on(st);
|
||||
}
|
||||
|
||||
|
||||
// Verification
|
||||
|
||||
void Klass::verify_on(outputStream* st) {
|
||||
guarantee(!Universe::heap()->is_in_reserved(this), "Shouldn't be");
|
||||
guarantee(this->is_metadata(), "should be in metaspace");
|
||||
|
||||
assert(ClassLoaderDataGraph::contains((address)this), "Should be");
|
||||
|
||||
guarantee(this->is_klass(),"should be klass");
|
||||
|
||||
if (super() != NULL) {
|
||||
guarantee(super()->is_metadata(), "should be in metaspace");
|
||||
guarantee(super()->is_klass(), "should be klass");
|
||||
}
|
||||
if (secondary_super_cache() != NULL) {
|
||||
Klass* ko = secondary_super_cache();
|
||||
guarantee(ko->is_metadata(), "should be in metaspace");
|
||||
guarantee(ko->is_klass(), "should be klass");
|
||||
}
|
||||
for ( uint i = 0; i < primary_super_limit(); i++ ) {
|
||||
Klass* ko = _primary_supers[i];
|
||||
if (ko != NULL) {
|
||||
guarantee(ko->is_metadata(), "should be in metaspace");
|
||||
guarantee(ko->is_klass(), "should be klass");
|
||||
}
|
||||
}
|
||||
|
||||
if (java_mirror() != NULL) {
|
||||
guarantee(java_mirror()->is_oop(), "should be instance");
|
||||
}
|
||||
}
|
||||
|
||||
void Klass::oop_verify_on(oop obj, outputStream* st) {
|
||||
guarantee(obj->is_oop(), "should be oop");
|
||||
guarantee(obj->klass()->is_perm(), "should be in permspace");
|
||||
guarantee(obj->klass()->is_metadata(), "should not be in Java heap");
|
||||
guarantee(obj->klass()->is_klass(), "klass field is not a klass");
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
void Klass::verify_vtable_index(int i) {
|
||||
assert(oop_is_instance() || oop_is_array(), "only instanceKlass and arrayKlass have vtables");
|
||||
if (oop_is_instance()) {
|
||||
assert(i>=0 && i<((instanceKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds");
|
||||
assert(i>=0 && i<((InstanceKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds");
|
||||
} else {
|
||||
assert(oop_is_array(), "Must be");
|
||||
assert(i>=0 && i<((arrayKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue