mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
Use WeakHandle for ClassLoaderData::_holder so that is_alive closure is not needed Reviewed-by: rehn, kbarrett
This commit is contained in:
parent
21f636f3cf
commit
d187884156
13 changed files with 273 additions and 48 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "code/codeCache.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "gc/shared/gcTraceTime.inline.hpp"
|
||||
#include "gc/shared/oopStorage.inline.hpp"
|
||||
#include "interpreter/bytecodeStream.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
|
@ -117,6 +118,8 @@ InstanceKlass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass =
|
|||
|
||||
const int defaultProtectionDomainCacheSize = 1009;
|
||||
|
||||
OopStorage* SystemDictionary::_vm_weak_oop_storage = NULL;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Java-level SystemLoader and PlatformLoader
|
||||
|
@ -1012,7 +1015,9 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
|
|||
CHECK_NULL);
|
||||
|
||||
if (host_klass != NULL && k != NULL) {
|
||||
// If it's anonymous, initialize it now, since nobody else will.
|
||||
// Anonymous classes must update ClassLoaderData holder (was host_klass loader)
|
||||
// so that they can be unloaded when the mirror is no longer referenced.
|
||||
k->class_loader_data()->initialize_holder(Handle(THREAD, k->java_mirror()));
|
||||
|
||||
{
|
||||
MutexLocker mu_r(Compile_lock, THREAD);
|
||||
|
@ -1032,6 +1037,8 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
|
|||
if (cp_patches != NULL) {
|
||||
k->constants()->patch_resolved_references(cp_patches);
|
||||
}
|
||||
|
||||
// If it's anonymous, initialize it now, since nobody else will.
|
||||
k->eager_initialize(CHECK_NULL);
|
||||
|
||||
// notify jvmti
|
||||
|
@ -1848,6 +1855,10 @@ bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive,
|
|||
GCTimer* gc_timer,
|
||||
bool do_cleaning) {
|
||||
|
||||
{
|
||||
GCTraceTime(Debug, gc, phases) t("SystemDictionary WeakHandle cleaning", gc_timer);
|
||||
vm_weak_oop_storage()->weak_oops_do(is_alive, &do_nothing_cl);
|
||||
}
|
||||
|
||||
bool unloading_occurred;
|
||||
{
|
||||
|
@ -1896,9 +1907,11 @@ void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
|
|||
// Only the protection domain oops contain references into the heap. Iterate
|
||||
// over all of them.
|
||||
_pd_cache_table->oops_do(strong);
|
||||
vm_weak_oop_storage()->oops_do(strong);
|
||||
} else {
|
||||
if (weak != NULL) {
|
||||
_pd_cache_table->oops_do(weak);
|
||||
vm_weak_oop_storage()->oops_do(weak);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1924,6 +1937,8 @@ void SystemDictionary::oops_do(OopClosure* f) {
|
|||
invoke_method_table()->oops_do(f);
|
||||
|
||||
ResolvedMethodTable::oops_do(f);
|
||||
|
||||
vm_weak_oop_storage()->oops_do(f);
|
||||
}
|
||||
|
||||
// CDS: scan and relocate all classes in the system dictionary.
|
||||
|
@ -3105,3 +3120,15 @@ const char* SystemDictionary::loader_name(const ClassLoaderData* loader_data) {
|
|||
return (loader_data->class_loader() == NULL ? "<bootloader>" :
|
||||
SystemDictionary::loader_name(loader_data->class_loader()));
|
||||
}
|
||||
|
||||
void SystemDictionary::initialize_oop_storage() {
|
||||
_vm_weak_oop_storage =
|
||||
new OopStorage("VM Weak Oop Handles",
|
||||
VMWeakAlloc_lock,
|
||||
VMWeakActive_lock);
|
||||
}
|
||||
|
||||
OopStorage* SystemDictionary::vm_weak_oop_storage() {
|
||||
assert(_vm_weak_oop_storage != NULL, "Uninitialized");
|
||||
return _vm_weak_oop_storage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue