2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2014-02-15 13:03:38 -05:00
|
|
|
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
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
2012-09-01 13:25:18 -04:00
|
|
|
#include "classfile/javaClasses.hpp"
|
|
|
|
#include "classfile/dictionary.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
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
2012-09-01 13:25:18 -04:00
|
|
|
#include "gc_implementation/shared/markSweep.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "gc_interface/collectedHeap.inline.hpp"
|
2013-01-25 15:06:18 -05:00
|
|
|
#include "memory/heapInspection.hpp"
|
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
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/metadataFactory.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "oops/instanceKlass.hpp"
|
|
|
|
#include "oops/klass.inline.hpp"
|
|
|
|
#include "oops/oop.inline2.hpp"
|
|
|
|
#include "runtime/atomic.hpp"
|
2013-06-10 11:30:51 +02:00
|
|
|
#include "trace/traceMacros.hpp"
|
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
2012-09-01 13:25:18 -04:00
|
|
|
#include "utilities/stack.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
|
|
|
#if INCLUDE_ALL_GCS
|
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
2012-09-01 13:25:18 -04:00
|
|
|
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
|
|
|
|
#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
|
|
|
|
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
void Klass::set_name(Symbol* n) {
|
|
|
|
_name = n;
|
|
|
|
if (_name != NULL) _name->increment_refcount();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-05-10 08:27:30 -07:00
|
|
|
bool Klass::is_subclass_of(const Klass* k) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Run up the super chain and check
|
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
2012-09-01 13:25:18 -04:00
|
|
|
if (this == k) return true;
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* t = const_cast<Klass*>(this)->super();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
while (t != NULL) {
|
|
|
|
if (t == k) return true;
|
2012-11-12 16:15:05 -05:00
|
|
|
t = t->super();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
bool Klass::search_secondary_supers(Klass* k) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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.
|
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
2012-09-01 13:25:18 -04:00
|
|
|
if (this == k)
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
// Scan the array-of-objects for a match
|
|
|
|
int cnt = secondary_supers()->length();
|
|
|
|
for (int i = 0; i < cnt; i++) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
if (secondary_supers()->at(i) == k) {
|
2007-12-01 00:00:00 +00:00
|
|
|
((Klass*)this)->set_secondary_super_cache(k);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return self, except for abstract classes with exactly 1
|
|
|
|
// implementor. Then return the 1 concrete implementation.
|
|
|
|
Klass *Klass::up_cast_abstract() {
|
|
|
|
Klass *r = this;
|
|
|
|
while( r->is_abstract() ) { // Receiver is abstract?
|
|
|
|
Klass *s = r->subklass(); // Check for exactly 1 subklass
|
|
|
|
if( !s || s->next_sibling() ) // Oops; wrong count; give up
|
|
|
|
return this; // Return 'this' as a no-progress flag
|
|
|
|
r = s; // Loop till find concrete class
|
|
|
|
}
|
|
|
|
return r; // Return the 1 concrete class
|
|
|
|
}
|
|
|
|
|
2009-02-27 13:27:09 -08:00
|
|
|
// Find LCA in class hierarchy
|
2007-12-01 00:00:00 +00:00
|
|
|
Klass *Klass::LCA( Klass *k2 ) {
|
|
|
|
Klass *k1 = this;
|
|
|
|
while( 1 ) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
if( k1->is_subtype_of(k2) ) return k2;
|
|
|
|
if( k2->is_subtype_of(k1) ) return k1;
|
|
|
|
k1 = k1->super();
|
|
|
|
k2 = k2->super();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Klass::check_valid_for_instantiation(bool throwError, TRAPS) {
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError()
|
|
|
|
: vmSymbols::java_lang_InstantiationException(), external_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Klass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
|
|
|
|
THROW(vmSymbols::java_lang_ArrayStoreException());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Klass::initialize(TRAPS) {
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
bool Klass::compute_is_subtype_of(Klass* k) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(k->is_klass(), "argument must be a class");
|
|
|
|
return is_subclass_of(k);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-14 14:27:45 -04:00
|
|
|
Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
|
|
|
tty->print_cr("Error: uncached_lookup_method called on a klass oop."
|
|
|
|
" Likely error: reflection method does not correctly"
|
|
|
|
" wrap return value in a mirror object.");
|
|
|
|
#endif
|
|
|
|
ShouldNotReachHere();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-29 18:56:29 -04:00
|
|
|
void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
return Metaspace::allocate(loader_data, word_size, /*read_only*/false,
|
2013-05-28 16:36:19 -07:00
|
|
|
MetaspaceObj::ClassType, CHECK_NULL);
|
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
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Klass::Klass() {
|
|
|
|
Klass* k = this;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-03-08 11:47:57 -05:00
|
|
|
// Preinitialize supertype information.
|
|
|
|
// A later call to initialize_supers() may update these settings:
|
|
|
|
set_super(NULL);
|
|
|
|
for (juint i = 0; i < Klass::primary_super_limit(); i++) {
|
|
|
|
_primary_supers[i] = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-03-08 11:47:57 -05:00
|
|
|
set_secondary_supers(NULL);
|
|
|
|
set_secondary_super_cache(NULL);
|
|
|
|
_primary_supers[0] = k;
|
|
|
|
set_super_check_offset(in_bytes(primary_supers_offset()));
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
set_java_mirror(NULL);
|
|
|
|
set_modifier_flags(0);
|
|
|
|
set_layout_helper(Klass::_lh_neutral_value);
|
|
|
|
set_name(NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
AccessFlags af;
|
|
|
|
af.set_flags(0);
|
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
2012-09-01 13:25:18 -04:00
|
|
|
set_access_flags(af);
|
|
|
|
set_subklass(NULL);
|
|
|
|
set_next_sibling(NULL);
|
|
|
|
set_next_link(NULL);
|
2013-06-10 11:30:51 +02:00
|
|
|
TRACE_INIT_ID(this);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
set_prototype_header(markOopDesc::prototype());
|
|
|
|
set_biased_lock_revocation_count(0);
|
|
|
|
set_last_biased_lock_bulk_revocation_time(0);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
// The klass doesn't have any references at this point.
|
|
|
|
clear_modified_oops();
|
|
|
|
clear_accumulated_modified_oops();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
jint Klass::array_layout_helper(BasicType etype) {
|
|
|
|
assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
|
|
|
|
// Note that T_ARRAY is not allowed here.
|
|
|
|
int hsize = arrayOopDesc::base_offset_in_bytes(etype);
|
2008-02-25 15:05:44 -08:00
|
|
|
int esize = type2aelembytes(etype);
|
2007-12-01 00:00:00 +00:00
|
|
|
bool isobj = (etype == T_OBJECT);
|
|
|
|
int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
|
|
|
|
int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
|
|
|
|
|
|
|
|
assert(lh < (int)_lh_neutral_value, "must look like an array layout");
|
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
2012-09-01 13:25:18 -04:00
|
|
|
assert(layout_helper_is_array(lh), "correct kind");
|
2007-12-01 00:00:00 +00:00
|
|
|
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");
|
|
|
|
assert(layout_helper_element_type(lh) == etype, "correct decode");
|
|
|
|
assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
|
|
|
|
|
|
|
|
return lh;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Klass::can_be_primary_super_slow() const {
|
|
|
|
if (super() == NULL)
|
|
|
|
return true;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
else if (super()->super_depth() >= primary_super_limit()-1)
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
void Klass::initialize_supers(Klass* k, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (FastSuperclassLimit == 0) {
|
|
|
|
// None of the other machinery matters.
|
|
|
|
set_super(k);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (k == NULL) {
|
|
|
|
set_super(NULL);
|
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
2012-09-01 13:25:18 -04:00
|
|
|
_primary_supers[0] = this;
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(super_depth() == 0, "Object must already be initialized properly");
|
2010-01-06 14:22:39 -08:00
|
|
|
} else if (k != super() || k == SystemDictionary::Object_klass()) {
|
|
|
|
assert(super() == NULL || super() == SystemDictionary::Object_klass(),
|
2007-12-01 00:00:00 +00:00
|
|
|
"initialize this only once to a non-trivial value");
|
|
|
|
set_super(k);
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* sup = k;
|
2007-12-01 00:00:00 +00:00
|
|
|
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++) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
_primary_supers[i] = sup->_primary_supers[i];
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* *super_check_cell;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (my_depth < primary_super_limit()) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
_primary_supers[my_depth] = this;
|
2007-12-01 00:00:00 +00:00
|
|
|
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;
|
|
|
|
}
|
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
2012-09-01 13:25:18 -04:00
|
|
|
set_super_check_offset((address)super_check_cell - (address) this);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
{
|
|
|
|
juint j = super_depth();
|
|
|
|
assert(j == my_depth, "computed accessor gets right answer");
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* t = this;
|
2012-11-12 16:15:05 -05:00
|
|
|
while (!t->can_be_primary_super()) {
|
|
|
|
t = t->super();
|
|
|
|
j = t->super_depth();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
|
|
|
|
assert(primary_super_of_depth(j1) == NULL, "super list padding");
|
|
|
|
}
|
|
|
|
while (t != NULL) {
|
|
|
|
assert(primary_super_of_depth(j) == t, "super list initialization");
|
2012-11-12 16:15:05 -05:00
|
|
|
t = t->super();
|
2007-12-01 00:00:00 +00:00
|
|
|
--j;
|
|
|
|
}
|
|
|
|
assert(j == (juint)-1, "correct depth count");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secondary_supers() == NULL) {
|
|
|
|
KlassHandle this_kh (THREAD, this);
|
|
|
|
|
|
|
|
// Now compute the list of secondary supertypes.
|
|
|
|
// Secondaries can occasionally be on the super chain,
|
|
|
|
// if the inline "_primary_supers" array overflows.
|
|
|
|
int extras = 0;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* p;
|
|
|
|
for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
++extras;
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Compute the "real" non-extra secondaries.
|
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
2012-09-01 13:25:18 -04:00
|
|
|
GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
|
|
|
|
if (secondaries == NULL) {
|
|
|
|
// secondary_supers set by compute_secondary_supers
|
|
|
|
return;
|
|
|
|
}
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
|
|
|
|
|
|
|
|
for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int i; // Scan for overflow primaries being duplicates of 2nd'arys
|
|
|
|
|
|
|
|
// This happens frequently for very deeply nested arrays: the
|
|
|
|
// primary superclass chain overflows into the secondary. The
|
|
|
|
// secondary list contains the element_klass's secondaries with
|
|
|
|
// an extra array dimension added. If the element_klass's
|
|
|
|
// secondary list already contains some primary overflows, they
|
|
|
|
// (with the extra level of array-ness) will collide with the
|
|
|
|
// normal primary superclass overflows.
|
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
2012-09-01 13:25:18 -04:00
|
|
|
for( i = 0; i < secondaries->length(); i++ ) {
|
|
|
|
if( secondaries->at(i) == p )
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if( i < secondaries->length() )
|
|
|
|
continue; // It's a dup, don't put it in
|
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
2012-09-01 13:25:18 -04:00
|
|
|
primaries->push(p);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
// 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.
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
// We must not copy any NULL placeholders left over from bootstrap.
|
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
2012-09-01 13:25:18 -04:00
|
|
|
for (int j = 0; j < s2->length(); j++) {
|
|
|
|
assert(s2->at(j) != NULL, "correct bootstrapping order");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
this_kh->set_secondary_supers(s2);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(num_extra_slots == 0, "override for complex klasses");
|
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
2012-09-01 13:25:18 -04:00
|
|
|
set_secondary_supers(Universe::the_empty_klass_array());
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass* Klass::superklass() const {
|
|
|
|
assert(super() == NULL || super()->oop_is_instance(), "must be instance klass");
|
|
|
|
return _super == NULL ? NULL : InstanceKlass::cast(_super);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
void Klass::set_subklass(Klass* s) {
|
|
|
|
assert(s != this, "sanity check");
|
|
|
|
_subklass = s;
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
void Klass::set_next_sibling(Klass* s) {
|
|
|
|
assert(s != this, "sanity check");
|
|
|
|
_next_sibling = s;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Klass::append_to_sibling_list() {
|
2012-10-10 17:04:33 -04:00
|
|
|
debug_only(verify();)
|
2007-12-01 00:00:00 +00:00
|
|
|
// add ourselves to superklass' subklass list
|
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
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass* super = superklass();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (super == NULL) return; // special case: class Object
|
2012-10-10 17:04:33 -04:00
|
|
|
assert((!super->is_interface() // interfaces cannot be supers
|
2007-12-01 00:00:00 +00:00
|
|
|
&& (super->superklass() == NULL || !is_interface())),
|
|
|
|
"an interface can only be a subklass of Object");
|
2014-03-26 21:47:45 -04:00
|
|
|
Klass* prev_first_subklass = super->subklass();
|
2007-12-01 00:00:00 +00:00
|
|
|
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
|
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
2012-09-01 13:25:18 -04:00
|
|
|
super->set_subklass(this);
|
2012-10-10 17:04:33 -04:00
|
|
|
debug_only(verify();)
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
bool Klass::is_loader_alive(BoolObjectClosure* is_alive) {
|
2012-11-29 16:50:29 -05:00
|
|
|
#ifdef ASSERT
|
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
2012-09-01 13:25:18 -04:00
|
|
|
// The class is alive iff the class loader is alive.
|
|
|
|
oop loader = class_loader();
|
2012-11-29 16:50:29 -05:00
|
|
|
bool loader_alive = (loader == NULL) || is_alive->do_object_b(loader);
|
|
|
|
#endif // ASSERT
|
|
|
|
|
|
|
|
// The class is alive if it's mirror is alive (which should be marked if the
|
|
|
|
// loader is alive) unless it's an anoymous class.
|
|
|
|
bool mirror_alive = is_alive->do_object_b(java_mirror());
|
|
|
|
assert(!mirror_alive || loader_alive, "loader must be alive if the mirror is"
|
|
|
|
" but not the other way around with anonymous classes");
|
|
|
|
return mirror_alive;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2014-03-26 21:47:45 -04:00
|
|
|
Klass* sub = current->subklass();
|
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
2012-09-01 13:25:18 -04:00
|
|
|
while (sub != NULL && !sub->is_loader_alive(is_alive)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef PRODUCT
|
2012-11-29 16:50:29 -05:00
|
|
|
if (TraceClassUnloading && WizardMode) {
|
|
|
|
ResourceMark rm;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name());
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
2014-03-26 21:47:45 -04:00
|
|
|
sub = sub->next_sibling();
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
current->set_subklass(sub);
|
|
|
|
if (sub != NULL) {
|
|
|
|
stack.push(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find and set the first alive sibling
|
2014-03-26 21:47:45 -04:00
|
|
|
Klass* sibling = current->next_sibling();
|
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
2012-09-01 13:25:18 -04:00
|
|
|
while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
|
2012-11-29 16:50:29 -05:00
|
|
|
if (TraceClassUnloading && WizardMode) {
|
|
|
|
ResourceMark rm;
|
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
2012-09-01 13:25:18 -04:00
|
|
|
tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-03-26 21:47:45 -04:00
|
|
|
sibling = sibling->next_sibling();
|
2012-11-29 16:50:29 -05: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
2012-09-01 13:25:18 -04:00
|
|
|
current->set_next_sibling(sibling);
|
|
|
|
if (sibling != NULL) {
|
|
|
|
stack.push(sibling);
|
2012-11-29 16:50:29 -05: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
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// 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);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
klass_update_barrier_set_pre((void*)p, v);
|
|
|
|
*p = v;
|
|
|
|
klass_update_barrier_set(v);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
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);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void Klass::remove_unshareable_info() {
|
2014-04-08 13:58:38 -04:00
|
|
|
assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
set_subklass(NULL);
|
|
|
|
set_next_sibling(NULL);
|
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
2012-09-01 13:25:18 -04:00
|
|
|
// 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);
|
2007-12-01 00:00:00 +00: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
2012-09-01 13:25:18 -04:00
|
|
|
void Klass::restore_unshareable_info(TRAPS) {
|
2014-04-25 10:08:04 +02:00
|
|
|
TRACE_INIT_ID(this);
|
2014-04-08 13:58:38 -04:00
|
|
|
// If an exception happened during CDS restore, some of these fields may already be
|
|
|
|
// set. We leave the class on the CLD list, even if incomplete so that we don't
|
|
|
|
// modify the CLD list outside a safepoint.
|
|
|
|
if (class_loader_data() == NULL) {
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Add to null class loader list first before creating the mirror
|
|
|
|
// (same order as class file parsing)
|
|
|
|
loader_data->add_class(this);
|
|
|
|
}
|
2011-01-27 16:11:27 -08:00
|
|
|
|
2013-05-22 14:37:49 -04:00
|
|
|
// Recreate the class mirror. The protection_domain is always null for
|
|
|
|
// boot loader, for now.
|
2014-04-08 13:58:38 -04:00
|
|
|
// Only recreate it if not present. A previous attempt to restore may have
|
|
|
|
// gotten an OOM later but keep the mirror if it was created.
|
|
|
|
if (java_mirror() == NULL) {
|
|
|
|
java_lang_Class::create_mirror(this, Handle(NULL), CHECK);
|
|
|
|
}
|
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
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2011-01-27 16:11:27 -08: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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* Klass::array_klass_or_null(int rank) {
|
2007-12-01 00:00:00 +00:00
|
|
|
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)
|
|
|
|
return array_klass_impl(true, rank, THREAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* Klass::array_klass_or_null() {
|
2007-12-01 00:00:00 +00:00
|
|
|
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)
|
|
|
|
return array_klass_impl(true, THREAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
|
2012-09-29 06:40:00 -04:00
|
|
|
fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
Klass* Klass::array_klass_impl(bool or_null, TRAPS) {
|
2012-09-29 06:40:00 -04:00
|
|
|
fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
oop Klass::class_loader() const { return class_loader_data()->class_loader(); }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* Klass::external_name() const {
|
2008-11-12 22:33:26 -08:00
|
|
|
if (oop_is_instance()) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
InstanceKlass* ik = (InstanceKlass*) this;
|
2008-11-12 22:33:26 -08:00
|
|
|
if (ik->is_anonymous()) {
|
2012-11-29 16:50:29 -05:00
|
|
|
intptr_t hash = 0;
|
|
|
|
if (ik->java_mirror() != NULL) {
|
|
|
|
// java_mirror might not be created yet, return 0 as hash.
|
|
|
|
hash = ik->java_mirror()->identity_hash();
|
|
|
|
}
|
2008-11-12 22:33:26 -08:00
|
|
|
char hash_buf[40];
|
|
|
|
sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash);
|
|
|
|
size_t hash_len = strlen(hash_buf);
|
|
|
|
|
|
|
|
size_t result_len = name()->utf8_length();
|
|
|
|
char* result = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 1);
|
|
|
|
name()->as_klass_external_name(result, (int) result_len + 1);
|
|
|
|
assert(strlen(result) == result_len, "");
|
|
|
|
strcpy(result + result_len, hash_buf);
|
|
|
|
assert(strlen(result) == result_len + hash_len, "");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
2009-10-17 19:51:05 -07:00
|
|
|
if (name() == NULL) return "<unknown>";
|
2007-12-01 00:00:00 +00:00
|
|
|
return name()->as_klass_external_name();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-17 19:51:05 -07:00
|
|
|
const char* Klass::signature_name() const {
|
|
|
|
if (name() == NULL) return "<unknown>";
|
2007-12-01 00:00:00 +00:00
|
|
|
return name()->as_C_string();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unless overridden, modifier_flags is 0.
|
|
|
|
jint Klass::compute_modifier_flags(TRAPS) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Klass::atomic_incr_biased_lock_revocation_count() {
|
|
|
|
return (int) Atomic::add(1, &_biased_lock_revocation_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unless overridden, jvmti_class_status has no flags set.
|
|
|
|
jint Klass::jvmti_class_status() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Printing
|
|
|
|
|
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
2012-09-01 13:25:18 -04:00
|
|
|
void Klass::print_on(outputStream* st) const {
|
|
|
|
ResourceMark rm;
|
|
|
|
// print title
|
|
|
|
st->print("%s", internal_name());
|
|
|
|
print_address_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void Klass::oop_print_on(oop obj, outputStream* st) {
|
|
|
|
ResourceMark rm;
|
|
|
|
// print title
|
|
|
|
st->print_cr("%s ", internal_name());
|
|
|
|
obj->print_address_on(st);
|
|
|
|
|
|
|
|
if (WizardMode) {
|
|
|
|
// print header
|
|
|
|
obj->mark()->print_on(st);
|
|
|
|
}
|
|
|
|
|
|
|
|
// print class
|
|
|
|
st->print(" - klass: ");
|
|
|
|
obj->klass()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Klass::oop_print_value_on(oop obj, outputStream* st) {
|
|
|
|
// print title
|
|
|
|
ResourceMark rm; // Cannot print in debug mode without this
|
|
|
|
st->print("%s", internal_name());
|
|
|
|
obj->print_address_on(st);
|
|
|
|
}
|
|
|
|
|
2013-01-25 15:06:18 -05:00
|
|
|
#if INCLUDE_SERVICES
|
|
|
|
// Size Statistics
|
|
|
|
void Klass::collect_statistics(KlassSizeStats *sz) const {
|
|
|
|
sz->_klass_bytes = sz->count(this);
|
|
|
|
sz->_mirror_bytes = sz->count(java_mirror());
|
|
|
|
sz->_secondary_supers_bytes = sz->count_array(secondary_supers());
|
|
|
|
|
|
|
|
sz->_ro_bytes += sz->_secondary_supers_bytes;
|
|
|
|
sz->_rw_bytes += sz->_klass_bytes + sz->_mirror_bytes;
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_SERVICES
|
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
2012-09-01 13:25:18 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Verification
|
|
|
|
|
2014-02-15 13:03:38 -05:00
|
|
|
void Klass::verify_on(outputStream* st) {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
|
2013-06-24 18:55:46 -04:00
|
|
|
// This can be expensive, but it is worth checking that this klass is actually
|
|
|
|
// in the CLD graph but not in production.
|
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
2012-09-01 13:25:18 -04:00
|
|
|
assert(ClassLoaderDataGraph::contains((address)this), "Should be");
|
|
|
|
|
|
|
|
guarantee(this->is_klass(),"should be klass");
|
|
|
|
|
|
|
|
if (super() != NULL) {
|
|
|
|
guarantee(super()->is_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
if (secondary_super_cache() != NULL) {
|
|
|
|
Klass* ko = secondary_super_cache();
|
|
|
|
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_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (java_mirror() != NULL) {
|
|
|
|
guarantee(java_mirror()->is_oop(), "should be instance");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void Klass::oop_verify_on(oop obj, outputStream* st) {
|
|
|
|
guarantee(obj->is_oop(), "should be oop");
|
|
|
|
guarantee(obj->klass()->is_klass(), "klass field is not a klass");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2013-09-13 22:38:02 -04:00
|
|
|
bool Klass::verify_vtable_index(int i) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (oop_is_instance()) {
|
2013-09-13 22:38:02 -04:00
|
|
|
int limit = ((InstanceKlass*)this)->vtable_length()/vtableEntry::size();
|
|
|
|
assert(i >= 0 && i < limit, err_msg("index %d out of bounds %d", i, limit));
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
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
2012-09-01 13:25:18 -04:00
|
|
|
assert(oop_is_array(), "Must be");
|
2013-09-13 22:38:02 -04:00
|
|
|
int limit = ((ArrayKlass*)this)->vtable_length()/vtableEntry::size();
|
|
|
|
assert(i >= 0 && i < limit, err_msg("index %d out of bounds %d", i, limit));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-09-13 22:38:02 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Klass::verify_itable_index(int i) {
|
|
|
|
assert(oop_is_instance(), "");
|
|
|
|
int method_count = klassItable::method_count_for_interface(this);
|
|
|
|
assert(i >= 0 && i < method_count, "index out of bounds");
|
|
|
|
return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2014-02-27 10:36:50 +01:00
|
|
|
|
|
|
|
/////////////// Unit tests ///////////////
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
|
|
|
class TestKlass {
|
|
|
|
public:
|
|
|
|
static void test_oop_is_instanceClassLoader() {
|
|
|
|
assert(SystemDictionary::ClassLoader_klass()->oop_is_instanceClassLoader(), "assert");
|
|
|
|
assert(!SystemDictionary::String_klass()->oop_is_instanceClassLoader(), "assert");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestKlass_test() {
|
|
|
|
TestKlass::test_oop_is_instanceClassLoader();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|