2017-07-28 10:48:35 -04:00
|
|
|
/*
|
2017-02-15 22:59:57 -05:00
|
|
|
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
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
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// A ClassLoaderData identifies the full set of class types that a class
|
|
|
|
// loader's name resolution strategy produces for a given configuration of the
|
|
|
|
// class loader.
|
|
|
|
// Class types in the ClassLoaderData may be defined by from class file binaries
|
|
|
|
// provided by the class loader, or from other class loader it interacts with
|
|
|
|
// according to its name resolution strategy.
|
|
|
|
//
|
|
|
|
// Class loaders that implement a deterministic name resolution strategy
|
|
|
|
// (including with respect to their delegation behavior), such as the boot, the
|
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
|
|
|
// platform, and the system loaders of the JDK's built-in class loader
|
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
|
|
|
// hierarchy, always produce the same linkset for a given configuration.
|
|
|
|
//
|
|
|
|
// ClassLoaderData carries information related to a linkset (e.g.,
|
|
|
|
// metaspace holding its klass definitions).
|
|
|
|
// The System Dictionary and related data structures (e.g., placeholder table,
|
|
|
|
// loader constraints table) as well as the runtime representation of classes
|
|
|
|
// only reference ClassLoaderData.
|
|
|
|
//
|
|
|
|
// Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that
|
|
|
|
// that represent the loader's "linking domain" in the JVM.
|
|
|
|
//
|
|
|
|
// The bootstrap loader (represented by NULL) also has a ClassLoaderData,
|
|
|
|
// the singleton class the_null_class_loader_data().
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "classfile/classLoaderData.hpp"
|
|
|
|
#include "classfile/classLoaderData.inline.hpp"
|
2017-07-28 10:48:35 -04:00
|
|
|
#include "classfile/dictionary.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"
|
2013-01-23 10:34:29 -05:00
|
|
|
#include "classfile/metadataOnStackMark.hpp"
|
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
|
|
|
#include "classfile/moduleEntry.hpp"
|
|
|
|
#include "classfile/packageEntry.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/systemDictionary.hpp"
|
|
|
|
#include "code/codeCache.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/gcLocker.hpp"
|
2016-02-03 11:40:30 -05:00
|
|
|
#include "logging/log.hpp"
|
2017-07-21 09:50:12 +02:00
|
|
|
#include "logging/logStream.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"
|
|
|
|
#include "memory/metaspaceShared.hpp"
|
2013-01-23 10:34:29 -05:00
|
|
|
#include "memory/oopFactory.hpp"
|
2016-04-04 12:57:48 -04:00
|
|
|
#include "memory/resourceArea.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "oops/objArrayOop.inline.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2016-02-03 11:40:30 -05:00
|
|
|
#include "runtime/javaCalls.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 "runtime/jniHandles.hpp"
|
|
|
|
#include "runtime/mutex.hpp"
|
2016-06-02 23:37:09 -04:00
|
|
|
#include "runtime/orderAccess.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 "runtime/safepoint.hpp"
|
|
|
|
#include "runtime/synchronizer.hpp"
|
|
|
|
#include "utilities/growableArray.hpp"
|
2013-11-23 12:25:13 +01:00
|
|
|
#include "utilities/macros.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/ostream.hpp"
|
2017-08-30 07:18:02 -04:00
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
2013-06-10 11:30:51 +02:00
|
|
|
#if INCLUDE_TRACE
|
2014-11-19 16:08:01 +01:00
|
|
|
#include "trace/tracing.hpp"
|
2013-06-10 11:30:51 +02: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
|
|
|
ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
|
|
|
|
|
2013-04-24 19:55:02 +02:00
|
|
|
ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
|
2012-12-12 11:39:29 -05:00
|
|
|
_class_loader(h_class_loader()),
|
2014-02-21 10:19:09 +01:00
|
|
|
_is_anonymous(is_anonymous),
|
|
|
|
// An anonymous class loader data doesn't have anything to keep
|
|
|
|
// it from being unloaded during parsing of the anonymous class.
|
|
|
|
// The null-class-loader should always be kept alive.
|
2016-04-21 09:23:04 -04:00
|
|
|
_keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
|
2012-12-12 11:39:29 -05:00
|
|
|
_metaspace(NULL), _unloading(false), _klasses(NULL),
|
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
|
|
|
_modules(NULL), _packages(NULL),
|
2017-10-03 16:42:04 -04:00
|
|
|
_claimed(0), _modified_oops(true), _accumulated_modified_oops(false),
|
|
|
|
_jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
|
2016-12-15 19:26:41 -08:00
|
|
|
_next(NULL), _dependencies(dependencies),
|
2014-12-11 21:34:43 -05:00
|
|
|
_metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
|
|
|
|
Monitor::_safepoint_check_never)) {
|
2017-04-18 13:19:42 -04:00
|
|
|
|
|
|
|
// A ClassLoaderData created solely for an anonymous class should never have a
|
|
|
|
// ModuleEntryTable or PackageEntryTable created for it. The defining package
|
|
|
|
// and module for an anonymous class will be found in its host class.
|
|
|
|
if (!is_anonymous) {
|
2017-04-27 10:08:02 -04:00
|
|
|
_packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
|
2017-04-18 13:19:42 -04:00
|
|
|
if (h_class_loader.is_null()) {
|
|
|
|
// Create unnamed module for boot loader
|
|
|
|
_unnamed_module = ModuleEntry::create_boot_unnamed_module(this);
|
|
|
|
} else {
|
|
|
|
// Create unnamed module for all other loaders
|
|
|
|
_unnamed_module = ModuleEntry::create_unnamed_module(this);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_unnamed_module = NULL;
|
|
|
|
}
|
2017-07-28 10:48:35 -04:00
|
|
|
|
|
|
|
if (!is_anonymous) {
|
|
|
|
_dictionary = create_dictionary();
|
|
|
|
} else {
|
|
|
|
_dictionary = NULL;
|
|
|
|
}
|
2016-12-06 22:49:17 +01:00
|
|
|
TRACE_INIT_ID(this);
|
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
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
void ClassLoaderData::init_dependencies(TRAPS) {
|
2013-04-24 19:55:02 +02:00
|
|
|
assert(!Universe::is_fully_initialized(), "should only be called when initializing");
|
|
|
|
assert(is_the_null_class_loader_data(), "should only call this for the null class loader");
|
2013-04-10 13:27:35 +02:00
|
|
|
_dependencies.init(CHECK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderData::Dependencies::init(TRAPS) {
|
2012-11-29 16:50:29 -05:00
|
|
|
// Create empty dependencies array to add to. CMS requires this to be
|
|
|
|
// an oop so that it can track additions via card marks. We think.
|
2013-04-10 13:27:35 +02:00
|
|
|
_list_head = oopFactory::new_objectArray(2, CHECK);
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
|
|
|
|
2017-02-23 18:57:10 +01:00
|
|
|
ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() {
|
|
|
|
Chunk* c = _head;
|
|
|
|
while (c != NULL) {
|
|
|
|
Chunk* next = c->_next;
|
|
|
|
delete c;
|
|
|
|
c = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
oop* ClassLoaderData::ChunkedHandleList::add(oop o) {
|
|
|
|
if (_head == NULL || _head->_size == Chunk::CAPACITY) {
|
|
|
|
Chunk* next = new Chunk(_head);
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&_head, next);
|
2017-02-23 18:57:10 +01:00
|
|
|
}
|
|
|
|
oop* handle = &_head->_data[_head->_size];
|
|
|
|
*handle = o;
|
|
|
|
OrderAccess::release_store(&_head->_size, _head->_size + 1);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ClassLoaderData::ChunkedHandleList::oops_do_chunk(OopClosure* f, Chunk* c, const juint size) {
|
|
|
|
for (juint i = 0; i < size; i++) {
|
|
|
|
if (c->_data[i] != NULL) {
|
|
|
|
f->do_oop(&c->_data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderData::ChunkedHandleList::oops_do(OopClosure* f) {
|
2017-10-16 22:36:06 -04:00
|
|
|
Chunk* head = OrderAccess::load_acquire(&_head);
|
2017-02-23 18:57:10 +01:00
|
|
|
if (head != NULL) {
|
|
|
|
// Must be careful when reading size of head
|
|
|
|
oops_do_chunk(f, head, OrderAccess::load_acquire(&head->_size));
|
|
|
|
for (Chunk* c = head->_next; c != NULL; c = c->_next) {
|
|
|
|
oops_do_chunk(f, c, c->_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
class VerifyContainsOopClosure : public OopClosure {
|
|
|
|
oop* _target;
|
|
|
|
bool _found;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VerifyContainsOopClosure(oop* target) : _target(target), _found(false) {}
|
|
|
|
|
|
|
|
void do_oop(oop* p) {
|
|
|
|
if (p == _target) {
|
|
|
|
_found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_oop(narrowOop* p) {
|
|
|
|
// The ChunkedHandleList should not contain any narrowOop
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool found() const {
|
|
|
|
return _found;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool ClassLoaderData::ChunkedHandleList::contains(oop* p) {
|
|
|
|
VerifyContainsOopClosure cl(p);
|
|
|
|
oops_do(&cl);
|
|
|
|
return cl.found();
|
|
|
|
}
|
2017-10-03 16:42:04 -04:00
|
|
|
#endif // ASSERT
|
2017-02-23 18:57:10 +01: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 ClassLoaderData::claim() {
|
|
|
|
if (_claimed == 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
|
|
|
|
}
|
|
|
|
|
2016-04-21 09:23:04 -04:00
|
|
|
// Anonymous classes have their own ClassLoaderData that is marked to keep alive
|
|
|
|
// while the class is being parsed, and if the class appears on the module fixup list.
|
|
|
|
// Due to the uniqueness that no other class shares the anonymous class' name or
|
|
|
|
// ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while
|
|
|
|
// it is being defined, therefore _keep_alive is not volatile or atomic.
|
|
|
|
void ClassLoaderData::inc_keep_alive() {
|
2016-08-11 11:41:11 -04:00
|
|
|
if (is_anonymous()) {
|
|
|
|
assert(_keep_alive >= 0, "Invalid keep alive increment count");
|
|
|
|
_keep_alive++;
|
|
|
|
}
|
2016-04-21 09:23:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderData::dec_keep_alive() {
|
2016-08-11 11:41:11 -04:00
|
|
|
if (is_anonymous()) {
|
|
|
|
assert(_keep_alive > 0, "Invalid keep alive decrement count");
|
|
|
|
_keep_alive--;
|
|
|
|
}
|
2016-04-21 09:23:04 -04:00
|
|
|
}
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
void ClassLoaderData::oops_do(OopClosure* f, bool must_claim, bool clear_mod_oops) {
|
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 (must_claim && !claim()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
// Only clear modified_oops after the ClassLoaderData is claimed.
|
|
|
|
if (clear_mod_oops) {
|
|
|
|
clear_modified_oops();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
f->do_oop(&_class_loader);
|
2013-04-10 13:27:35 +02:00
|
|
|
_dependencies.oops_do(f);
|
2017-02-23 18:57:10 +01:00
|
|
|
_handles.oops_do(f);
|
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-04-10 13:27:35 +02:00
|
|
|
void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
|
|
|
|
f->do_oop((oop*)&_list_head);
|
|
|
|
}
|
|
|
|
|
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 ClassLoaderData::classes_do(KlassClosure* klass_closure) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
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_closure->do_klass(k);
|
2013-03-15 17:24:40 -04:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
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-10 11:30:51 +02:00
|
|
|
void ClassLoaderData::classes_do(void f(Klass * const)) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
2013-06-10 11:30:51 +02:00
|
|
|
f(k);
|
2016-12-06 22:49:17 +01:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
2013-06-10 11:30:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-31 10:35:06 +02:00
|
|
|
void ClassLoaderData::methods_do(void f(Method*)) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
2017-04-12 08:02:29 -04:00
|
|
|
if (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded()) {
|
2014-03-31 10:35:06 +02:00
|
|
|
InstanceKlass::cast(k)->methods_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-24 10:02:02 +02:00
|
|
|
void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
2013-10-24 10:02:02 +02:00
|
|
|
// Do not filter ArrayKlass oops here...
|
2015-10-28 09:47:23 -04:00
|
|
|
if (k->is_array_klass() || (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded())) {
|
2013-10-24 10:02:02 +02:00
|
|
|
klass_closure->do_klass(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
|
|
|
void ClassLoaderData::classes_do(void f(InstanceKlass*)) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
2015-10-28 09:47:23 -04:00
|
|
|
if (k->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
|
|
|
f(InstanceKlass::cast(k));
|
|
|
|
}
|
2013-03-15 17:24:40 -04:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void ClassLoaderData::modules_do(void f(ModuleEntry*)) {
|
2016-06-02 23:37:09 -04:00
|
|
|
assert_locked_or_safepoint(Module_lock);
|
2017-04-18 13:19:42 -04:00
|
|
|
if (_unnamed_module != NULL) {
|
|
|
|
f(_unnamed_module);
|
|
|
|
}
|
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
|
|
|
if (_modules != NULL) {
|
|
|
|
for (int i = 0; i < _modules->table_size(); i++) {
|
|
|
|
for (ModuleEntry* entry = _modules->bucket(i);
|
2017-04-27 10:08:02 -04:00
|
|
|
entry != NULL;
|
|
|
|
entry = entry->next()) {
|
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
|
|
|
f(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderData::packages_do(void f(PackageEntry*)) {
|
2017-04-27 10:08:02 -04:00
|
|
|
assert_locked_or_safepoint(Module_lock);
|
|
|
|
if (_packages != NULL) {
|
|
|
|
for (int i = 0; i < _packages->table_size(); i++) {
|
|
|
|
for (PackageEntry* entry = _packages->bucket(i);
|
|
|
|
entry != NULL;
|
|
|
|
entry = entry->next()) {
|
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
|
|
|
f(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
void ClassLoaderData::record_dependency(const Klass* k, TRAPS) {
|
|
|
|
assert(k != NULL, "invariant");
|
|
|
|
|
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
|
|
|
ClassLoaderData * const from_cld = this;
|
|
|
|
ClassLoaderData * const to_cld = k->class_loader_data();
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
// Dependency to the null class loader data doesn't need to be recorded
|
|
|
|
// because the null class loader data never goes away.
|
|
|
|
if (to_cld->is_the_null_class_loader_data()) {
|
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;
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
oop to;
|
|
|
|
if (to_cld->is_anonymous()) {
|
|
|
|
// Anonymous class dependencies are through the mirror.
|
|
|
|
to = k->java_mirror();
|
|
|
|
} else {
|
|
|
|
to = to_cld->class_loader();
|
|
|
|
|
|
|
|
// If from_cld is anonymous, even if it's class_loader is a parent of 'to'
|
|
|
|
// we still have to add it. The class_loader won't keep from_cld alive.
|
|
|
|
if (!from_cld->is_anonymous()) {
|
|
|
|
// Check that this dependency isn't from the same or parent class_loader
|
|
|
|
oop from = from_cld->class_loader();
|
|
|
|
|
|
|
|
oop curr = from;
|
|
|
|
while (curr != NULL) {
|
|
|
|
if (curr == to) {
|
|
|
|
return; // this class loader is in the parent list, no need to add it.
|
|
|
|
}
|
|
|
|
curr = java_lang_ClassLoader::parent(curr);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's a dependency we won't find through GC, add it. This is relatively rare
|
2012-11-29 16:50:29 -05:00
|
|
|
// Must handle over GC point.
|
|
|
|
Handle dependency(THREAD, to);
|
2013-04-10 13:27:35 +02:00
|
|
|
from_cld->_dependencies.add(dependency, CHECK);
|
2017-10-03 16:42:04 -04:00
|
|
|
|
|
|
|
// Added a potentially young gen oop to the ClassLoaderData
|
|
|
|
record_modified_oops();
|
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-04-10 13:27:35 +02:00
|
|
|
void ClassLoaderData::Dependencies::add(Handle dependency, TRAPS) {
|
2012-11-29 16:50:29 -05:00
|
|
|
// Check first if this dependency is already in the list.
|
|
|
|
// Save a pointer to the last to add to under the lock.
|
2013-04-10 13:27:35 +02:00
|
|
|
objArrayOop ok = _list_head;
|
2012-11-29 16:50:29 -05:00
|
|
|
objArrayOop last = 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
|
|
|
while (ok != NULL) {
|
2012-11-29 16:50:29 -05:00
|
|
|
last = ok;
|
|
|
|
if (ok->obj_at(0) == dependency()) {
|
|
|
|
// Don't need to add it
|
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
ok = (objArrayOop)ok->obj_at(1);
|
|
|
|
}
|
2012-11-29 16:50:29 -05:00
|
|
|
|
2012-12-12 22:41:13 +01:00
|
|
|
// Must handle over GC points
|
|
|
|
assert (last != NULL, "dependencies should be initialized");
|
|
|
|
objArrayHandle last_handle(THREAD, last);
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
// Create a new dependency node with fields for (class_loader or mirror, next)
|
|
|
|
objArrayOop deps = oopFactory::new_objectArray(2, CHECK);
|
|
|
|
deps->obj_at_put(0, dependency());
|
|
|
|
|
2012-12-12 22:41:13 +01:00
|
|
|
// Must handle over GC points
|
2012-11-29 16:50:29 -05:00
|
|
|
objArrayHandle new_dependency(THREAD, deps);
|
|
|
|
|
|
|
|
// Add the dependency under lock
|
2013-04-10 13:27:35 +02:00
|
|
|
locked_add(last_handle, new_dependency, 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
|
|
|
}
|
|
|
|
|
2013-04-10 13:27:35 +02:00
|
|
|
void ClassLoaderData::Dependencies::locked_add(objArrayHandle last_handle,
|
|
|
|
objArrayHandle new_dependency,
|
|
|
|
Thread* 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
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
// Have to lock and put the new dependency on the end of the dependency
|
|
|
|
// array so the card mark for CMS sees that this dependency is new.
|
|
|
|
// Can probably do this lock free with some effort.
|
2013-04-10 13:27:35 +02:00
|
|
|
ObjectLocker ol(Handle(THREAD, _list_head), THREAD);
|
2012-11-29 16:50:29 -05:00
|
|
|
|
|
|
|
oop loader_or_mirror = new_dependency->obj_at(0);
|
|
|
|
|
|
|
|
// Since the dependencies are only added, add to the end.
|
|
|
|
objArrayOop end = last_handle();
|
|
|
|
objArrayOop last = NULL;
|
|
|
|
while (end != NULL) {
|
|
|
|
last = end;
|
|
|
|
// check again if another thread added it to the end.
|
|
|
|
if (end->obj_at(0) == loader_or_mirror) {
|
|
|
|
// Don't need to add it
|
|
|
|
return;
|
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
|
|
|
}
|
2012-11-29 16:50:29 -05:00
|
|
|
end = (objArrayOop)end->obj_at(1);
|
|
|
|
}
|
|
|
|
assert (last != NULL, "dependencies should be initialized");
|
|
|
|
// fill in the first element with the oop in new_dependency.
|
|
|
|
if (last->obj_at(0) == NULL) {
|
|
|
|
last->obj_at_put(0, new_dependency->obj_at(0));
|
|
|
|
} else {
|
|
|
|
last->obj_at_put(1, new_dependency());
|
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 ClassLoaderDataGraph::clear_claimed_marks() {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->clear_claimed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 20:04:03 +01:00
|
|
|
void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) {
|
|
|
|
{
|
|
|
|
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
Klass* old_value = _klasses;
|
|
|
|
k->set_next_link(old_value);
|
2016-06-02 23:37:09 -04:00
|
|
|
// Link the new item into the list, making sure the linked class is stable
|
|
|
|
// since the list can be walked without a lock
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&_klasses, k);
|
2015-12-08 20:04:03 +01:00
|
|
|
}
|
|
|
|
|
2016-02-03 11:40:30 -05:00
|
|
|
if (publicize && k->class_loader_data() != 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
|
|
|
ResourceMark rm;
|
2016-04-29 22:40:51 -04:00
|
|
|
log_trace(class, loader, data)("Adding k: " PTR_FORMAT " %s to CLD: "
|
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
|
|
|
PTR_FORMAT " loader: " PTR_FORMAT " %s",
|
2014-05-09 16:50:54 -04:00
|
|
|
p2i(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
|
|
|
k->external_name(),
|
2014-05-09 16:50:54 -04:00
|
|
|
p2i(k->class_loader_data()),
|
|
|
|
p2i((void *)k->class_loader()),
|
2012-11-29 16:50:29 -05:00
|
|
|
loader_name());
|
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-07-28 10:48:35 -04:00
|
|
|
// Class iterator used by the compiler. It gets some number of classes at
|
|
|
|
// a safepoint to decay invocation counters on the methods.
|
|
|
|
class ClassLoaderDataGraphKlassIteratorStatic {
|
|
|
|
ClassLoaderData* _current_loader_data;
|
|
|
|
Klass* _current_class_entry;
|
|
|
|
public:
|
|
|
|
|
|
|
|
ClassLoaderDataGraphKlassIteratorStatic() : _current_loader_data(NULL), _current_class_entry(NULL) {}
|
|
|
|
|
|
|
|
InstanceKlass* try_get_next_class() {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
|
|
|
int max_classes = InstanceKlass::number_of_instance_classes();
|
2017-08-01 17:36:38 -04:00
|
|
|
assert(max_classes > 0, "should not be called with no instance classes");
|
|
|
|
for (int i = 0; i < max_classes; ) {
|
2017-07-28 10:48:35 -04:00
|
|
|
|
|
|
|
if (_current_class_entry != NULL) {
|
|
|
|
Klass* k = _current_class_entry;
|
|
|
|
_current_class_entry = _current_class_entry->next_link();
|
|
|
|
|
|
|
|
if (k->is_instance_klass()) {
|
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2017-08-01 17:36:38 -04:00
|
|
|
i++; // count all instance classes found
|
|
|
|
// Not yet loaded classes are counted in max_classes
|
|
|
|
// but only return loaded classes.
|
2017-07-28 10:48:35 -04:00
|
|
|
if (ik->is_loaded()) {
|
|
|
|
return ik;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Go to next CLD
|
|
|
|
if (_current_loader_data != NULL) {
|
|
|
|
_current_loader_data = _current_loader_data->next();
|
|
|
|
}
|
|
|
|
// Start at the beginning
|
|
|
|
if (_current_loader_data == NULL) {
|
|
|
|
_current_loader_data = ClassLoaderDataGraph::_head;
|
|
|
|
}
|
|
|
|
|
|
|
|
_current_class_entry = _current_loader_data->klasses();
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 17:36:38 -04:00
|
|
|
// Should never be reached unless all instance classes have failed or are not fully loaded.
|
|
|
|
// Caller handles NULL.
|
|
|
|
return NULL;
|
2017-07-28 10:48:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the current class for the static iterator is a class being unloaded or
|
|
|
|
// deallocated, adjust the current class.
|
|
|
|
void adjust_saved_class(ClassLoaderData* cld) {
|
|
|
|
if (_current_loader_data == cld) {
|
|
|
|
_current_loader_data = cld->next();
|
|
|
|
if (_current_loader_data != NULL) {
|
|
|
|
_current_class_entry = _current_loader_data->klasses();
|
|
|
|
} // else try_get_next_class will start at the head
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void adjust_saved_class(Klass* klass) {
|
|
|
|
if (_current_class_entry == klass) {
|
|
|
|
_current_class_entry = klass->next_link();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static ClassLoaderDataGraphKlassIteratorStatic static_klass_iterator;
|
|
|
|
|
|
|
|
InstanceKlass* ClassLoaderDataGraph::try_get_next_class() {
|
|
|
|
return static_klass_iterator.try_get_next_class();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-02 23:37:09 -04:00
|
|
|
// Remove a klass from the _klasses list for scratch_class during redefinition
|
|
|
|
// or parsed class in the case of an error.
|
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 ClassLoaderData::remove_class(Klass* scratch_class) {
|
2016-06-02 23:37:09 -04:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
2017-07-28 10:48:35 -04:00
|
|
|
|
|
|
|
// Adjust global class iterator.
|
|
|
|
static_klass_iterator.adjust_saved_class(scratch_class);
|
|
|
|
|
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* prev = NULL;
|
|
|
|
for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
|
|
|
|
if (k == scratch_class) {
|
|
|
|
if (prev == NULL) {
|
|
|
|
_klasses = k->next_link();
|
|
|
|
} else {
|
|
|
|
Klass* next = k->next_link();
|
|
|
|
prev->set_next_link(next);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
prev = k;
|
2013-03-15 17:24:40 -04:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
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
|
|
|
}
|
|
|
|
ShouldNotReachHere(); // should have found this class!!
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
void ClassLoaderData::unload() {
|
|
|
|
_unloading = true;
|
|
|
|
|
2013-04-24 16:19:35 -04:00
|
|
|
// Tell serviceability tools these classes are unloading
|
|
|
|
classes_do(InstanceKlass::notify_unload_class);
|
|
|
|
|
2017-07-21 09:50:12 +02:00
|
|
|
LogTarget(Debug, class, loader, data) lt;
|
|
|
|
if (lt.is_enabled()) {
|
2012-11-29 16:50:29 -05:00
|
|
|
ResourceMark rm;
|
2017-07-21 09:50:12 +02:00
|
|
|
LogStream ls(lt);
|
|
|
|
ls.print(": unload loader data " INTPTR_FORMAT, p2i(this));
|
|
|
|
ls.print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()),
|
2012-11-29 16:50:29 -05:00
|
|
|
loader_name());
|
|
|
|
if (is_anonymous()) {
|
2017-07-21 09:50:12 +02:00
|
|
|
ls.print(" for anonymous class " INTPTR_FORMAT " ", p2i(_klasses));
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
2017-07-21 09:50:12 +02:00
|
|
|
ls.cr();
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
2016-05-18 11:06:00 +02:00
|
|
|
|
2017-12-13 07:14:18 -05:00
|
|
|
// Some items on the _deallocate_list need to free their C heap structures
|
|
|
|
// if they are not already on the _klasses list.
|
|
|
|
unload_deallocate_list();
|
2017-07-28 10:48:35 -04:00
|
|
|
|
|
|
|
// Clean up global class iterator for compiler
|
|
|
|
static_klass_iterator.adjust_saved_class(this);
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
ModuleEntryTable* ClassLoaderData::modules() {
|
|
|
|
// Lazily create the module entry table at first request.
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire.
|
|
|
|
ModuleEntryTable* modules = OrderAccess::load_acquire(&_modules);
|
2016-06-02 23:37:09 -04:00
|
|
|
if (modules == NULL) {
|
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
|
|
|
MutexLocker m1(Module_lock);
|
2016-06-02 23:37:09 -04:00
|
|
|
// Check if _modules got allocated while we were waiting for this lock.
|
|
|
|
if ((modules = _modules) == NULL) {
|
|
|
|
modules = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size);
|
|
|
|
|
|
|
|
{
|
|
|
|
MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
// Ensure _modules is stable, since it is examined without a lock
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&_modules, modules);
|
2016-06-02 23:37:09 -04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2016-06-02 23:37:09 -04:00
|
|
|
return modules;
|
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
|
|
|
}
|
|
|
|
|
2017-07-28 10:48:35 -04:00
|
|
|
const int _boot_loader_dictionary_size = 1009;
|
|
|
|
const int _default_loader_dictionary_size = 107;
|
|
|
|
|
|
|
|
Dictionary* ClassLoaderData::create_dictionary() {
|
|
|
|
assert(!is_anonymous(), "anonymous class loader data do not have a dictionary");
|
|
|
|
int size;
|
2017-11-02 11:00:34 -05:00
|
|
|
bool resizable = false;
|
2017-07-28 10:48:35 -04:00
|
|
|
if (_the_null_class_loader_data == NULL) {
|
|
|
|
size = _boot_loader_dictionary_size;
|
2017-11-02 11:00:34 -05:00
|
|
|
resizable = true;
|
2017-07-28 10:48:35 -04:00
|
|
|
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
|
|
|
|
size = 1; // there's only one class in relection class loader and no initiated classes
|
|
|
|
} else if (is_system_class_loader_data()) {
|
2017-11-02 11:00:34 -05:00
|
|
|
size = _boot_loader_dictionary_size;
|
|
|
|
resizable = true;
|
2017-07-28 10:48:35 -04:00
|
|
|
} else {
|
|
|
|
size = _default_loader_dictionary_size;
|
2017-11-02 11:00:34 -05:00
|
|
|
resizable = true;
|
|
|
|
}
|
|
|
|
if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) {
|
|
|
|
resizable = false;
|
2017-07-28 10:48:35 -04:00
|
|
|
}
|
2017-11-02 11:00:34 -05:00
|
|
|
return new Dictionary(this, size, resizable);
|
2017-07-28 10:48:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unloading support
|
2014-02-21 10:19:09 +01:00
|
|
|
oop ClassLoaderData::keep_alive_object() const {
|
2016-06-02 23:37:09 -04:00
|
|
|
assert_locked_or_safepoint(_metaspace_lock);
|
2014-02-21 10:19:09 +01:00
|
|
|
assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
|
|
|
|
return is_anonymous() ? _klasses->java_mirror() : class_loader();
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
bool ClassLoaderData::is_alive(BoolObjectClosure* is_alive_closure) const {
|
2014-02-21 10:19:09 +01:00
|
|
|
bool alive = keep_alive() // null class loader and incomplete anonymous klasses.
|
|
|
|
|| is_alive_closure->do_object_b(keep_alive_object());
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
return 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
|
|
|
ClassLoaderData::~ClassLoaderData() {
|
2013-04-24 16:19:35 -04:00
|
|
|
// Release C heap structures for all the classes.
|
|
|
|
classes_do(InstanceKlass::release_C_heap_structures);
|
|
|
|
|
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
|
|
|
// Release C heap allocated hashtable for all the packages.
|
|
|
|
if (_packages != NULL) {
|
|
|
|
// Destroy the table itself
|
|
|
|
delete _packages;
|
|
|
|
_packages = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Release C heap allocated hashtable for all the modules.
|
|
|
|
if (_modules != NULL) {
|
|
|
|
// Destroy the table itself
|
|
|
|
delete _modules;
|
|
|
|
_modules = NULL;
|
|
|
|
}
|
|
|
|
|
2017-07-28 10:48:35 -04:00
|
|
|
// Release C heap allocated hashtable for the dictionary
|
|
|
|
if (_dictionary != NULL) {
|
|
|
|
// Destroy the table itself
|
|
|
|
delete _dictionary;
|
|
|
|
_dictionary = NULL;
|
|
|
|
}
|
|
|
|
|
2017-04-18 13:19:42 -04:00
|
|
|
if (_unnamed_module != NULL) {
|
|
|
|
_unnamed_module->delete_unnamed_module();
|
|
|
|
_unnamed_module = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// release the metaspace
|
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
|
|
|
Metaspace *m = _metaspace;
|
|
|
|
if (m != NULL) {
|
|
|
|
_metaspace = NULL;
|
|
|
|
delete m;
|
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
|
|
|
}
|
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 all the JNI handles for methods
|
|
|
|
// These aren't deallocated and are going to look like a leak, but that's
|
|
|
|
// needed because we can't really get rid of jmethodIDs because we don't
|
|
|
|
// know when native code is going to stop using them. The spec says that
|
|
|
|
// they're "invalid" but existing programs likely rely on their being
|
|
|
|
// NULL after class unloading.
|
|
|
|
if (_jmethod_ids != NULL) {
|
|
|
|
Method::clear_jmethod_ids(this);
|
|
|
|
}
|
|
|
|
// Delete lock
|
|
|
|
delete _metaspace_lock;
|
|
|
|
|
|
|
|
// Delete free list
|
|
|
|
if (_deallocate_list != NULL) {
|
|
|
|
delete _deallocate_list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 10:11:01 -04:00
|
|
|
// Returns true if this class loader data is for the system class loader.
|
|
|
|
bool ClassLoaderData::is_system_class_loader_data() const {
|
|
|
|
return SystemDictionary::is_system_class_loader(class_loader());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if this class loader data is for the platform class loader.
|
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
|
|
|
bool ClassLoaderData::is_platform_class_loader_data() const {
|
|
|
|
return SystemDictionary::is_platform_class_loader(class_loader());
|
2013-03-25 17:13:26 -07:00
|
|
|
}
|
|
|
|
|
2016-06-28 10:11:01 -04:00
|
|
|
// Returns true if this class loader data is one of the 3 builtin
|
|
|
|
// (boot, application/system or platform) class loaders. Note, the
|
|
|
|
// builtin loaders are not freed by a GC.
|
|
|
|
bool ClassLoaderData::is_builtin_class_loader_data() const {
|
|
|
|
return (is_the_null_class_loader_data() ||
|
2017-02-15 22:59:57 -05:00
|
|
|
SystemDictionary::is_system_class_loader(class_loader()) ||
|
|
|
|
SystemDictionary::is_platform_class_loader(class_loader()));
|
2016-06-28 10:11:01 -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
|
|
|
Metaspace* ClassLoaderData::metaspace_non_null() {
|
|
|
|
// If the metaspace has not been allocated, create a new one. Might want
|
|
|
|
// to create smaller arena for Reflection class loaders also.
|
|
|
|
// The reason for the delayed allocation is because some class loaders are
|
|
|
|
// simply for delegating with no metadata of their own.
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire.
|
|
|
|
Metaspace* metaspace = OrderAccess::load_acquire(&_metaspace);
|
2016-06-02 23:37:09 -04:00
|
|
|
if (metaspace == NULL) {
|
|
|
|
MutexLockerEx ml(_metaspace_lock, Mutex::_no_safepoint_check_flag);
|
|
|
|
// Check if _metaspace got allocated while we were waiting for this lock.
|
|
|
|
if ((metaspace = _metaspace) == NULL) {
|
|
|
|
if (this == the_null_class_loader_data()) {
|
|
|
|
assert (class_loader() == NULL, "Must be");
|
|
|
|
metaspace = new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType);
|
|
|
|
} else if (is_anonymous()) {
|
|
|
|
if (class_loader() != NULL) {
|
|
|
|
log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
|
|
|
|
}
|
|
|
|
metaspace = new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType);
|
|
|
|
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
|
|
|
|
if (class_loader() != NULL) {
|
|
|
|
log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
|
|
|
|
}
|
|
|
|
metaspace = new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType);
|
|
|
|
} else {
|
|
|
|
metaspace = new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType);
|
2012-12-03 15:09:39 -08:00
|
|
|
}
|
2016-06-02 23:37:09 -04:00
|
|
|
// Ensure _metaspace is stable, since it is examined without a lock
|
2017-10-16 22:36:06 -04:00
|
|
|
OrderAccess::release_store(&_metaspace, metaspace);
|
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
|
|
|
}
|
|
|
|
}
|
2016-06-02 23:37:09 -04:00
|
|
|
return metaspace;
|
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-23 12:00:39 -04:00
|
|
|
OopHandle ClassLoaderData::add_handle(Handle h) {
|
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
|
|
|
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
2017-10-03 16:42:04 -04:00
|
|
|
record_modified_oops();
|
2017-08-23 12:00:39 -04:00
|
|
|
return OopHandle(_handles.add(h()));
|
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-30 07:18:02 -04:00
|
|
|
void ClassLoaderData::remove_handle(OopHandle h) {
|
2017-12-13 07:14:18 -05:00
|
|
|
assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
|
2017-08-30 07:18:02 -04:00
|
|
|
oop* ptr = h.ptr_raw();
|
|
|
|
if (ptr != NULL) {
|
|
|
|
assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
// This barrier is used by G1 to remember the old oop values, so
|
|
|
|
// that we don't forget any objects that were live at the snapshot at
|
|
|
|
// the beginning.
|
|
|
|
if (UseG1GC) {
|
|
|
|
oop obj = *ptr;
|
|
|
|
if (obj != NULL) {
|
|
|
|
G1SATBCardTableModRefBS::enqueue(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*ptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 12:00:39 -04:00
|
|
|
void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
|
|
|
|
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
if (dest.resolve() != NULL) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
dest = _handles.add(h());
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
// Add this metadata pointer to be freed when it's safe. This is only during
|
|
|
|
// class unloading because Handles might point to this metadata field.
|
|
|
|
void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
|
|
|
|
// Metadata in shared region isn't deleted.
|
|
|
|
if (!m->is_shared()) {
|
|
|
|
MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
if (_deallocate_list == NULL) {
|
|
|
|
_deallocate_list = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(100, true);
|
|
|
|
}
|
|
|
|
_deallocate_list->append_if_missing(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deallocate free metadata on the free list. How useful the PermGen was!
|
|
|
|
void ClassLoaderData::free_deallocate_list() {
|
|
|
|
// Don't need lock, at safepoint
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
2017-12-13 07:14:18 -05:00
|
|
|
assert(!is_unloading(), "only called for ClassLoaderData that are not unloading");
|
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 (_deallocate_list == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Go backwards because this removes entries that are freed.
|
|
|
|
for (int i = _deallocate_list->length() - 1; i >= 0; i--) {
|
|
|
|
Metadata* m = _deallocate_list->at(i);
|
|
|
|
if (!m->on_stack()) {
|
|
|
|
_deallocate_list->remove_at(i);
|
|
|
|
// There are only three types of metadata that we deallocate directly.
|
|
|
|
// Cast them so they can be used by the template function.
|
|
|
|
if (m->is_method()) {
|
|
|
|
MetadataFactory::free_metadata(this, (Method*)m);
|
|
|
|
} else if (m->is_constantPool()) {
|
|
|
|
MetadataFactory::free_metadata(this, (ConstantPool*)m);
|
|
|
|
} else if (m->is_klass()) {
|
|
|
|
MetadataFactory::free_metadata(this, (InstanceKlass*)m);
|
|
|
|
} else {
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
2015-03-13 12:40:39 -04:00
|
|
|
} else {
|
|
|
|
// Metadata is alive.
|
|
|
|
// If scratch_class is on stack then it shouldn't be on this list!
|
|
|
|
assert(!m->is_klass() || !((InstanceKlass*)m)->is_scratch_class(),
|
|
|
|
"scratch classes on this list should be dead");
|
|
|
|
// Also should assert that other metadata on the list was found in handles.
|
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-12-13 07:14:18 -05:00
|
|
|
// This is distinct from free_deallocate_list. For class loader data that are
|
|
|
|
// unloading, this frees the C heap memory for constant pools on the list. If there
|
|
|
|
// were C heap memory allocated for methods, it would free that too. The C heap memory
|
|
|
|
// for InstanceKlasses on this list is freed in the ClassLoaderData destructor.
|
|
|
|
void ClassLoaderData::unload_deallocate_list() {
|
|
|
|
// Don't need lock, at safepoint
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
|
|
|
assert(is_unloading(), "only called for ClassLoaderData that are unloading");
|
|
|
|
if (_deallocate_list == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Go backwards because this removes entries that are freed.
|
|
|
|
for (int i = _deallocate_list->length() - 1; i >= 0; i--) {
|
|
|
|
Metadata* m = _deallocate_list->at(i);
|
|
|
|
assert (!m->on_stack(), "wouldn't be unloading if this were so");
|
|
|
|
_deallocate_list->remove_at(i);
|
|
|
|
// Only constant pool entries have C heap memory to free.
|
|
|
|
if (m->is_constantPool()) {
|
|
|
|
((ConstantPool*)m)->release_C_heap_structures();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
// These anonymous class loaders are to contain classes used for JSR292
|
|
|
|
ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
|
|
|
|
// Add a new class loader data to the graph.
|
2017-02-15 22:59:57 -05:00
|
|
|
Handle lh(THREAD, loader);
|
|
|
|
return ClassLoaderDataGraph::add(lh, 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
|
|
|
}
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
const char* ClassLoaderData::loader_name() {
|
|
|
|
// Handles null class loader
|
|
|
|
return SystemDictionary::loader_name(class_loader());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
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
|
|
|
// Define to dump klasses
|
|
|
|
#undef CLD_DUMP_KLASSES
|
|
|
|
|
|
|
|
void ClassLoaderData::dump(outputStream * const out) {
|
2015-06-24 12:12:25 -04:00
|
|
|
out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: " PTR_FORMAT " %s {",
|
2014-05-09 16:50:54 -04:00
|
|
|
p2i(this), p2i((void *)class_loader()),
|
|
|
|
p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
|
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 (claimed()) out->print(" claimed ");
|
|
|
|
if (is_unloading()) out->print(" unloading ");
|
|
|
|
out->cr();
|
|
|
|
if (metaspace_or_null() != NULL) {
|
2014-05-09 16:50:54 -04:00
|
|
|
out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_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
|
|
|
metaspace_or_null()->dump(out);
|
|
|
|
} else {
|
|
|
|
out->print_cr("metaspace: NULL");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CLD_DUMP_KLASSES
|
|
|
|
if (Verbose) {
|
|
|
|
Klass* k = _klasses;
|
|
|
|
while (k != NULL) {
|
2017-10-03 16:42:04 -04:00
|
|
|
out->print_cr("klass " PTR_FORMAT ", %s", p2i(k), k->name()->as_C_string());
|
2013-03-15 17:24:40 -04:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
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
|
|
|
k = k->next_link();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // CLD_DUMP_KLASSES
|
|
|
|
#undef CLD_DUMP_KLASSES
|
|
|
|
if (_jmethod_ids != NULL) {
|
|
|
|
Method::print_jmethod_ids(this, out);
|
|
|
|
}
|
|
|
|
out->print_cr("}");
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
|
|
|
void ClassLoaderData::verify() {
|
2016-06-02 23:37:09 -04:00
|
|
|
assert_locked_or_safepoint(_metaspace_lock);
|
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 cl = class_loader();
|
|
|
|
|
2012-11-29 16:50:29 -05:00
|
|
|
guarantee(this == class_loader_data(cl) || is_anonymous(), "Must be the same");
|
|
|
|
guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_anonymous(), "must 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
|
|
|
|
|
|
|
// Verify the integrity of the allocated space.
|
|
|
|
if (metaspace_or_null() != NULL) {
|
|
|
|
metaspace_or_null()->verify();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
|
|
|
|
guarantee(k->class_loader_data() == this, "Must be the same");
|
|
|
|
k->verify();
|
2013-03-15 17:24:40 -04:00
|
|
|
assert(k != k->next_link(), "no loops!");
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-15 13:03:38 -05:00
|
|
|
bool ClassLoaderData::contains_klass(Klass* klass) {
|
2017-10-16 22:36:06 -04:00
|
|
|
// Lock-free access requires load_acquire
|
|
|
|
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) {
|
2014-02-15 13:03:38 -05:00
|
|
|
if (k == klass) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// GC root of class loader data created.
|
|
|
|
ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
|
|
|
|
ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL;
|
2014-06-27 13:33:36 +02:00
|
|
|
ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = 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
|
|
|
ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
|
|
|
|
|
2014-05-15 18:23:26 -04:00
|
|
|
bool ClassLoaderDataGraph::_should_purge = false;
|
2014-10-30 18:38:42 -04:00
|
|
|
bool ClassLoaderDataGraph::_metaspace_oom = false;
|
2014-05-15 18:23:26 -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
|
|
|
// Add a new class loader data node to the list. Assign the newly created
|
|
|
|
// ClassLoaderData into the java/lang/ClassLoader object as a hidden field
|
2013-04-23 08:39:55 +02:00
|
|
|
ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous, TRAPS) {
|
2013-04-24 19:55:02 +02:00
|
|
|
// We need to allocate all the oops for the ClassLoaderData before allocating the
|
|
|
|
// actual ClassLoaderData object.
|
|
|
|
ClassLoaderData::Dependencies dependencies(CHECK_NULL);
|
|
|
|
|
2016-01-14 13:26:19 +01:00
|
|
|
NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
|
|
|
|
// ClassLoaderData in the graph since the CLD
|
|
|
|
// contains unhandled oops
|
2013-04-24 19:55:02 +02:00
|
|
|
|
|
|
|
ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous, dependencies);
|
2012-11-29 16:50:29 -05:00
|
|
|
|
2013-04-23 08:39:55 +02:00
|
|
|
|
|
|
|
if (!is_anonymous) {
|
|
|
|
ClassLoaderData** cld_addr = java_lang_ClassLoader::loader_data_addr(loader());
|
2013-04-24 19:55:02 +02:00
|
|
|
// First, Atomically set it
|
2017-10-16 22:36:06 -04:00
|
|
|
ClassLoaderData* old = Atomic::cmpxchg(cld, cld_addr, (ClassLoaderData*)NULL);
|
2013-04-24 19:55:02 +02:00
|
|
|
if (old != NULL) {
|
|
|
|
delete cld;
|
|
|
|
// Returns the data.
|
|
|
|
return old;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// We won the race, and therefore the task of adding the data to the list of
|
|
|
|
// class loader data
|
2013-04-23 08:39:55 +02:00
|
|
|
ClassLoaderData** list_head = &_head;
|
|
|
|
ClassLoaderData* next = _head;
|
|
|
|
|
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
|
|
|
do {
|
|
|
|
cld->set_next(next);
|
2017-10-16 22:36:06 -04:00
|
|
|
ClassLoaderData* exchanged = Atomic::cmpxchg(cld, list_head, next);
|
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 (exchanged == next) {
|
2017-07-21 09:50:12 +02:00
|
|
|
LogTarget(Debug, class, loader, data) lt;
|
|
|
|
if (lt.is_enabled()) {
|
2016-02-03 11:40:30 -05:00
|
|
|
PauseNoSafepointVerifier pnsv(&no_safepoints); // Need safe points for JavaCalls::call_virtual
|
2017-07-21 09:50:12 +02:00
|
|
|
LogStream ls(lt);
|
|
|
|
print_creation(&ls, loader, cld, 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
|
|
|
}
|
|
|
|
return cld;
|
|
|
|
}
|
|
|
|
next = exchanged;
|
|
|
|
} while (true);
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
|
|
|
|
2017-07-21 09:50:12 +02:00
|
|
|
void ClassLoaderDataGraph::print_creation(outputStream* out, Handle loader, ClassLoaderData* cld, TRAPS) {
|
2016-02-03 11:40:30 -05:00
|
|
|
Handle string;
|
|
|
|
if (loader.not_null()) {
|
|
|
|
// Include the result of loader.toString() in the output. This allows
|
|
|
|
// the user of the log to identify the class loader instance.
|
|
|
|
JavaValue result(T_OBJECT);
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* spec_klass = SystemDictionary::ClassLoader_klass();
|
2016-02-03 11:40:30 -05:00
|
|
|
JavaCalls::call_virtual(&result,
|
|
|
|
loader,
|
|
|
|
spec_klass,
|
|
|
|
vmSymbols::toString_name(),
|
|
|
|
vmSymbols::void_string_signature(),
|
|
|
|
CHECK);
|
|
|
|
assert(result.get_type() == T_OBJECT, "just checking");
|
2017-02-15 22:59:57 -05:00
|
|
|
string = Handle(THREAD, (oop)result.get_jobject());
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
2012-11-29 16:50:29 -05:00
|
|
|
|
2016-02-03 11:40:30 -05:00
|
|
|
ResourceMark rm;
|
2017-07-21 09:50:12 +02:00
|
|
|
out->print("create class loader data " INTPTR_FORMAT, p2i(cld));
|
|
|
|
out->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
|
2016-02-03 11:40:30 -05:00
|
|
|
cld->loader_name());
|
|
|
|
|
|
|
|
if (string.not_null()) {
|
2017-07-21 09:50:12 +02:00
|
|
|
out->print(": ");
|
|
|
|
java_lang_String::print(string(), out);
|
2016-02-03 11:40:30 -05:00
|
|
|
}
|
2017-07-21 09:50:12 +02:00
|
|
|
out->cr();
|
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
|
|
|
}
|
|
|
|
|
2016-02-03 11:40:30 -05:00
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) {
|
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 (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
2017-10-03 16:42:04 -04:00
|
|
|
cld->oops_do(f, must_claim);
|
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-10-03 16:42:04 -04:00
|
|
|
void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, bool must_claim) {
|
2012-11-29 16:50:29 -05:00
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
if (cld->keep_alive()) {
|
2017-10-03 16:42:04 -04:00
|
|
|
cld->oops_do(f, must_claim);
|
2012-11-29 16:50:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, bool must_claim) {
|
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 (ClassUnloading) {
|
2017-10-03 16:42:04 -04:00
|
|
|
keep_alive_oops_do(f, must_claim);
|
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 {
|
2017-10-03 16:42:04 -04:00
|
|
|
oops_do(f, must_claim);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-04 11:05:30 +02:00
|
|
|
void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
|
|
|
|
for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
|
|
|
|
cl->do_cld(cld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-06 22:49:17 +01:00
|
|
|
void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
|
|
|
// Only walk the head until any clds not purged from prior unloading
|
|
|
|
// (CMS doesn't purge right away).
|
|
|
|
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
|
|
|
|
assert(cld->is_unloading(), "invariant");
|
|
|
|
cl->do_cld(cld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-07 10:12:40 +02:00
|
|
|
void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) {
|
|
|
|
CLDClosure* closure = cld->keep_alive() ? strong : weak;
|
|
|
|
if (closure != NULL) {
|
|
|
|
closure->do_cld(cld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::keep_alive_cld_do(CLDClosure* cl) {
|
|
|
|
roots_cld_do(cl, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::always_strong_cld_do(CLDClosure* cl) {
|
|
|
|
if (ClassUnloading) {
|
|
|
|
keep_alive_cld_do(cl);
|
|
|
|
} else {
|
|
|
|
cld_do(cl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->classes_do(klass_closure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
void ClassLoaderDataGraph::classes_do(void f(Klass* const)) {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->classes_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-31 10:35:06 +02:00
|
|
|
void ClassLoaderDataGraph::methods_do(void f(Method*)) {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->methods_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void ClassLoaderDataGraph::modules_do(void f(ModuleEntry*)) {
|
|
|
|
assert_locked_or_safepoint(Module_lock);
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->modules_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::modules_unloading_do(void f(ModuleEntry*)) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
|
|
|
// Only walk the head until any clds not purged from prior unloading
|
|
|
|
// (CMS doesn't purge right away).
|
|
|
|
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
|
|
|
|
assert(cld->is_unloading(), "invariant");
|
|
|
|
cld->modules_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::packages_do(void f(PackageEntry*)) {
|
|
|
|
assert_locked_or_safepoint(Module_lock);
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->packages_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::packages_unloading_do(void f(PackageEntry*)) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
|
|
|
// Only walk the head until any clds not purged from prior unloading
|
|
|
|
// (CMS doesn't purge right away).
|
|
|
|
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
|
|
|
|
assert(cld->is_unloading(), "invariant");
|
|
|
|
cld->packages_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-24 10:02:02 +02:00
|
|
|
void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) {
|
|
|
|
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
|
|
|
|
cld->loaded_classes_do(klass_closure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
2014-06-27 13:33:36 +02:00
|
|
|
// Only walk the head until any clds not purged from prior unloading
|
|
|
|
// (CMS doesn't purge right away).
|
|
|
|
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
|
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
|
|
|
assert(cld->is_unloading(), "invariant");
|
2013-06-10 11:30:51 +02:00
|
|
|
cld->classes_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-28 10:48:35 -04:00
|
|
|
#define FOR_ALL_DICTIONARY(X) for (ClassLoaderData* X = _head; X != NULL; X = X->next()) \
|
|
|
|
if (X->dictionary() != NULL)
|
|
|
|
|
|
|
|
// Walk classes in the loaded class dictionaries in various forms.
|
|
|
|
// Only walks the classes defined in this class loader.
|
|
|
|
void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*)) {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
cld->dictionary()->classes_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only walks the classes defined in this class loader.
|
|
|
|
void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*, TRAPS), TRAPS) {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
cld->dictionary()->classes_do(f, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Walks all entries in the dictionary including entries initiated by this class loader.
|
|
|
|
void ClassLoaderDataGraph::dictionary_all_entries_do(void f(InstanceKlass*, ClassLoaderData*)) {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
cld->dictionary()->all_entries_do(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::verify_dictionary() {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
cld->dictionary()->verify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-02 10:52:50 -04:00
|
|
|
void ClassLoaderDataGraph::print_dictionary(outputStream* st) {
|
2017-07-28 10:48:35 -04:00
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
2017-08-02 10:52:50 -04:00
|
|
|
st->print("Dictionary for ");
|
|
|
|
cld->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
cld->dictionary()->print_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::print_dictionary_statistics(outputStream* st) {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
ResourceMark rm;
|
|
|
|
stringStream tempst;
|
|
|
|
tempst.print("System Dictionary for %s", cld->loader_name());
|
|
|
|
cld->dictionary()->print_table_statistics(st, tempst.as_string());
|
2017-07-28 10:48:35 -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
|
|
|
GrowableArray<ClassLoaderData*>* ClassLoaderDataGraph::new_clds() {
|
|
|
|
assert(_head == NULL || _saved_head != NULL, "remember_new_clds(true) not called?");
|
|
|
|
|
|
|
|
GrowableArray<ClassLoaderData*>* array = new GrowableArray<ClassLoaderData*>();
|
|
|
|
|
|
|
|
// The CLDs in [_head, _saved_head] were all added during last call to remember_new_clds(true);
|
|
|
|
ClassLoaderData* curr = _head;
|
|
|
|
while (curr != _saved_head) {
|
|
|
|
if (!curr->claimed()) {
|
|
|
|
array->push(curr);
|
2017-07-21 09:50:12 +02:00
|
|
|
LogTarget(Debug, class, loader, data) lt;
|
|
|
|
if (lt.is_enabled()) {
|
|
|
|
LogStream ls(lt);
|
|
|
|
ls.print("found new CLD: ");
|
|
|
|
curr->print_value_on(&ls);
|
|
|
|
ls.cr();
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curr = curr->_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2014-07-07 10:12:40 +02:00
|
|
|
bool ClassLoaderDataGraph::unload_list_contains(const void* x) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "only safe to call at safepoint");
|
|
|
|
for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
|
|
|
|
if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-07 13:26:56 -05:00
|
|
|
#ifndef PRODUCT
|
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 ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
|
|
|
|
for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
|
|
|
|
if (loader_data == data) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
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
|
|
|
// Move class loader data from main list to the unloaded list for unloading
|
|
|
|
// and deallocation later.
|
2015-03-13 12:40:39 -04:00
|
|
|
bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure,
|
|
|
|
bool clean_previous_versions) {
|
|
|
|
|
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
|
|
|
ClassLoaderData* data = _head;
|
|
|
|
ClassLoaderData* prev = NULL;
|
|
|
|
bool seen_dead_loader = false;
|
2014-06-27 13:33:36 +02:00
|
|
|
|
2015-03-13 12:40:39 -04:00
|
|
|
// Mark metadata seen on the stack only so we can delete unneeded entries.
|
|
|
|
// Only walk all metadata, including the expensive code cache walk, for Full GC
|
|
|
|
// and only if class redefinition and if there's previous versions of
|
|
|
|
// Klasses to delete.
|
|
|
|
bool walk_all_metadata = clean_previous_versions &&
|
|
|
|
JvmtiExport::has_redefined_a_class() &&
|
2016-09-07 15:25:21 -04:00
|
|
|
InstanceKlass::has_previous_versions_and_reset();
|
2015-03-13 12:40:39 -04:00
|
|
|
MetadataOnStackMark md_on_stack(walk_all_metadata);
|
|
|
|
|
2014-06-27 13:33:36 +02:00
|
|
|
// Save previous _unloading pointer for CMS which may add to unloading list before
|
|
|
|
// purging and we don't want to rewalk the previously unloaded class loader data.
|
|
|
|
_saved_unloading = _unloading;
|
|
|
|
|
2014-07-10 15:12:48 +02:00
|
|
|
data = _head;
|
|
|
|
while (data != NULL) {
|
|
|
|
if (data->is_alive(is_alive_closure)) {
|
2015-03-13 12:40:39 -04:00
|
|
|
// clean metaspace
|
|
|
|
if (walk_all_metadata) {
|
|
|
|
data->classes_do(InstanceKlass::purge_previous_versions);
|
|
|
|
}
|
|
|
|
data->free_deallocate_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
|
|
|
prev = data;
|
|
|
|
data = data->next();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
seen_dead_loader = true;
|
|
|
|
ClassLoaderData* dead = data;
|
2012-11-29 16:50:29 -05:00
|
|
|
dead->unload();
|
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
|
|
|
data = data->next();
|
|
|
|
// Remove from loader list.
|
2013-02-12 14:15:45 -08:00
|
|
|
// This class loader data will no longer be found
|
|
|
|
// in the ClassLoaderDataGraph.
|
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 (prev != NULL) {
|
|
|
|
prev->set_next(data);
|
|
|
|
} else {
|
|
|
|
assert(dead == _head, "sanity check");
|
|
|
|
_head = data;
|
|
|
|
}
|
|
|
|
dead->set_next(_unloading);
|
|
|
|
_unloading = dead;
|
|
|
|
}
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
if (seen_dead_loader) {
|
2016-06-28 10:11:01 -04:00
|
|
|
data = _head;
|
|
|
|
while (data != NULL) {
|
2017-07-28 10:48:35 -04:00
|
|
|
// Remove entries in the dictionary of live class loader that have
|
|
|
|
// initiated loading classes in a dead class loader.
|
|
|
|
if (data->dictionary() != NULL) {
|
|
|
|
data->dictionary()->do_unloading();
|
|
|
|
}
|
|
|
|
// Walk a ModuleEntry's reads, and a PackageEntry's exports
|
|
|
|
// lists to determine if there are modules on those lists that are now
|
|
|
|
// dead and should be removed. A module's life cycle is equivalent
|
|
|
|
// to its defining class loader's life cycle. Since a module is
|
|
|
|
// considered dead if its class loader is dead, these walks must
|
|
|
|
// occur after each class loader's aliveness is determined.
|
2017-04-27 10:08:02 -04:00
|
|
|
if (data->packages() != NULL) {
|
2016-06-28 10:11:01 -04:00
|
|
|
data->packages()->purge_all_package_exports();
|
|
|
|
}
|
|
|
|
if (data->modules_defined()) {
|
|
|
|
data->modules()->purge_all_module_reads();
|
|
|
|
}
|
|
|
|
data = data->next();
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
post_class_unload_events();
|
|
|
|
}
|
|
|
|
|
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 seen_dead_loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::purge() {
|
2014-05-15 18:23:26 -04:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
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
|
|
|
ClassLoaderData* list = _unloading;
|
|
|
|
_unloading = NULL;
|
|
|
|
ClassLoaderData* next = list;
|
2014-10-30 18:38:42 -04:00
|
|
|
bool classes_unloaded = 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
|
|
|
while (next != NULL) {
|
|
|
|
ClassLoaderData* purge_me = next;
|
|
|
|
next = purge_me->next();
|
|
|
|
delete purge_me;
|
2014-10-30 18:38:42 -04:00
|
|
|
classes_unloaded = true;
|
|
|
|
}
|
|
|
|
if (classes_unloaded) {
|
|
|
|
Metaspace::purge();
|
|
|
|
set_metaspace_oom(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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-02 11:00:34 -05:00
|
|
|
int ClassLoaderDataGraph::resize_if_needed() {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
|
|
|
int resized = 0;
|
|
|
|
if (Dictionary::does_any_dictionary_needs_resizing()) {
|
|
|
|
FOR_ALL_DICTIONARY(cld) {
|
|
|
|
if (cld->dictionary()->resize_if_needed()) {
|
|
|
|
resized++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resized;
|
|
|
|
}
|
|
|
|
|
2016-12-06 22:49:17 +01:00
|
|
|
void ClassLoaderDataGraph::post_class_unload_events() {
|
2013-06-10 11:30:51 +02:00
|
|
|
#if INCLUDE_TRACE
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
|
|
|
if (Tracing::enabled()) {
|
|
|
|
if (Tracing::is_event_enabled(TraceClassUnloadEvent)) {
|
|
|
|
assert(_unloading != NULL, "need class loader data unload list!");
|
2013-11-23 12:25:13 +01:00
|
|
|
_class_unload_time = Ticks::now();
|
2013-06-10 11:30:51 +02:00
|
|
|
classes_unloading_do(&class_unload_event);
|
|
|
|
}
|
|
|
|
Tracing::on_unloading_classes();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-07 10:12:40 +02:00
|
|
|
ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic()
|
|
|
|
: _next_klass(NULL) {
|
|
|
|
ClassLoaderData* cld = ClassLoaderDataGraph::_head;
|
|
|
|
Klass* klass = NULL;
|
|
|
|
|
|
|
|
// Find the first klass in the CLDG.
|
|
|
|
while (cld != NULL) {
|
2016-06-02 23:37:09 -04:00
|
|
|
assert_locked_or_safepoint(cld->metaspace_lock());
|
2014-07-07 10:12:40 +02:00
|
|
|
klass = cld->_klasses;
|
|
|
|
if (klass != NULL) {
|
|
|
|
_next_klass = klass;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cld = cld->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) {
|
|
|
|
Klass* next = klass->next_link();
|
|
|
|
if (next != NULL) {
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No more klasses in the current CLD. Time to find a new CLD.
|
|
|
|
ClassLoaderData* cld = klass->class_loader_data();
|
2016-06-02 23:37:09 -04:00
|
|
|
assert_locked_or_safepoint(cld->metaspace_lock());
|
2014-07-07 10:12:40 +02:00
|
|
|
while (next == NULL) {
|
|
|
|
cld = cld->next();
|
|
|
|
if (cld == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
next = cld->_klasses;
|
|
|
|
}
|
|
|
|
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() {
|
2015-03-06 16:47:46 +01:00
|
|
|
Klass* head = _next_klass;
|
2014-07-07 10:12:40 +02:00
|
|
|
|
|
|
|
while (head != NULL) {
|
|
|
|
Klass* next = next_klass_in_cldg(head);
|
|
|
|
|
2017-10-16 22:36:06 -04:00
|
|
|
Klass* old_head = Atomic::cmpxchg(next, &_next_klass, head);
|
2014-07-07 10:12:40 +02:00
|
|
|
|
|
|
|
if (old_head == head) {
|
|
|
|
return head; // Won the CAS.
|
|
|
|
}
|
|
|
|
|
|
|
|
head = old_head;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nothing more for the iterator to hand out.
|
2015-09-29 11:02:08 +02:00
|
|
|
assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head));
|
2014-07-07 10:12:40 +02: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
|
|
|
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() {
|
|
|
|
_data = ClassLoaderDataGraph::_head;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClassLoaderDataGraphMetaspaceIterator::~ClassLoaderDataGraphMetaspaceIterator() {}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
// callable from debugger
|
|
|
|
extern "C" int print_loader_data_graph() {
|
|
|
|
ClassLoaderDataGraph::dump_on(tty);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::verify() {
|
|
|
|
for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
|
|
|
|
data->verify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassLoaderDataGraph::dump_on(outputStream * const out) {
|
|
|
|
for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
|
|
|
|
data->dump(out);
|
|
|
|
}
|
|
|
|
MetaspaceAux::dump(out);
|
|
|
|
}
|
2013-01-25 15:06:18 -05:00
|
|
|
#endif // PRODUCT
|
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 ClassLoaderData::print_value_on(outputStream* out) const {
|
|
|
|
if (class_loader() == NULL) {
|
2017-08-02 10:52:50 -04:00
|
|
|
out->print("NULL class loader");
|
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 {
|
2016-08-04 12:24:10 -04:00
|
|
|
out->print("class loader " INTPTR_FORMAT " ", p2i(this));
|
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
|
|
|
class_loader()->print_value_on(out);
|
|
|
|
}
|
|
|
|
}
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2017-07-28 10:48:35 -04:00
|
|
|
void ClassLoaderData::print_on(outputStream* out) const {
|
|
|
|
if (class_loader() == NULL) {
|
2017-08-02 10:52:50 -04:00
|
|
|
out->print("NULL class loader");
|
2017-07-28 10:48:35 -04:00
|
|
|
} else {
|
|
|
|
out->print("class loader " INTPTR_FORMAT " ", p2i(this));
|
|
|
|
class_loader()->print_on(out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-10 11:30:51 +02:00
|
|
|
#if INCLUDE_TRACE
|
|
|
|
|
2013-11-23 12:25:13 +01:00
|
|
|
Ticks ClassLoaderDataGraph::_class_unload_time;
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
void ClassLoaderDataGraph::class_unload_event(Klass* const k) {
|
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
|
|
|
assert(k != NULL, "invariant");
|
2013-06-10 11:30:51 +02:00
|
|
|
|
|
|
|
// post class unload event
|
|
|
|
EventClassUnload event(UNTIMED);
|
|
|
|
event.set_endtime(_class_unload_time);
|
|
|
|
event.set_unloadedClass(k);
|
2016-12-06 22:49:17 +01:00
|
|
|
event.set_definingClassLoader(k->class_loader_data());
|
2013-06-10 11:30:51 +02:00
|
|
|
event.commit();
|
|
|
|
}
|
|
|
|
|
2014-11-19 16:08:01 +01:00
|
|
|
#endif // INCLUDE_TRACE
|