8047125: (ref) More phantom object references
Reviewed-by: mchung, dfuchs, ahgross, jmasa, brutisso, mgerdin
This commit is contained in:
parent
b986429c73
commit
72a9a49cfb
@ -1905,11 +1905,12 @@ void SystemDictionary::initialize_preloaded_classes(TRAPS) {
|
|||||||
InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
|
InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
|
||||||
InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
|
InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
|
||||||
|
|
||||||
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
|
initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Cleaner_klass), scan, CHECK);
|
||||||
InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
|
InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
|
||||||
InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
|
InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
|
||||||
InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
|
InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
|
||||||
InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
|
InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
|
||||||
|
InstanceKlass::cast(WK_KLASS(Cleaner_klass))->set_reference_type(REF_CLEANER);
|
||||||
|
|
||||||
// JSR 292 classes
|
// JSR 292 classes
|
||||||
WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
|
WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
|
||||||
|
@ -128,6 +128,7 @@ class Ticks;
|
|||||||
do_klass(WeakReference_klass, java_lang_ref_WeakReference, Pre ) \
|
do_klass(WeakReference_klass, java_lang_ref_WeakReference, Pre ) \
|
||||||
do_klass(FinalReference_klass, java_lang_ref_FinalReference, Pre ) \
|
do_klass(FinalReference_klass, java_lang_ref_FinalReference, Pre ) \
|
||||||
do_klass(PhantomReference_klass, java_lang_ref_PhantomReference, Pre ) \
|
do_klass(PhantomReference_klass, java_lang_ref_PhantomReference, Pre ) \
|
||||||
|
do_klass(Cleaner_klass, sun_misc_Cleaner, Pre ) \
|
||||||
do_klass(Finalizer_klass, java_lang_ref_Finalizer, Pre ) \
|
do_klass(Finalizer_klass, java_lang_ref_Finalizer, Pre ) \
|
||||||
\
|
\
|
||||||
do_klass(Thread_klass, java_lang_Thread, Pre ) \
|
do_klass(Thread_klass, java_lang_Thread, Pre ) \
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
template(java_lang_ref_WeakReference, "java/lang/ref/WeakReference") \
|
template(java_lang_ref_WeakReference, "java/lang/ref/WeakReference") \
|
||||||
template(java_lang_ref_FinalReference, "java/lang/ref/FinalReference") \
|
template(java_lang_ref_FinalReference, "java/lang/ref/FinalReference") \
|
||||||
template(java_lang_ref_PhantomReference, "java/lang/ref/PhantomReference") \
|
template(java_lang_ref_PhantomReference, "java/lang/ref/PhantomReference") \
|
||||||
|
template(sun_misc_Cleaner, "sun/misc/Cleaner") \
|
||||||
template(java_lang_ref_Finalizer, "java/lang/ref/Finalizer") \
|
template(java_lang_ref_Finalizer, "java/lang/ref/Finalizer") \
|
||||||
template(java_lang_reflect_AccessibleObject, "java/lang/reflect/AccessibleObject") \
|
template(java_lang_reflect_AccessibleObject, "java/lang/reflect/AccessibleObject") \
|
||||||
template(java_lang_reflect_Method, "java/lang/reflect/Method") \
|
template(java_lang_reflect_Method, "java/lang/reflect/Method") \
|
||||||
|
@ -118,6 +118,7 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
|
|||||||
_discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q];
|
_discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q];
|
||||||
_discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q];
|
_discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q];
|
||||||
_discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
|
_discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
|
||||||
|
_discoveredCleanerRefs = &_discoveredPhantomRefs[_max_num_q];
|
||||||
|
|
||||||
// Initialize all entries to NULL
|
// Initialize all entries to NULL
|
||||||
for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||||
@ -246,6 +247,13 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(
|
|||||||
phantom_count =
|
phantom_count =
|
||||||
process_discovered_reflist(_discoveredPhantomRefs, NULL, false,
|
process_discovered_reflist(_discoveredPhantomRefs, NULL, false,
|
||||||
is_alive, keep_alive, complete_gc, task_executor);
|
is_alive, keep_alive, complete_gc, task_executor);
|
||||||
|
|
||||||
|
// Process cleaners, but include them in phantom statistics. We expect
|
||||||
|
// Cleaner references to be temporary, and don't want to deal with
|
||||||
|
// possible incompatibilities arising from making it more visible.
|
||||||
|
phantom_count +=
|
||||||
|
process_discovered_reflist(_discoveredCleanerRefs, NULL, false,
|
||||||
|
is_alive, keep_alive, complete_gc, task_executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weak global JNI references. It would make more sense (semantically) to
|
// Weak global JNI references. It would make more sense (semantically) to
|
||||||
@ -885,6 +893,7 @@ void ReferenceProcessor::balance_all_queues() {
|
|||||||
balance_queues(_discoveredWeakRefs);
|
balance_queues(_discoveredWeakRefs);
|
||||||
balance_queues(_discoveredFinalRefs);
|
balance_queues(_discoveredFinalRefs);
|
||||||
balance_queues(_discoveredPhantomRefs);
|
balance_queues(_discoveredPhantomRefs);
|
||||||
|
balance_queues(_discoveredCleanerRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@ -998,6 +1007,9 @@ inline DiscoveredList* ReferenceProcessor::get_discovered_list(ReferenceType rt)
|
|||||||
case REF_PHANTOM:
|
case REF_PHANTOM:
|
||||||
list = &_discoveredPhantomRefs[id];
|
list = &_discoveredPhantomRefs[id];
|
||||||
break;
|
break;
|
||||||
|
case REF_CLEANER:
|
||||||
|
list = &_discoveredCleanerRefs[id];
|
||||||
|
break;
|
||||||
case REF_NONE:
|
case REF_NONE:
|
||||||
// we should not reach here if we are an InstanceRefKlass
|
// we should not reach here if we are an InstanceRefKlass
|
||||||
default:
|
default:
|
||||||
@ -1263,6 +1275,17 @@ void ReferenceProcessor::preclean_discovered_references(
|
|||||||
preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive,
|
preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive,
|
||||||
keep_alive, complete_gc, yield);
|
keep_alive, complete_gc, yield);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleaner references. Included in timing for phantom references. We
|
||||||
|
// expect Cleaner references to be temporary, and don't want to deal with
|
||||||
|
// possible incompatibilities arising from making it more visible.
|
||||||
|
for (uint i = 0; i < _max_num_q; i++) {
|
||||||
|
if (yield->should_return()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
preclean_discovered_reflist(_discoveredCleanerRefs[i], is_alive,
|
||||||
|
keep_alive, complete_gc, yield);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1331,6 +1354,7 @@ const char* ReferenceProcessor::list_name(uint i) {
|
|||||||
case 1: return "WeakRef";
|
case 1: return "WeakRef";
|
||||||
case 2: return "FinalRef";
|
case 2: return "FinalRef";
|
||||||
case 3: return "PhantomRef";
|
case 3: return "PhantomRef";
|
||||||
|
case 4: return "CleanerRef";
|
||||||
}
|
}
|
||||||
ShouldNotReachHere();
|
ShouldNotReachHere();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -264,9 +264,10 @@ class ReferenceProcessor : public CHeapObj<mtGC> {
|
|||||||
DiscoveredList* _discoveredWeakRefs;
|
DiscoveredList* _discoveredWeakRefs;
|
||||||
DiscoveredList* _discoveredFinalRefs;
|
DiscoveredList* _discoveredFinalRefs;
|
||||||
DiscoveredList* _discoveredPhantomRefs;
|
DiscoveredList* _discoveredPhantomRefs;
|
||||||
|
DiscoveredList* _discoveredCleanerRefs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
|
static int number_of_subclasses_of_ref() { return (REF_CLEANER - REF_OTHER); }
|
||||||
|
|
||||||
uint num_q() { return _num_q; }
|
uint num_q() { return _num_q; }
|
||||||
uint max_num_q() { return _max_num_q; }
|
uint max_num_q() { return _max_num_q; }
|
||||||
|
@ -35,7 +35,8 @@ enum ReferenceType {
|
|||||||
REF_SOFT, // Subclass of java/lang/ref/SoftReference
|
REF_SOFT, // Subclass of java/lang/ref/SoftReference
|
||||||
REF_WEAK, // Subclass of java/lang/ref/WeakReference
|
REF_WEAK, // Subclass of java/lang/ref/WeakReference
|
||||||
REF_FINAL, // Subclass of java/lang/ref/FinalReference
|
REF_FINAL, // Subclass of java/lang/ref/FinalReference
|
||||||
REF_PHANTOM // Subclass of java/lang/ref/PhantomReference
|
REF_PHANTOM, // Subclass of java/lang/ref/PhantomReference
|
||||||
|
REF_CLEANER // Subclass of sun/misc/Cleaner
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARE_VM_MEMORY_REFRERENCETYPE_HPP
|
#endif // SHARE_VM_MEMORY_REFRERENCETYPE_HPP
|
||||||
|
@ -661,6 +661,7 @@ typedef TwoOopHashtable<Symbol*, mtClass> SymbolTwoOopHashtable;
|
|||||||
static_field(SystemDictionary, WK_KLASS(WeakReference_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(WeakReference_klass), Klass*) \
|
||||||
static_field(SystemDictionary, WK_KLASS(FinalReference_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(FinalReference_klass), Klass*) \
|
||||||
static_field(SystemDictionary, WK_KLASS(PhantomReference_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(PhantomReference_klass), Klass*) \
|
||||||
|
static_field(SystemDictionary, WK_KLASS(Cleaner_klass), Klass*) \
|
||||||
static_field(SystemDictionary, WK_KLASS(Finalizer_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(Finalizer_klass), Klass*) \
|
||||||
static_field(SystemDictionary, WK_KLASS(Thread_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(Thread_klass), Klass*) \
|
||||||
static_field(SystemDictionary, WK_KLASS(ThreadGroup_klass), Klass*) \
|
static_field(SystemDictionary, WK_KLASS(ThreadGroup_klass), Klass*) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user