8213307: G1 should clean up RMT with ClassUnloadingWithConcurrentMark

Re-enable cleanup of the ResolvedMethodTable after changes in JDK-8206423.

Reviewed-by: shade, coleenp
This commit is contained in:
Thomas Schatzl 2018-11-13 11:45:16 +01:00
parent 8a64d3bc3c
commit 56db122656
6 changed files with 21 additions and 16 deletions

View file

@ -496,11 +496,11 @@ bool ClassLoaderDataGraph::is_valid(ClassLoaderData* loader_data) {
// Move class loader data from main list to the unloaded list for unloading
// and deallocation later.
bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
bool ClassLoaderDataGraph::do_unloading() {
assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
// Indicate whether safepoint cleanup is needed.
_safepoint_cleanup_needed |= do_cleaning;
_safepoint_cleanup_needed = true;
ClassLoaderData* data = _head;
ClassLoaderData* prev = NULL;

View file

@ -88,7 +88,7 @@ class ClassLoaderDataGraph : public AllStatic {
static void loaded_classes_do(KlassClosure* klass_closure);
static void unlocked_loaded_classes_do(KlassClosure* klass_closure);
static void classes_unloading_do(void f(Klass* const));
static bool do_unloading(bool do_cleaning);
static bool do_unloading();
// Expose state to avoid logging overhead in safepoint cleanup tasks.
static inline bool should_clean_metaspaces_and_reset();

View file

@ -1845,15 +1845,14 @@ void SystemDictionary::add_to_hierarchy(InstanceKlass* k, TRAPS) {
// Assumes classes in the SystemDictionary are only unloaded at a safepoint
// Note: anonymous classes are not in the SD.
bool SystemDictionary::do_unloading(GCTimer* gc_timer,
bool do_cleaning) {
bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
bool unloading_occurred;
{
GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
// First, mark for unload all ClassLoaderData referencing a dead class loader.
unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);
unloading_occurred = ClassLoaderDataGraph::do_unloading();
if (unloading_occurred) {
JFR_ONLY(Jfr::on_unloading_classes();)
ClassLoaderDataGraph::clean_module_and_package_info();
@ -1883,7 +1882,7 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer,
_pd_cache_table->trigger_cleanup();
}
if (do_cleaning) {
{
GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
ResolvedMethodTable::trigger_cleanup();
}

View file

@ -347,8 +347,7 @@ public:
// Unload (that is, break root links to) all unmarked classes and
// loaders. Returns "true" iff something was unloaded.
static bool do_unloading(GCTimer* gc_timer,
bool do_cleaning = true);
static bool do_unloading(GCTimer* gc_timer);
// Used by DumpSharedSpaces only to remove classes that failed verification
static void remove_classes_in_error_state();

View file

@ -1655,7 +1655,7 @@ void G1ConcurrentMark::weak_refs_work(bool clear_all_soft_refs) {
// Unload Klasses, String, Code Cache, etc.
if (ClassUnloadingWithConcurrentMark) {
GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm, false /* Defer cleaning */);
bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm);
_g1h->complete_cleaning(&g1_is_alive, purged_classes);
} else {
GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);

View file

@ -23,8 +23,9 @@
/*
* @test
* @bug 8174749
* @bug 8174749 8213307
* @summary MemberNameTable should reuse entries
* @requires vm.gc == "null"
* @library /test/lib
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
@ -71,13 +72,16 @@ public class MemberNameLeak {
}
}
public static void test(String gc) throws Throwable {
public static void test(String gc, boolean doConcurrent) throws Throwable {
// Run this Leak class with logging
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xlog:membername+table=trace",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-Xbootclasspath/a:.",
doConcurrent ? "-XX:+ExplicitGCInvokesConcurrent" : "-XX:-ExplicitGCInvokesConcurrent",
"-XX:+ClassUnloading",
"-XX:+ClassUnloadingWithConcurrentMark",
gc, Leak.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("ResolvedMethod entry added for MemberNameLeak$Leak.callMe()V");
@ -87,11 +91,14 @@ public class MemberNameLeak {
}
public static void main(java.lang.String[] unused) throws Throwable {
test("-XX:+UseG1GC");
test("-XX:+UseParallelGC");
test("-XX:+UseSerialGC");
test("-XX:+UseG1GC", false);
test("-XX:+UseG1GC", true);
test("-XX:+UseParallelGC", false);
test("-XX:+UseSerialGC", false);
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
test("-XX:+UseConcMarkSweepGC");
test("-XX:+UseConcMarkSweepGC", false);
test("-XX:+UseConcMarkSweepGC", true);
}
}
}