Thu, 13 Feb 2014 17:44:39 +0100
8034761: Remove the do_code_roots parameter from process_strong_roots
Reviewed-by: tschatzl, mgerdin, jmasa
1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Feb 10 12:58:09 2014 +0100 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu Feb 13 17:44:39 2014 +0100 1.3 @@ -3040,7 +3040,6 @@ 1.4 true, // activate StrongRootsScope 1.5 SharedHeap::ScanningOption(roots_scanning_options()), 1.6 ¬Older, 1.7 - true, // walk code active on stacks 1.8 NULL, 1.9 NULL); // SSS: Provide correct closure 1.10 1.11 @@ -3107,7 +3106,6 @@ 1.12 true, // activate StrongRootsScope 1.13 SharedHeap::ScanningOption(roots_scanning_options()), 1.14 ¬Older, 1.15 - true, // walk code active on stacks 1.16 NULL, 1.17 &klass_closure); 1.18 1.19 @@ -3686,12 +3684,6 @@ 1.20 ResourceMark rm; 1.21 HandleMark hm; 1.22 1.23 - FalseClosure falseClosure; 1.24 - // In the case of a synchronous collection, we will elide the 1.25 - // remark step, so it's important to catch all the nmethod oops 1.26 - // in this step. 1.27 - // The final 'true' flag to gen_process_strong_roots will ensure this. 1.28 - // If 'async' is true, we can relax the nmethod tracing. 1.29 MarkRefsIntoClosure notOlder(_span, &_markBitMap); 1.30 GenCollectedHeap* gch = GenCollectedHeap::heap(); 1.31 1.32 @@ -3744,7 +3736,6 @@ 1.33 true, // activate StrongRootsScope 1.34 SharedHeap::ScanningOption(roots_scanning_options()), 1.35 ¬Older, 1.36 - true, // walk all of code cache if (so & SO_AllCodeCache) 1.37 NULL, 1.38 &klass_closure); 1.39 } 1.40 @@ -5243,7 +5234,6 @@ 1.41 false, // this is parallel code 1.42 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.43 &par_mri_cl, 1.44 - true, // walk all of code cache if (so & SO_AllCodeCache) 1.45 NULL, 1.46 &klass_closure); 1.47 assert(_collector->should_unload_classes() 1.48 @@ -5379,7 +5369,6 @@ 1.49 false, // this is parallel code 1.50 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.51 &par_mrias_cl, 1.52 - true, // walk all of code cache if (so & SO_AllCodeCache) 1.53 NULL, 1.54 NULL); // The dirty klasses will be handled below 1.55 assert(_collector->should_unload_classes() 1.56 @@ -5969,7 +5958,6 @@ 1.57 false, // use the local StrongRootsScope 1.58 SharedHeap::ScanningOption(roots_scanning_options()), 1.59 &mrias_cl, 1.60 - true, // walk code active on stacks 1.61 NULL, 1.62 NULL); // The dirty klasses will be handled below 1.63
2.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Mon Feb 10 12:58:09 2014 +0100 2.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Thu Feb 13 17:44:39 2014 +0100 2.3 @@ -1383,13 +1383,6 @@ 2.4 // Closures of various sorts used by CMS to accomplish its work 2.5 // 2.6 2.7 -// This closure is used to check that a certain set of oops is empty. 2.8 -class FalseClosure: public OopClosure { 2.9 - public: 2.10 - void do_oop(oop* p) { guarantee(false, "Should be an empty set"); } 2.11 - void do_oop(narrowOop* p) { guarantee(false, "Should be an empty set"); } 2.12 -}; 2.13 - 2.14 // This closure is used to do concurrent marking from the roots 2.15 // following the first checkpoint. 2.16 class MarkFromRootsClosure: public BitMapClosure {
3.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Feb 10 12:58:09 2014 +0100 3.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Feb 13 17:44:39 2014 +0100 3.3 @@ -3390,13 +3390,12 @@ 3.4 3.5 if (!silent) { gclog_or_tty->print("Roots "); } 3.6 VerifyRootsClosure rootsCl(vo); 3.7 - G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo); 3.8 - G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl); 3.9 VerifyKlassClosure klassCl(this, &rootsCl); 3.10 3.11 // We apply the relevant closures to all the oops in the 3.12 - // system dictionary, the string table and the code cache. 3.13 - const int so = SO_AllClasses | SO_Strings | SO_AllCodeCache; 3.14 + // system dictionary, class loader data graph and the string table. 3.15 + // Don't verify the code cache here, since it's verified below. 3.16 + const int so = SO_AllClasses | SO_Strings; 3.17 3.18 // Need cleared claim bits for the strong roots processing 3.19 ClassLoaderDataGraph::clear_claimed_marks(); 3.20 @@ -3404,10 +3403,14 @@ 3.21 process_strong_roots(true, // activate StrongRootsScope 3.22 ScanningOption(so), // roots scanning options 3.23 &rootsCl, 3.24 - &blobsCl, 3.25 &klassCl 3.26 ); 3.27 3.28 + // Verify the nmethods in the code cache. 3.29 + G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo); 3.30 + G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl); 3.31 + CodeCache::blobs_do(&blobsCl); 3.32 + 3.33 bool failures = rootsCl.failures() || codeRootsCl.failures(); 3.34 3.35 if (vo != VerifyOption_G1UseMarkWord) { 3.36 @@ -4865,12 +4868,9 @@ 3.37 3.38 BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); 3.39 3.40 - CodeBlobToOopClosure scan_code_roots(&buf_scan_non_heap_roots, true /* do_marking */); 3.41 - 3.42 process_strong_roots(false, // no scoping; this is parallel code 3.43 so, 3.44 &buf_scan_non_heap_roots, 3.45 - &scan_code_roots, 3.46 scan_klasses 3.47 ); 3.48 3.49 @@ -4930,12 +4930,6 @@ 3.50 _process_strong_tasks->all_tasks_completed(); 3.51 } 3.52 3.53 -void 3.54 -G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) { 3.55 - CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false); 3.56 - SharedHeap::process_weak_roots(root_closure, &roots_in_blobs); 3.57 -} 3.58 - 3.59 class G1StringSymbolTableUnlinkTask : public AbstractGangTask { 3.60 private: 3.61 BoolObjectClosure* _is_alive;
4.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Mon Feb 10 12:58:09 2014 +0100 4.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Thu Feb 13 17:44:39 2014 +0100 4.3 @@ -834,11 +834,6 @@ 4.4 G1KlassScanClosure* scan_klasses, 4.5 uint worker_i); 4.6 4.7 - // Apply "blk" to all the weak roots of the system. These include 4.8 - // JNI weak roots, the code cache, system dictionary, symbol table, 4.9 - // string table, and referents of reachable weak refs. 4.10 - void g1_process_weak_roots(OopClosure* root_closure); 4.11 - 4.12 // Notifies all the necessary spaces that the committed space has 4.13 // been updated (either expanded or shrunk). It should be called 4.14 // after _g1_storage is updated.
5.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Mon Feb 10 12:58:09 2014 +0100 5.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Thu Feb 13 17:44:39 2014 +0100 5.3 @@ -134,7 +134,6 @@ 5.4 sh->process_strong_roots(true, // activate StrongRootsScope 5.5 SharedHeap::SO_SystemClasses, 5.6 &GenMarkSweep::follow_root_closure, 5.7 - &GenMarkSweep::follow_code_root_closure, 5.8 &GenMarkSweep::follow_klass_closure); 5.9 5.10 // Process reference objects found during marking 5.11 @@ -308,9 +307,8 @@ 5.12 ClassLoaderDataGraph::clear_claimed_marks(); 5.13 5.14 sh->process_strong_roots(true, // activate StrongRootsScope 5.15 - SharedHeap::SO_AllClasses, 5.16 + SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, 5.17 &GenMarkSweep::adjust_pointer_closure, 5.18 - NULL, // do not touch code cache here 5.19 &GenMarkSweep::adjust_klass_closure); 5.20 5.21 assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity"); 5.22 @@ -318,7 +316,7 @@ 5.23 5.24 // Now adjust pointers in remaining weak roots. (All of which should 5.25 // have been cleared if they pointed to non-surviving objects.) 5.26 - g1h->g1_process_weak_roots(&GenMarkSweep::adjust_pointer_closure); 5.27 + sh->process_weak_roots(&GenMarkSweep::adjust_pointer_closure); 5.28 5.29 if (G1StringDedup::is_enabled()) { 5.30 G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
6.1 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Mon Feb 10 12:58:09 2014 +0100 6.2 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu Feb 13 17:44:39 2014 +0100 6.3 @@ -623,7 +623,6 @@ 6.4 false, // no scope; this is parallel code 6.5 SharedHeap::ScanningOption(so), 6.6 &par_scan_state.to_space_root_closure(), 6.7 - true, // walk *all* scavengable nmethods 6.8 &par_scan_state.older_gen_closure(), 6.9 &klass_scan_closure); 6.10 par_scan_state.end_strong_roots();
7.1 --- a/src/share/vm/gc_implementation/shared/markSweep.cpp Mon Feb 10 12:58:09 2014 +0100 7.2 +++ b/src/share/vm/gc_implementation/shared/markSweep.cpp Thu Feb 13 17:44:39 2014 +0100 7.3 @@ -49,7 +49,6 @@ 7.4 SerialOldTracer* MarkSweep::_gc_tracer = NULL; 7.5 7.6 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; 7.7 -CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); 7.8 7.9 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } 7.10 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }
8.1 --- a/src/share/vm/gc_implementation/shared/markSweep.hpp Mon Feb 10 12:58:09 2014 +0100 8.2 +++ b/src/share/vm/gc_implementation/shared/markSweep.hpp Thu Feb 13 17:44:39 2014 +0100 8.3 @@ -143,7 +143,6 @@ 8.4 // Public closures 8.5 static IsAliveClosure is_alive; 8.6 static FollowRootClosure follow_root_closure; 8.7 - static CodeBlobToOopClosure follow_code_root_closure; // => follow_root_closure 8.8 static MarkAndPushClosure mark_and_push_closure; 8.9 static FollowKlassClosure follow_klass_closure; 8.10 static FollowStackClosure follow_stack_closure;
9.1 --- a/src/share/vm/memory/defNewGeneration.cpp Mon Feb 10 12:58:09 2014 +0100 9.2 +++ b/src/share/vm/memory/defNewGeneration.cpp Thu Feb 13 17:44:39 2014 +0100 9.3 @@ -630,7 +630,6 @@ 9.4 true, // activate StrongRootsScope 9.5 SharedHeap::ScanningOption(so), 9.6 &fsc_with_no_gc_barrier, 9.7 - true, // walk *all* scavengable nmethods 9.8 &fsc_with_gc_barrier, 9.9 &klass_scan_closure); 9.10
10.1 --- a/src/share/vm/memory/genCollectedHeap.cpp Mon Feb 10 12:58:09 2014 +0100 10.2 +++ b/src/share/vm/memory/genCollectedHeap.cpp Thu Feb 13 17:44:39 2014 +0100 10.3 @@ -599,20 +599,12 @@ 10.4 bool activate_scope, 10.5 SharedHeap::ScanningOption so, 10.6 OopsInGenClosure* not_older_gens, 10.7 - bool do_code_roots, 10.8 OopsInGenClosure* older_gens, 10.9 KlassClosure* klass_closure) { 10.10 // General strong roots. 10.11 10.12 - if (!do_code_roots) { 10.13 - SharedHeap::process_strong_roots(activate_scope, so, 10.14 - not_older_gens, NULL, klass_closure); 10.15 - } else { 10.16 - bool do_code_marking = (activate_scope || nmethod::oops_do_marking_is_active()); 10.17 - CodeBlobToOopClosure code_roots(not_older_gens, /*do_marking=*/ do_code_marking); 10.18 - SharedHeap::process_strong_roots(activate_scope, so, 10.19 - not_older_gens, &code_roots, klass_closure); 10.20 - } 10.21 + SharedHeap::process_strong_roots(activate_scope, so, 10.22 + not_older_gens, klass_closure); 10.23 10.24 if (younger_gens_as_roots) { 10.25 if (!_gen_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { 10.26 @@ -634,9 +626,8 @@ 10.27 _gen_process_strong_tasks->all_tasks_completed(); 10.28 } 10.29 10.30 -void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure, 10.31 - CodeBlobClosure* code_roots) { 10.32 - SharedHeap::process_weak_roots(root_closure, code_roots); 10.33 +void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { 10.34 + SharedHeap::process_weak_roots(root_closure); 10.35 // "Local" "weak" refs 10.36 for (int i = 0; i < _n_gens; i++) { 10.37 _gens[i]->ref_processor()->weak_oops_do(root_closure);
11.1 --- a/src/share/vm/memory/genCollectedHeap.hpp Mon Feb 10 12:58:09 2014 +0100 11.2 +++ b/src/share/vm/memory/genCollectedHeap.hpp Thu Feb 13 17:44:39 2014 +0100 11.3 @@ -422,15 +422,13 @@ 11.4 bool activate_scope, 11.5 SharedHeap::ScanningOption so, 11.6 OopsInGenClosure* not_older_gens, 11.7 - bool do_code_roots, 11.8 OopsInGenClosure* older_gens, 11.9 KlassClosure* klass_closure); 11.10 11.11 - // Apply "blk" to all the weak roots of the system. These include 11.12 - // JNI weak roots, the code cache, system dictionary, symbol table, 11.13 - // string table, and referents of reachable weak refs. 11.14 - void gen_process_weak_roots(OopClosure* root_closure, 11.15 - CodeBlobClosure* code_roots); 11.16 + // Apply "root_closure" to all the weak roots of the system. 11.17 + // These include JNI weak roots, string table, 11.18 + // and referents of reachable weak refs. 11.19 + void gen_process_weak_roots(OopClosure* root_closure); 11.20 11.21 // Set the saved marks of generations, if that makes sense. 11.22 // In particular, if any generation might iterate over the oops
12.1 --- a/src/share/vm/memory/genMarkSweep.cpp Mon Feb 10 12:58:09 2014 +0100 12.2 +++ b/src/share/vm/memory/genMarkSweep.cpp Thu Feb 13 17:44:39 2014 +0100 12.3 @@ -212,7 +212,6 @@ 12.4 true, // activate StrongRootsScope 12.5 SharedHeap::SO_SystemClasses, 12.6 &follow_root_closure, 12.7 - true, // walk code active on stacks 12.8 &follow_root_closure, 12.9 &follow_klass_closure); 12.10 12.11 @@ -295,18 +294,12 @@ 12.12 gch->gen_process_strong_roots(level, 12.13 false, // Younger gens are not roots. 12.14 true, // activate StrongRootsScope 12.15 - SharedHeap::SO_AllClasses, 12.16 + SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, 12.17 &adjust_pointer_closure, 12.18 - false, // do not walk code 12.19 &adjust_pointer_closure, 12.20 &adjust_klass_closure); 12.21 12.22 - // Now adjust pointers in remaining weak roots. (All of which should 12.23 - // have been cleared if they pointed to non-surviving objects.) 12.24 - CodeBlobToOopClosure adjust_code_pointer_closure(&adjust_pointer_closure, 12.25 - /*do_marking=*/ false); 12.26 - gch->gen_process_weak_roots(&adjust_pointer_closure, 12.27 - &adjust_code_pointer_closure); 12.28 + gch->gen_process_weak_roots(&adjust_pointer_closure); 12.29 12.30 adjust_marks(); 12.31 GenAdjustPointersClosure blk;
13.1 --- a/src/share/vm/memory/sharedHeap.cpp Mon Feb 10 12:58:09 2014 +0100 13.2 +++ b/src/share/vm/memory/sharedHeap.cpp Thu Feb 13 17:44:39 2014 +0100 13.3 @@ -141,7 +141,6 @@ 13.4 void SharedHeap::process_strong_roots(bool activate_scope, 13.5 ScanningOption so, 13.6 OopClosure* roots, 13.7 - CodeBlobClosure* code_roots, 13.8 KlassClosure* klass_closure) { 13.9 StrongRootsScope srs(this, activate_scope); 13.10 13.11 @@ -158,15 +157,17 @@ 13.12 if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) 13.13 JNIHandles::oops_do(roots); 13.14 13.15 + CodeBlobToOopClosure code_roots(roots, true); 13.16 + 13.17 CLDToOopClosure roots_from_clds(roots); 13.18 // If we limit class scanning to SO_SystemClasses we need to apply a CLD closure to 13.19 // CLDs which are strongly reachable from the thread stacks. 13.20 CLDToOopClosure* roots_from_clds_p = ((so & SO_SystemClasses) ? &roots_from_clds : NULL); 13.21 // All threads execute this; the individual threads are task groups. 13.22 if (CollectedHeap::use_parallel_gc_threads()) { 13.23 - Threads::possibly_parallel_oops_do(roots, roots_from_clds_p, code_roots); 13.24 + Threads::possibly_parallel_oops_do(roots, roots_from_clds_p, &code_roots); 13.25 } else { 13.26 - Threads::oops_do(roots, roots_from_clds_p, code_roots); 13.27 + Threads::oops_do(roots, roots_from_clds_p, &code_roots); 13.28 } 13.29 13.30 if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) 13.31 @@ -208,17 +209,17 @@ 13.32 13.33 if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { 13.34 if (so & SO_ScavengeCodeCache) { 13.35 - assert(code_roots != NULL, "must supply closure for code cache"); 13.36 + assert(&code_roots != NULL, "must supply closure for code cache"); 13.37 13.38 // We only visit parts of the CodeCache when scavenging. 13.39 - CodeCache::scavenge_root_nmethods_do(code_roots); 13.40 + CodeCache::scavenge_root_nmethods_do(&code_roots); 13.41 } 13.42 if (so & SO_AllCodeCache) { 13.43 - assert(code_roots != NULL, "must supply closure for code cache"); 13.44 + assert(&code_roots != NULL, "must supply closure for code cache"); 13.45 13.46 // CMSCollector uses this to do intermediate-strength collections. 13.47 // We scan the entire code cache, since CodeCache::do_unloading is not called. 13.48 - CodeCache::blobs_do(code_roots); 13.49 + CodeCache::blobs_do(&code_roots); 13.50 } 13.51 // Verify that the code cache contents are not subject to 13.52 // movement by a scavenging collection. 13.53 @@ -235,12 +236,10 @@ 13.54 }; 13.55 static AlwaysTrueClosure always_true; 13.56 13.57 -void SharedHeap::process_weak_roots(OopClosure* root_closure, 13.58 - CodeBlobClosure* code_roots) { 13.59 +void SharedHeap::process_weak_roots(OopClosure* root_closure) { 13.60 // Global (weak) JNI handles 13.61 JNIHandles::weak_oops_do(&always_true, root_closure); 13.62 13.63 - CodeCache::blobs_do(code_roots); 13.64 StringTable::oops_do(root_closure); 13.65 } 13.66
14.1 --- a/src/share/vm/memory/sharedHeap.hpp Mon Feb 10 12:58:09 2014 +0100 14.2 +++ b/src/share/vm/memory/sharedHeap.hpp Thu Feb 13 17:44:39 2014 +0100 14.3 @@ -238,14 +238,11 @@ 14.4 void process_strong_roots(bool activate_scope, 14.5 ScanningOption so, 14.6 OopClosure* roots, 14.7 - CodeBlobClosure* code_roots, 14.8 KlassClosure* klass_closure); 14.9 14.10 - // Apply "blk" to all the weak roots of the system. These include 14.11 - // JNI weak roots, the code cache, system dictionary, symbol table, 14.12 - // string table. 14.13 - void process_weak_roots(OopClosure* root_closure, 14.14 - CodeBlobClosure* code_roots); 14.15 + // Apply "root_closure" to all the weak roots of the system. 14.16 + // These include JNI weak roots and string table. 14.17 + void process_weak_roots(OopClosure* root_closure); 14.18 14.19 // The functions below are helper functions that a subclass of 14.20 // "SharedHeap" can use in the implementation of its virtual 14.21 @@ -275,4 +272,8 @@ 14.22 size_t capacity); 14.23 }; 14.24 14.25 +inline SharedHeap::ScanningOption operator|(SharedHeap::ScanningOption so0, SharedHeap::ScanningOption so1) { 14.26 + return static_cast<SharedHeap::ScanningOption>(static_cast<int>(so0) | static_cast<int>(so1)); 14.27 +} 14.28 + 14.29 #endif // SHARE_VM_MEMORY_SHAREDHEAP_HPP