2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-02-23 07:47:29 -05:00
|
|
|
* Copyright (c) 1997, 2018, 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"
|
2018-04-18 18:43:04 -04:00
|
|
|
#include "classfile/classLoaderData.inline.hpp"
|
2018-10-04 16:39:07 +02:00
|
|
|
#include "classfile/classLoaderDataGraph.inline.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/dictionary.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "classfile/javaClasses.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
2016-02-03 11:40:30 -05:00
|
|
|
#include "logging/log.hpp"
|
2013-01-25 15:06:18 -05:00
|
|
|
#include "memory/heapInspection.hpp"
|
2018-10-09 15:58:07 -04:00
|
|
|
#include "memory/heapShared.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"
|
2017-08-02 18:06:38 -07:00
|
|
|
#include "memory/metaspaceClosure.hpp"
|
|
|
|
#include "memory/metaspaceShared.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
2018-03-15 21:24:10 +01:00
|
|
|
#include "oops/compressedOops.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceKlass.hpp"
|
|
|
|
#include "oops/klass.inline.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "oops/oop.inline.hpp"
|
2018-04-18 10:39:40 -04:00
|
|
|
#include "oops/oopHandle.inline.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2018-03-14 12:12:00 +01:00
|
|
|
#include "runtime/handles.inline.hpp"
|
2018-06-06 10:45:40 -04:00
|
|
|
#include "runtime/orderAccess.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2015-03-25 10:08:09 +01:00
|
|
|
#include "utilities/stack.inline.hpp"
|
2017-10-03 16:42:04 -04:00
|
|
|
|
|
|
|
void Klass::set_java_mirror(Handle m) {
|
|
|
|
assert(!m.is_null(), "New mirror should never be null.");
|
|
|
|
assert(_java_mirror.resolve() == NULL, "should only be used to initialize mirror");
|
|
|
|
_java_mirror = class_loader_data()->add_handle(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop Klass::java_mirror() const {
|
|
|
|
return _java_mirror.resolve();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-11-20 10:08:19 +01:00
|
|
|
oop Klass::java_mirror_no_keepalive() const {
|
|
|
|
return _java_mirror.peek();
|
|
|
|
}
|
|
|
|
|
2015-12-18 20:23:28 +03:00
|
|
|
bool Klass::is_cloneable() const {
|
|
|
|
return _access_flags.is_cloneable_fast() ||
|
|
|
|
is_subtype_of(SystemDictionary::Cloneable_klass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Klass::set_is_cloneable() {
|
2018-01-18 22:17:11 -05:00
|
|
|
if (name() == vmSymbols::java_lang_invoke_MemberName()) {
|
2015-12-18 20:23:28 +03:00
|
|
|
assert(is_final(), "no subclasses allowed");
|
|
|
|
// MemberName cloning should not be intrinsified and always happen in JVM_Clone.
|
2018-01-18 22:17:11 -05:00
|
|
|
} else if (is_instance_klass() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {
|
|
|
|
// Reference cloning should not be intrinsified and always happen in JVM_Clone.
|
|
|
|
} else {
|
|
|
|
_access_flags.set_is_cloneable_fast();
|
2015-12-18 20:23:28 +03: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
|
2018-10-31 14:38:14 -04:00
|
|
|
if( !s || s->next_sibling() ) // Oops; wrong count; give up
|
2007-12-01 00:00:00 +00:00
|
|
|
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) {
|
2018-06-15 12:25:53 +02:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
assert(s != NULL, "Throw NPE!");
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(),
|
|
|
|
err_msg("arraycopy: source type %s is not an array", s->klass()->external_name()));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-05-07 19:38:22 +04:00
|
|
|
Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
|
|
|
|
#ifdef ASSERT
|
|
|
|
tty->print_cr("Error: find_field called on a klass oop."
|
|
|
|
" Likely error: reflection method does not correctly"
|
|
|
|
" wrap return value in a mirror object.");
|
|
|
|
#endif
|
|
|
|
ShouldNotReachHere();
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-06-23 01:32:41 -04:00
|
|
|
Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
|
|
|
|
OverpassLookupMode overpass_mode,
|
|
|
|
PrivateLookupMode private_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() {
|
2017-08-02 18:06:38 -07:00
|
|
|
return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, 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
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
// "Normal" instantiation is preceeded by a MetaspaceObj allocation
|
|
|
|
// which zeros out memory - calloc equivalent.
|
2017-03-03 23:08:35 -08:00
|
|
|
// The constructor is also used from CppVtableCloner,
|
2015-12-08 20:04:03 +01:00
|
|
|
// which doesn't zero out the memory before calling the constructor.
|
|
|
|
// Need to set the _java_mirror field explicitly to not hit an assert that the field
|
|
|
|
// should be NULL before setting it.
|
2018-05-26 06:59:49 +02:00
|
|
|
Klass::Klass(KlassID id) : _id(id),
|
2018-08-08 15:31:07 +02:00
|
|
|
_java_mirror(NULL),
|
2018-05-26 06:59:49 +02:00
|
|
|
_prototype_header(markOopDesc::prototype()),
|
2018-08-08 15:31:07 +02:00
|
|
|
_shared_class_path_index(-1) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CDS_ONLY(_shared_class_flags = 0;)
|
|
|
|
CDS_JAVA_HEAP_ONLY(_archived_mirror = 0;)
|
2015-12-08 20:04:03 +01:00
|
|
|
_primary_supers[0] = this;
|
2013-03-08 11:47:57 -05:00
|
|
|
set_super_check_offset(in_bytes(primary_supers_offset()));
|
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;
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:45:07 -07:00
|
|
|
void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, 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) {
|
|
|
|
|
|
|
|
// 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.
|
2018-05-02 09:26:10 -07:00
|
|
|
GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras, transitive_interfaces);
|
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 (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);
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
for (p = 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
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
set_secondary_supers(s2);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-02 09:26:10 -07:00
|
|
|
GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* transitive_interfaces) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(num_extra_slots == 0, "override for complex klasses");
|
2018-05-02 09:26:10 -07:00
|
|
|
assert(transitive_interfaces == NULL, "sanity");
|
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 {
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
|
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 _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
|
|
|
}
|
|
|
|
|
2018-06-24 21:46:11 -07:00
|
|
|
oop Klass::holder_phantom() const {
|
|
|
|
return class_loader_data()->holder_phantom();
|
|
|
|
}
|
|
|
|
|
2018-04-27 15:00:04 -04:00
|
|
|
void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses) {
|
|
|
|
if (!ClassUnloading || !unloading_occurred) {
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* root = SystemDictionary::Object_klass();
|
|
|
|
Stack<Klass*, mtGC> stack;
|
|
|
|
|
|
|
|
stack.push(root);
|
|
|
|
while (!stack.is_empty()) {
|
|
|
|
Klass* current = stack.pop();
|
|
|
|
|
2018-04-18 13:37:39 -04:00
|
|
|
assert(current->is_loader_alive(), "just checking, this should be live");
|
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
|
|
|
|
|
|
|
// Find and set the first alive subklass
|
2018-10-31 14:38:14 -04:00
|
|
|
Klass* sub = current->subklass();
|
|
|
|
while (sub != NULL && !sub->is_loader_alive()) {
|
|
|
|
#ifndef PRODUCT
|
|
|
|
if (log_is_enabled(Trace, class, unload)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, unload)("unlinking class (subclass): %s", sub->external_name());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sub = sub->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
|
|
|
current->set_subklass(sub);
|
|
|
|
if (sub != NULL) {
|
|
|
|
stack.push(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find and set the first alive sibling
|
2018-10-31 14:38:14 -04:00
|
|
|
Klass* sibling = current->next_sibling();
|
|
|
|
while (sibling != NULL && !sibling->is_loader_alive()) {
|
|
|
|
if (log_is_enabled(Trace, class, unload)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(class, unload)("[Unlinking class (sibling) %s]", sibling->external_name());
|
|
|
|
}
|
|
|
|
sibling = sibling->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
|
|
|
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.
|
2015-10-28 09:47:23 -04:00
|
|
|
if (clean_alive_klasses && current->is_instance_klass()) {
|
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::cast(current);
|
2018-04-18 13:37:39 -04:00
|
|
|
ik->clean_weak_instanceklass_links();
|
2016-08-31 12:10:40 -07:00
|
|
|
|
|
|
|
// JVMTI RedefineClasses creates previous versions that are not in
|
|
|
|
// the class hierarchy, so process them here.
|
|
|
|
while ((ik = ik->previous_versions()) != NULL) {
|
2018-04-18 13:37:39 -04:00
|
|
|
ik->clean_weak_instanceklass_links();
|
2016-08-31 12:10:40 -07:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-02 18:06:38 -07:00
|
|
|
void Klass::metaspace_pointers_do(MetaspaceClosure* it) {
|
|
|
|
if (log_is_enabled(Trace, cds)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(cds)("Iter(Klass): %p (%s)", this, external_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
it->push(&_name);
|
|
|
|
it->push(&_secondary_super_cache);
|
|
|
|
it->push(&_secondary_supers);
|
|
|
|
for (int i = 0; i < _primary_super_limit; i++) {
|
|
|
|
it->push(&_primary_supers[i]);
|
|
|
|
}
|
|
|
|
it->push(&_super);
|
|
|
|
it->push(&_subklass);
|
|
|
|
it->push(&_next_sibling);
|
|
|
|
it->push(&_next_link);
|
|
|
|
|
|
|
|
vtableEntry* vt = start_of_vtable();
|
|
|
|
for (int i=0; i<vtable_length(); i++) {
|
|
|
|
it->push(vt[i].method_addr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
2018-05-15 20:24:34 +02:00
|
|
|
JFR_ONLY(REMOVE_ID(this);)
|
2017-08-28 15:34:04 -07:00
|
|
|
if (log_is_enabled(Trace, cds, unshareable)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(cds, unshareable)("remove: %s", external_name());
|
|
|
|
}
|
2014-04-08 13:58:38 -04:00
|
|
|
|
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
|
|
|
set_next_link(NULL);
|
|
|
|
|
|
|
|
// Null out class_loader_data because we don't share that yet.
|
|
|
|
set_class_loader_data(NULL);
|
2017-04-14 08:33:57 -07:00
|
|
|
set_is_shared();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-08-28 15:34:04 -07:00
|
|
|
void Klass::remove_java_mirror() {
|
|
|
|
assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
|
|
|
|
if (log_is_enabled(Trace, cds, unshareable)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(cds, unshareable)("remove java_mirror: %s", external_name());
|
|
|
|
}
|
2017-10-03 16:42:04 -04:00
|
|
|
// Just null out the mirror. The class_loader_data() no longer exists.
|
|
|
|
_java_mirror = NULL;
|
2017-08-28 15:34:04 -07:00
|
|
|
}
|
|
|
|
|
2014-08-12 17:29:00 -07:00
|
|
|
void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
|
2017-03-03 23:08:35 -08:00
|
|
|
assert(is_klass(), "ensure C++ vtable is restored");
|
2017-04-14 08:33:57 -07:00
|
|
|
assert(is_shared(), "must be set");
|
2018-05-15 20:24:34 +02:00
|
|
|
JFR_ONLY(RESTORE_ID(this);)
|
2017-08-28 15:34:04 -07:00
|
|
|
if (log_is_enabled(Trace, cds, unshareable)) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_trace(cds, unshareable)("restore: %s", external_name());
|
|
|
|
}
|
2016-06-20 22:02:20 -07:00
|
|
|
|
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) {
|
|
|
|
// 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
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
Handle loader(THREAD, loader_data->class_loader());
|
|
|
|
ModuleEntry* module_entry = NULL;
|
|
|
|
Klass* k = this;
|
|
|
|
if (k->is_objArray_klass()) {
|
|
|
|
k = ObjArrayKlass::cast(k)->bottom_klass();
|
|
|
|
}
|
|
|
|
// Obtain klass' module.
|
|
|
|
if (k->is_instance_klass()) {
|
|
|
|
InstanceKlass* ik = (InstanceKlass*) k;
|
|
|
|
module_entry = ik->module();
|
|
|
|
} else {
|
|
|
|
module_entry = ModuleEntryTable::javabase_moduleEntry();
|
|
|
|
}
|
|
|
|
// Obtain java.lang.Module, if available
|
|
|
|
Handle module_handle(THREAD, ((module_entry != NULL) ? module_entry->module() : (oop)NULL));
|
|
|
|
|
|
|
|
if (this->has_raw_archived_mirror()) {
|
2018-06-12 18:12:59 -04:00
|
|
|
ResourceMark rm;
|
2018-03-02 17:25:55 -05:00
|
|
|
log_debug(cds, mirror)("%s has raw archived mirror", external_name());
|
2018-10-09 15:58:07 -04:00
|
|
|
if (HeapShared::open_archive_heap_region_mapped()) {
|
2018-06-12 18:12:59 -04:00
|
|
|
bool present = java_lang_Class::restore_archived_mirror(this, loader, module_handle,
|
|
|
|
protection_domain,
|
|
|
|
CHECK);
|
|
|
|
if (present) {
|
2018-03-02 17:25:55 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No archived mirror data
|
2018-06-12 18:12:59 -04:00
|
|
|
log_debug(cds, mirror)("No archived mirror data for %s", external_name());
|
2018-03-02 17:25:55 -05:00
|
|
|
_java_mirror = NULL;
|
|
|
|
this->clear_has_raw_archived_mirror();
|
|
|
|
}
|
|
|
|
|
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) {
|
2018-03-02 17:25:55 -05:00
|
|
|
log_trace(cds, mirror)("Recreate mirror for %s", external_name());
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
|
2014-04-08 13:58:38 -04: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
|
|
|
}
|
2011-01-27 16:11:27 -08:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS_JAVA_HEAP
|
|
|
|
// Used at CDS dump time to access the archived mirror. No GC barrier.
|
|
|
|
oop Klass::archived_java_mirror_raw() {
|
|
|
|
assert(has_raw_archived_mirror(), "must have raw archived mirror");
|
2018-03-15 21:24:10 +01:00
|
|
|
return CompressedOops::decode(_archived_mirror);
|
2018-03-02 17:25:55 -05:00
|
|
|
}
|
|
|
|
|
2018-08-14 09:59:37 -07:00
|
|
|
narrowOop Klass::archived_java_mirror_raw_narrow() {
|
|
|
|
assert(has_raw_archived_mirror(), "must have raw archived mirror");
|
|
|
|
return _archived_mirror;
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
// No GC barrier
|
|
|
|
void Klass::set_archived_java_mirror_raw(oop m) {
|
|
|
|
assert(DumpSharedSpaces, "called only during runtime");
|
2018-03-15 21:24:10 +01:00
|
|
|
_archived_mirror = CompressedOops::encode(m);
|
2018-03-02 17:25:55 -05:00
|
|
|
}
|
|
|
|
#endif // INCLUDE_CDS_JAVA_HEAP
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-10-05 20:03:14 +02:00
|
|
|
void Klass::check_array_allocation_length(int length, int max_length, TRAPS) {
|
|
|
|
if (length > max_length) {
|
|
|
|
if (!THREAD->in_retryable_allocation()) {
|
|
|
|
report_java_out_of_memory("Requested array size exceeds VM limit");
|
|
|
|
JvmtiExport::post_array_size_exhausted();
|
|
|
|
THROW_OOP(Universe::out_of_memory_error_array_size());
|
|
|
|
} else {
|
|
|
|
THROW_OOP(Universe::out_of_memory_error_retry());
|
|
|
|
}
|
|
|
|
} else if (length < 0) {
|
|
|
|
THROW_MSG(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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(); }
|
|
|
|
|
2015-10-26 13:11:36 -04:00
|
|
|
// In product mode, this function doesn't have virtual function calls so
|
|
|
|
// there might be some performance advantage to handling InstanceKlass here.
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* Klass::external_name() const {
|
2015-10-28 09:47:23 -04:00
|
|
|
if (is_instance_klass()) {
|
2015-10-26 13:11:36 -04:00
|
|
|
const InstanceKlass* ik = static_cast<const InstanceKlass*>(this);
|
2018-08-20 08:25:57 -04:00
|
|
|
if (ik->is_unsafe_anonymous()) {
|
2018-02-23 13:55:49 -08:00
|
|
|
char addr_buf[20];
|
|
|
|
jio_snprintf(addr_buf, 20, "/" INTPTR_FORMAT, p2i(ik));
|
|
|
|
size_t addr_len = strlen(addr_buf);
|
|
|
|
size_t name_len = name()->utf8_length();
|
|
|
|
char* result = NEW_RESOURCE_ARRAY(char, name_len + addr_len + 1);
|
|
|
|
name()->as_klass_external_name(result, (int) name_len + 1);
|
|
|
|
assert(strlen(result) == name_len, "");
|
|
|
|
strcpy(result + name_len, addr_buf);
|
|
|
|
assert(strlen(result) == name_len + addr_len, "");
|
2008-11-12 22:33:26 -08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2018-02-08 09:23:49 +01:00
|
|
|
const char* Klass::external_kind() const {
|
|
|
|
if (is_interface()) return "interface";
|
|
|
|
if (is_abstract()) return "abstract class";
|
|
|
|
return "class";
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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.
|
2014-05-15 18:23:26 -04:00
|
|
|
assert(Metaspace::contains((address)this), "Should be");
|
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
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-20 10:08:19 +01:00
|
|
|
if (java_mirror_no_keepalive() != NULL) {
|
|
|
|
guarantee(oopDesc::is_oop(java_mirror_no_keepalive()), "should be 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void Klass::oop_verify_on(oop obj, outputStream* st) {
|
2017-08-23 14:52:55 -04:00
|
|
|
guarantee(oopDesc::is_oop(obj), "should be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
guarantee(obj->klass()->is_klass(), "klass field is not a klass");
|
|
|
|
}
|
|
|
|
|
2018-10-04 16:39:07 +02:00
|
|
|
Klass* Klass::decode_klass_raw(narrowKlass narrow_klass) {
|
|
|
|
return (Klass*)(void*)( (uintptr_t)Universe::narrow_klass_base() +
|
|
|
|
((uintptr_t)narrow_klass << Universe::narrow_klass_shift()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Klass::is_valid(Klass* k) {
|
|
|
|
if (!is_aligned(k, sizeof(MetaWord))) return false;
|
|
|
|
if ((size_t)k < os::min_page_size()) return false;
|
|
|
|
|
|
|
|
if (!os::is_readable_range(k, k + 1)) return false;
|
|
|
|
if (!MetaspaceUtils::is_range_in_committed(k, k + 1)) return false;
|
|
|
|
|
|
|
|
if (!Symbol::is_valid(k->name())) return false;
|
|
|
|
return ClassLoaderDataGraph::is_valid(k->class_loader_data());
|
|
|
|
}
|
|
|
|
|
2017-04-13 01:56:01 -07:00
|
|
|
klassVtable Klass::vtable() const {
|
|
|
|
return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
|
2016-01-19 12:07:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
vtableEntry* Klass::start_of_vtable() const {
|
|
|
|
return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));
|
|
|
|
}
|
|
|
|
|
|
|
|
Method* Klass::method_at_vtable(int index) {
|
|
|
|
#ifndef PRODUCT
|
|
|
|
assert(index >= 0, "valid vtable index");
|
|
|
|
if (DebugVtables) {
|
|
|
|
verify_vtable_index(index);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return start_of_vtable()[index].method();
|
|
|
|
}
|
|
|
|
|
2015-12-01 10:35:49 +01:00
|
|
|
ByteSize Klass::vtable_start_offset() {
|
|
|
|
return in_ByteSize(InstanceKlass::header_size() * wordSize);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2013-09-13 22:38:02 -04:00
|
|
|
bool Klass::verify_vtable_index(int i) {
|
2015-10-26 13:11:36 -04:00
|
|
|
int limit = vtable_length()/vtableEntry::size();
|
|
|
|
assert(i >= 0 && i < limit, "index %d out of bounds %d", i, limit);
|
2013-09-13 22:38:02 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-23 07:47:29 -05:00
|
|
|
#endif // PRODUCT
|
|
|
|
|
2018-06-25 11:33:11 -04:00
|
|
|
// Caller needs ResourceMark
|
|
|
|
// joint_in_module_of_loader provides an optimization if 2 classes are in
|
|
|
|
// the same module to succinctly print out relevant information about their
|
|
|
|
// module name and class loader's name_and_id for error messages.
|
|
|
|
// Format:
|
|
|
|
// <fully-qualified-external-class-name1> and <fully-qualified-external-class-name2>
|
|
|
|
// are in module <module-name>[@<version>]
|
|
|
|
// of loader <loader-name_and_id>[, parent loader <parent-loader-name_and_id>]
|
|
|
|
const char* Klass::joint_in_module_of_loader(const Klass* class2, bool include_parent_loader) const {
|
|
|
|
assert(module() == class2->module(), "classes do not have the same module");
|
|
|
|
const char* class1_name = external_name();
|
|
|
|
size_t len = strlen(class1_name) + 1;
|
|
|
|
|
|
|
|
const char* class2_description = class2->class_in_module_of_loader(true, include_parent_loader);
|
|
|
|
len += strlen(class2_description);
|
|
|
|
|
|
|
|
len += strlen(" and ");
|
|
|
|
|
|
|
|
char* joint_description = NEW_RESOURCE_ARRAY_RETURN_NULL(char, len);
|
|
|
|
|
|
|
|
// Just return the FQN if error when allocating string
|
|
|
|
if (joint_description == NULL) {
|
|
|
|
return class1_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
jio_snprintf(joint_description, len, "%s and %s",
|
|
|
|
class1_name,
|
|
|
|
class2_description);
|
|
|
|
|
|
|
|
return joint_description;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Caller needs ResourceMark
|
|
|
|
// class_in_module_of_loader provides a standard way to include
|
|
|
|
// relevant information about a class, such as its module name as
|
|
|
|
// well as its class loader's name_and_id, in error messages and logging.
|
|
|
|
// Format:
|
|
|
|
// <fully-qualified-external-class-name> is in module <module-name>[@<version>]
|
|
|
|
// of loader <loader-name_and_id>[, parent loader <parent-loader-name_and_id>]
|
|
|
|
const char* Klass::class_in_module_of_loader(bool use_are, bool include_parent_loader) const {
|
|
|
|
// 1. fully qualified external name of class
|
|
|
|
const char* klass_name = external_name();
|
|
|
|
size_t len = strlen(klass_name) + 1;
|
|
|
|
|
|
|
|
// 2. module name + @version
|
2018-02-23 07:47:29 -05:00
|
|
|
const char* module_name = "";
|
|
|
|
const char* version = "";
|
2018-06-25 11:33:11 -04:00
|
|
|
bool has_version = false;
|
|
|
|
bool module_is_named = false;
|
|
|
|
const char* module_name_phrase = "";
|
2018-02-23 07:47:29 -05:00
|
|
|
const Klass* bottom_klass = is_objArray_klass() ?
|
2018-06-25 11:33:11 -04:00
|
|
|
ObjArrayKlass::cast(this)->bottom_klass() : this;
|
2018-02-23 07:47:29 -05:00
|
|
|
if (bottom_klass->is_instance_klass()) {
|
|
|
|
ModuleEntry* module = InstanceKlass::cast(bottom_klass)->module();
|
|
|
|
if (module->is_named()) {
|
2018-06-25 11:33:11 -04:00
|
|
|
module_is_named = true;
|
|
|
|
module_name_phrase = "module ";
|
2018-02-23 07:47:29 -05:00
|
|
|
module_name = module->name()->as_C_string();
|
2018-06-25 11:33:11 -04:00
|
|
|
len += strlen(module_name);
|
2018-02-23 07:47:29 -05:00
|
|
|
// Use version if exists and is not a jdk module
|
2018-06-14 10:33:54 -04:00
|
|
|
if (module->should_show_version()) {
|
2018-02-23 07:47:29 -05:00
|
|
|
has_version = true;
|
|
|
|
version = module->version()->as_C_string();
|
2018-06-25 11:33:11 -04:00
|
|
|
// Include stlen(version) + 1 for the "@"
|
|
|
|
len += strlen(version) + 1;
|
2018-02-23 07:47:29 -05:00
|
|
|
}
|
2018-06-25 11:33:11 -04:00
|
|
|
} else {
|
|
|
|
module_name = UNNAMED_MODULE;
|
|
|
|
len += UNNAMED_MODULE_LEN;
|
2018-02-23 07:47:29 -05:00
|
|
|
}
|
|
|
|
} else {
|
2018-06-25 11:33:11 -04:00
|
|
|
// klass is an array of primitives, module is java.base
|
|
|
|
module_is_named = true;
|
|
|
|
module_name_phrase = "module ";
|
2018-02-23 07:47:29 -05:00
|
|
|
module_name = JAVA_BASE_NAME;
|
2018-06-25 11:33:11 -04:00
|
|
|
len += JAVA_BASE_NAME_LEN;
|
2018-02-23 07:47:29 -05:00
|
|
|
}
|
|
|
|
|
2018-06-25 11:33:11 -04:00
|
|
|
// 3. class loader's name_and_id
|
|
|
|
ClassLoaderData* cld = class_loader_data();
|
|
|
|
assert(cld != NULL, "class_loader_data should not be null");
|
|
|
|
const char* loader_name_and_id = cld->loader_name_and_id();
|
|
|
|
len += strlen(loader_name_and_id);
|
|
|
|
|
|
|
|
// 4. include parent loader information
|
|
|
|
const char* parent_loader_phrase = "";
|
|
|
|
const char* parent_loader_name_and_id = "";
|
|
|
|
if (include_parent_loader &&
|
|
|
|
!cld->is_builtin_class_loader_data()) {
|
|
|
|
oop parent_loader = java_lang_ClassLoader::parent(class_loader());
|
2018-11-07 13:54:22 -05:00
|
|
|
ClassLoaderData *parent_cld = ClassLoaderData::class_loader_data_or_null(parent_loader);
|
|
|
|
// The parent loader's ClassLoaderData could be null if it is
|
|
|
|
// a delegating class loader that has never defined a class.
|
|
|
|
// In this case the loader's name must be obtained via the parent loader's oop.
|
|
|
|
if (parent_cld == NULL) {
|
|
|
|
oop cl_name_and_id = java_lang_ClassLoader::nameAndId(parent_loader);
|
|
|
|
if (cl_name_and_id != NULL) {
|
|
|
|
parent_loader_name_and_id = java_lang_String::as_utf8_string(cl_name_and_id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
parent_loader_name_and_id = parent_cld->loader_name_and_id();
|
|
|
|
}
|
2018-06-25 11:33:11 -04:00
|
|
|
parent_loader_phrase = ", parent loader ";
|
|
|
|
len += strlen(parent_loader_phrase) + strlen(parent_loader_name_and_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start to construct final full class description string
|
|
|
|
len += ((use_are) ? strlen(" are in ") : strlen(" is in "));
|
|
|
|
len += strlen(module_name_phrase) + strlen(" of loader ");
|
|
|
|
|
|
|
|
char* class_description = NEW_RESOURCE_ARRAY_RETURN_NULL(char, len);
|
|
|
|
|
|
|
|
// Just return the FQN if error when allocating string
|
|
|
|
if (class_description == NULL) {
|
|
|
|
return klass_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
jio_snprintf(class_description, len, "%s %s in %s%s%s%s of loader %s%s%s",
|
|
|
|
klass_name,
|
|
|
|
(use_are) ? "are" : "is",
|
|
|
|
module_name_phrase,
|
|
|
|
module_name,
|
2018-02-23 07:47:29 -05:00
|
|
|
(has_version) ? "@" : "",
|
|
|
|
(has_version) ? version : "",
|
2018-06-25 11:33:11 -04:00
|
|
|
loader_name_and_id,
|
|
|
|
parent_loader_phrase,
|
|
|
|
parent_loader_name_and_id);
|
|
|
|
|
|
|
|
return class_description;
|
2018-02-23 07:47:29 -05:00
|
|
|
}
|