mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
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:
parent
8a64d3bc3c
commit
56db122656
6 changed files with 21 additions and 16 deletions
|
@ -496,11 +496,11 @@ bool ClassLoaderDataGraph::is_valid(ClassLoaderData* loader_data) {
|
||||||
|
|
||||||
// Move class loader data from main list to the unloaded list for unloading
|
// Move class loader data from main list to the unloaded list for unloading
|
||||||
// and deallocation later.
|
// and deallocation later.
|
||||||
bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
|
bool ClassLoaderDataGraph::do_unloading() {
|
||||||
assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
|
assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
|
||||||
|
|
||||||
// Indicate whether safepoint cleanup is needed.
|
// Indicate whether safepoint cleanup is needed.
|
||||||
_safepoint_cleanup_needed |= do_cleaning;
|
_safepoint_cleanup_needed = true;
|
||||||
|
|
||||||
ClassLoaderData* data = _head;
|
ClassLoaderData* data = _head;
|
||||||
ClassLoaderData* prev = NULL;
|
ClassLoaderData* prev = NULL;
|
||||||
|
|
|
@ -88,7 +88,7 @@ class ClassLoaderDataGraph : public AllStatic {
|
||||||
static void loaded_classes_do(KlassClosure* klass_closure);
|
static void loaded_classes_do(KlassClosure* klass_closure);
|
||||||
static void unlocked_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 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.
|
// Expose state to avoid logging overhead in safepoint cleanup tasks.
|
||||||
static inline bool should_clean_metaspaces_and_reset();
|
static inline bool should_clean_metaspaces_and_reset();
|
||||||
|
|
|
@ -1845,15 +1845,14 @@ void SystemDictionary::add_to_hierarchy(InstanceKlass* k, TRAPS) {
|
||||||
|
|
||||||
// Assumes classes in the SystemDictionary are only unloaded at a safepoint
|
// Assumes classes in the SystemDictionary are only unloaded at a safepoint
|
||||||
// Note: anonymous classes are not in the SD.
|
// Note: anonymous classes are not in the SD.
|
||||||
bool SystemDictionary::do_unloading(GCTimer* gc_timer,
|
bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
|
||||||
bool do_cleaning) {
|
|
||||||
|
|
||||||
bool unloading_occurred;
|
bool unloading_occurred;
|
||||||
{
|
{
|
||||||
GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
|
GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
|
||||||
|
|
||||||
// First, mark for unload all ClassLoaderData referencing a dead class loader.
|
// 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) {
|
if (unloading_occurred) {
|
||||||
JFR_ONLY(Jfr::on_unloading_classes();)
|
JFR_ONLY(Jfr::on_unloading_classes();)
|
||||||
ClassLoaderDataGraph::clean_module_and_package_info();
|
ClassLoaderDataGraph::clean_module_and_package_info();
|
||||||
|
@ -1883,7 +1882,7 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer,
|
||||||
_pd_cache_table->trigger_cleanup();
|
_pd_cache_table->trigger_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_cleaning) {
|
{
|
||||||
GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
|
GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
|
||||||
ResolvedMethodTable::trigger_cleanup();
|
ResolvedMethodTable::trigger_cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,8 +347,7 @@ public:
|
||||||
|
|
||||||
// Unload (that is, break root links to) all unmarked classes and
|
// Unload (that is, break root links to) all unmarked classes and
|
||||||
// loaders. Returns "true" iff something was unloaded.
|
// loaders. Returns "true" iff something was unloaded.
|
||||||
static bool do_unloading(GCTimer* gc_timer,
|
static bool do_unloading(GCTimer* gc_timer);
|
||||||
bool do_cleaning = true);
|
|
||||||
|
|
||||||
// Used by DumpSharedSpaces only to remove classes that failed verification
|
// Used by DumpSharedSpaces only to remove classes that failed verification
|
||||||
static void remove_classes_in_error_state();
|
static void remove_classes_in_error_state();
|
||||||
|
|
|
@ -1655,7 +1655,7 @@ void G1ConcurrentMark::weak_refs_work(bool clear_all_soft_refs) {
|
||||||
// Unload Klasses, String, Code Cache, etc.
|
// Unload Klasses, String, Code Cache, etc.
|
||||||
if (ClassUnloadingWithConcurrentMark) {
|
if (ClassUnloadingWithConcurrentMark) {
|
||||||
GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
|
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);
|
_g1h->complete_cleaning(&g1_is_alive, purged_classes);
|
||||||
} else {
|
} else {
|
||||||
GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
|
GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8174749
|
* @bug 8174749 8213307
|
||||||
* @summary MemberNameTable should reuse entries
|
* @summary MemberNameTable should reuse entries
|
||||||
|
* @requires vm.gc == "null"
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @build sun.hotspot.WhiteBox
|
* @build sun.hotspot.WhiteBox
|
||||||
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
|
* @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
|
// Run this Leak class with logging
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||||
"-Xlog:membername+table=trace",
|
"-Xlog:membername+table=trace",
|
||||||
"-XX:+UnlockDiagnosticVMOptions",
|
"-XX:+UnlockDiagnosticVMOptions",
|
||||||
"-XX:+WhiteBoxAPI",
|
"-XX:+WhiteBoxAPI",
|
||||||
"-Xbootclasspath/a:.",
|
"-Xbootclasspath/a:.",
|
||||||
|
doConcurrent ? "-XX:+ExplicitGCInvokesConcurrent" : "-XX:-ExplicitGCInvokesConcurrent",
|
||||||
|
"-XX:+ClassUnloading",
|
||||||
|
"-XX:+ClassUnloadingWithConcurrentMark",
|
||||||
gc, Leak.class.getName());
|
gc, Leak.class.getName());
|
||||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
output.shouldContain("ResolvedMethod entry added for MemberNameLeak$Leak.callMe()V");
|
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 {
|
public static void main(java.lang.String[] unused) throws Throwable {
|
||||||
test("-XX:+UseG1GC");
|
test("-XX:+UseG1GC", false);
|
||||||
test("-XX:+UseParallelGC");
|
test("-XX:+UseG1GC", true);
|
||||||
test("-XX:+UseSerialGC");
|
|
||||||
|
test("-XX:+UseParallelGC", false);
|
||||||
|
test("-XX:+UseSerialGC", false);
|
||||||
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
|
if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
|
||||||
test("-XX:+UseConcMarkSweepGC");
|
test("-XX:+UseConcMarkSweepGC", false);
|
||||||
|
test("-XX:+UseConcMarkSweepGC", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue