diff options
author | fmatte <none@none> | 2018-07-20 03:07:49 -0400 |
---|---|---|
committer | fmatte <none@none> | 2018-07-20 03:07:49 -0400 |
commit | 2cff25862702a3a4a5f543b37fbcf6de9eb0577f (patch) | |
tree | 32360de5fe2c15e0a60a9d6b1a19e6a0ac4f331c /src/share/vm/gc_implementation/g1 | |
parent | d74660ae2ef0975419d1571c6bac12a758cd6ff4 (diff) | |
download | jdk8u_hotspot-2cff25862702a3a4a5f543b37fbcf6de9eb0577f.tar.gz |
8114823: G1 doesn't honor request to disable class unloading
Reviewed-by: tschatzl
Diffstat (limited to 'src/share/vm/gc_implementation/g1')
-rw-r--r-- | src/share/vm/gc_implementation/g1/g1MarkSweep.cpp | 29 | ||||
-rw-r--r-- | src/share/vm/gc_implementation/g1/g1RootProcessor.cpp | 51 | ||||
-rw-r--r-- | src/share/vm/gc_implementation/g1/g1RootProcessor.hpp | 23 |
3 files changed, 79 insertions, 24 deletions
diff --git a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index b1bc68275..69084775e 100644 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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 @@ -135,9 +135,16 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); { G1RootProcessor root_processor(g1h); - root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, - &GenMarkSweep::follow_cld_closure, - &follow_code_closure); + if (ClassUnloading) { + root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } else { + root_processor.process_all_roots_no_string_table( + &GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } } // Process reference objects found during marking @@ -158,15 +165,17 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, // This is the point where the entire marking should have completed. assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); - // Unload classes and purge the SystemDictionary. - bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); + if (ClassUnloading) { - // Unload nmethods. - CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class); + // Unload classes and purge the SystemDictionary. + bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); - // Prune dead klasses from subklass/sibling/implementor lists. - Klass::clean_weak_klass_links(&GenMarkSweep::is_alive); + // Unload nmethods. + CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class); + // Prune dead klasses from subklass/sibling/implementor lists. + Klass::clean_weak_klass_links(&GenMarkSweep::is_alive); + } // Delete entries for dead interned string and clean up unreferenced symbols in symbol table. G1CollectedHeap::heap()->unlink_string_and_symbol_table(&GenMarkSweep::is_alive); diff --git a/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp b/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp index b27696d2d..5b27a017a 100644 --- a/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -156,7 +156,7 @@ void G1RootProcessor::evacuate_roots(OopClosure* scan_non_heap_roots, } process_vm_roots(strong_roots, weak_roots, phase_times, worker_i); - + process_string_table_roots(weak_roots, phase_times, worker_i); { // Now the CM ref_processor roots. G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CMRefRoots, worker_i); @@ -223,18 +223,34 @@ void G1RootProcessor::process_strong_roots(OopClosure* oops, void G1RootProcessor::process_all_roots(OopClosure* oops, CLDClosure* clds, - CodeBlobClosure* blobs) { + CodeBlobClosure* blobs, + bool process_string_table) { process_java_roots(oops, NULL, clds, clds, NULL, NULL, 0); process_vm_roots(oops, oops, NULL, 0); - if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { - CodeCache::blobs_do(blobs); - } + if (process_string_table) { + process_string_table_roots(oops, NULL, 0); + } + process_code_cache_roots(blobs, NULL, 0); _process_strong_tasks.all_tasks_completed(); } +void G1RootProcessor::process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + process_all_roots(oops, clds, blobs, true); +} + +void G1RootProcessor::process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + assert(!ClassUnloading, "Should only be used when class unloading is disabled"); + process_all_roots(oops, clds, blobs, false); +} + + void G1RootProcessor::process_java_roots(OopClosure* strong_roots, CLDClosure* thread_stack_clds, CLDClosure* strong_clds, @@ -311,14 +327,23 @@ void G1RootProcessor::process_vm_roots(OopClosure* strong_roots, SystemDictionary::roots_oops_do(strong_roots, weak_roots); } } +} - { - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); - // All threads execute the following. A specific chunk of buckets - // from the StringTable are the individual tasks. - if (weak_roots != NULL) { - StringTable::possibly_parallel_oops_do(weak_roots); - } +void G1RootProcessor::process_string_table_roots(OopClosure* weak_roots, G1GCPhaseTimes* phase_times, + uint worker_i) { + assert(weak_roots != NULL, "Should only be called when all roots are processed"); + + G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); + // All threads execute the following. A specific chunk of buckets + // from the StringTable are the individual tasks. + StringTable::possibly_parallel_oops_do(weak_roots); +} + +void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i) { + if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { + CodeCache::blobs_do(code_closure); } } diff --git a/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp b/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp index 1cce9f357..ad4e75ba3 100644 --- a/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp +++ b/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -34,6 +34,7 @@ class CodeBlobClosure; class G1CollectedHeap; class G1GCPhaseTimes; class G1ParPushHeapRSClosure; +class G1RootClosures; class Monitor; class OopClosure; class SubTasksDone; @@ -71,6 +72,11 @@ class G1RootProcessor : public StackObj { void worker_has_discovered_all_strong_classes(); void wait_until_all_strong_classes_discovered(); + void process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs, + bool process_string_table); + void process_java_roots(OopClosure* scan_non_heap_roots, CLDClosure* thread_stack_clds, CLDClosure* scan_strong_clds, @@ -84,6 +90,14 @@ class G1RootProcessor : public StackObj { G1GCPhaseTimes* phase_times, uint worker_i); + void process_string_table_roots(OopClosure* scan_non_heap_weak_roots, + G1GCPhaseTimes* phase_times, + uint worker_i); + + void process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i); + public: G1RootProcessor(G1CollectedHeap* g1h); @@ -114,6 +128,13 @@ public: OopClosure* scan_non_heap_weak_roots, uint worker_i); + // Apply oops, clds and blobs to strongly and weakly reachable roots in the system, + // the only thing different from process_all_roots is that we skip the string table + // to avoid keeping every string live when doing class unloading. + void process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs); + // Inform the root processor about the number of worker threads void set_num_workers(int active_workers); }; |