< prev index next >
src/hotspot/share/classfile/classLoaderDataGraph.cpp
Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com
*** 1,7 ****
/*
! * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* 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.
--- 1,7 ----
/*
! * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* 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.
*** 190,208 ****
bool ClassLoaderDataGraph::_safepoint_cleanup_needed = false;
bool ClassLoaderDataGraph::_metaspace_oom = false;
// 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
! ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_unsafe_anonymous) {
assert_lock_strong(ClassLoaderDataGraph_lock);
ClassLoaderData* cld;
// First check if another thread beat us to creating the CLD and installing
// it into the loader while we were waiting for the lock.
! if (!is_unsafe_anonymous && loader.not_null()) {
cld = java_lang_ClassLoader::loader_data_acquire(loader());
if (cld != NULL) {
return cld;
}
}
--- 190,208 ----
bool ClassLoaderDataGraph::_safepoint_cleanup_needed = false;
bool ClassLoaderDataGraph::_metaspace_oom = false;
// 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
! ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool has_class_mirror_holder) {
assert_lock_strong(ClassLoaderDataGraph_lock);
ClassLoaderData* cld;
// First check if another thread beat us to creating the CLD and installing
// it into the loader while we were waiting for the lock.
! if (!has_class_mirror_holder && loader.not_null()) {
cld = java_lang_ClassLoader::loader_data_acquire(loader());
if (cld != NULL) {
return cld;
}
}
*** 210,227 ****
// We mustn't GC until we've installed the ClassLoaderData in the Graph since the CLD
// contains oops in _handles that must be walked. GC doesn't walk CLD from the
// loader oop in all collections, particularly young collections.
NoSafepointVerifier no_safepoints;
! cld = new ClassLoaderData(loader, is_unsafe_anonymous);
// First install the new CLD to the Graph.
cld->set_next(_head);
Atomic::release_store(&_head, cld);
// Next associate with the class_loader.
! if (!is_unsafe_anonymous) {
// Use OrderAccess, since readers need to get the loader_data only after
// it's added to the Graph
java_lang_ClassLoader::release_set_loader_data(loader(), cld);
}
--- 210,227 ----
// We mustn't GC until we've installed the ClassLoaderData in the Graph since the CLD
// contains oops in _handles that must be walked. GC doesn't walk CLD from the
// loader oop in all collections, particularly young collections.
NoSafepointVerifier no_safepoints;
! cld = new ClassLoaderData(loader, has_class_mirror_holder);
// First install the new CLD to the Graph.
cld->set_next(_head);
Atomic::release_store(&_head, cld);
// Next associate with the class_loader.
! if (!has_class_mirror_holder) {
// Use OrderAccess, since readers need to get the loader_data only after
// it's added to the Graph
java_lang_ClassLoader::release_set_loader_data(loader(), cld);
}
*** 235,247 ****
ls.cr();
}
return cld;
}
! ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_unsafe_anonymous) {
MutexLocker ml(ClassLoaderDataGraph_lock);
! ClassLoaderData* loader_data = add_to_graph(loader, is_unsafe_anonymous);
return loader_data;
}
void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock);
--- 235,247 ----
ls.cr();
}
return cld;
}
! ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool has_class_mirror_holder) {
MutexLocker ml(ClassLoaderDataGraph_lock);
! ClassLoaderData* loader_data = add_to_graph(loader, has_class_mirror_holder);
return loader_data;
}
void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock);
< prev index next >