Fri, 26 Apr 2013 10:40:36 +0200
8013160: NPG: Remove unnecessary mark stack draining after CodeCache::do_unloading
Reviewed-by: coleenp, mgerdin
1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Fri Apr 26 09:53:22 2013 +0200 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Fri Apr 26 10:40:36 2013 +0200 1.3 @@ -6007,26 +6007,23 @@ 1.4 &cmsDrainMarkingStackClosure, 1.5 NULL); 1.6 } 1.7 - verify_work_stacks_empty(); 1.8 - } 1.9 + } 1.10 + 1.11 + // This is the point where the entire marking should have completed. 1.12 + verify_work_stacks_empty(); 1.13 1.14 if (should_unload_classes()) { 1.15 { 1.16 TraceTime t("class unloading", PrintGCDetails, false, gclog_or_tty); 1.17 1.18 - // Follow SystemDictionary roots and unload classes 1.19 + // Unload classes and purge the SystemDictionary. 1.20 bool purged_class = SystemDictionary::do_unloading(&_is_alive_closure); 1.21 1.22 - // Follow CodeCache roots and unload any methods marked for unloading 1.23 + // Unload nmethods. 1.24 CodeCache::do_unloading(&_is_alive_closure, purged_class); 1.25 1.26 - cmsDrainMarkingStackClosure.do_void(); 1.27 - verify_work_stacks_empty(); 1.28 - 1.29 - // Update subklass/sibling/implementor links in KlassKlass descendants 1.30 + // Prune dead klasses from subklass/sibling/implementor lists. 1.31 Klass::clean_weak_klass_links(&_is_alive_closure); 1.32 - // Nothing should have been pushed onto the working stacks. 1.33 - verify_work_stacks_empty(); 1.34 } 1.35 1.36 { 1.37 @@ -6040,11 +6037,10 @@ 1.38 // Need to check if we really scanned the StringTable. 1.39 if ((roots_scanning_options() & SharedHeap::SO_Strings) == 0) { 1.40 TraceTime t("scrub string table", PrintGCDetails, false, gclog_or_tty); 1.41 - // Now clean up stale oops in StringTable 1.42 + // Delete entries for dead interned strings. 1.43 StringTable::unlink(&_is_alive_closure); 1.44 } 1.45 1.46 - verify_work_stacks_empty(); 1.47 // Restore any preserved marks as a result of mark stack or 1.48 // work queue overflow 1.49 restore_preserved_marks_if_any(); // done single-threaded for now
2.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Fri Apr 26 09:53:22 2013 +0200 2.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Fri Apr 26 10:40:36 2013 +0200 2.3 @@ -144,29 +144,25 @@ 2.4 &GenMarkSweep::follow_stack_closure, 2.5 NULL); 2.6 2.7 - // Follow system dictionary roots and unload classes 2.8 + 2.9 + // This is the point where the entire marking should have completed. 2.10 + assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); 2.11 + 2.12 + // Unload classes and purge the SystemDictionary. 2.13 bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive); 2.14 - assert(GenMarkSweep::_marking_stack.is_empty(), 2.15 - "stack should be empty by now"); 2.16 2.17 - // Follow code cache roots (has to be done after system dictionary, 2.18 - // assumes all live klasses are marked) 2.19 + // Unload nmethods. 2.20 CodeCache::do_unloading(&GenMarkSweep::is_alive, purged_class); 2.21 - GenMarkSweep::follow_stack(); 2.22 2.23 - // Update subklass/sibling/implementor links of live klasses 2.24 + // Prune dead klasses from subklass/sibling/implementor lists. 2.25 Klass::clean_weak_klass_links(&GenMarkSweep::is_alive); 2.26 - assert(GenMarkSweep::_marking_stack.is_empty(), 2.27 - "stack should be empty by now"); 2.28 2.29 - // Visit interned string tables and delete unmarked oops 2.30 + // Delete entries for dead interned strings. 2.31 StringTable::unlink(&GenMarkSweep::is_alive); 2.32 + 2.33 // Clean up unreferenced symbols in symbol table. 2.34 SymbolTable::unlink(); 2.35 2.36 - assert(GenMarkSweep::_marking_stack.is_empty(), 2.37 - "stack should be empty by now"); 2.38 - 2.39 if (VerifyDuringGC) { 2.40 HandleMark hm; // handle scope 2.41 COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact);
3.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Fri Apr 26 09:53:22 2013 +0200 3.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Fri Apr 26 10:40:36 2013 +0200 3.3 @@ -517,23 +517,23 @@ 3.4 is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL); 3.5 } 3.6 3.7 - // Follow system dictionary roots and unload classes 3.8 + // This is the point where the entire marking should have completed. 3.9 + assert(_marking_stack.is_empty(), "Marking should have completed"); 3.10 + 3.11 + // Unload classes and purge the SystemDictionary. 3.12 bool purged_class = SystemDictionary::do_unloading(is_alive_closure()); 3.13 3.14 - // Follow code cache roots 3.15 + // Unload nmethods. 3.16 CodeCache::do_unloading(is_alive_closure(), purged_class); 3.17 - follow_stack(); // Flush marking stack 3.18 3.19 - // Update subklass/sibling/implementor links of live klasses 3.20 - Klass::clean_weak_klass_links(&is_alive); 3.21 - assert(_marking_stack.is_empty(), "just drained"); 3.22 + // Prune dead klasses from subklass/sibling/implementor lists. 3.23 + Klass::clean_weak_klass_links(is_alive_closure()); 3.24 3.25 - // Visit interned string tables and delete unmarked oops 3.26 + // Delete entries for dead interned strings. 3.27 StringTable::unlink(is_alive_closure()); 3.28 + 3.29 // Clean up unreferenced symbols in symbol table. 3.30 SymbolTable::unlink(); 3.31 - 3.32 - assert(_marking_stack.is_empty(), "stack should be empty by now"); 3.33 } 3.34 3.35
4.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Apr 26 09:53:22 2013 +0200 4.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Apr 26 10:40:36 2013 +0200 4.3 @@ -2354,22 +2354,24 @@ 4.4 } 4.5 4.6 TraceTime tm_c("class unloading", print_phases(), true, gclog_or_tty); 4.7 + 4.8 + // This is the point where the entire marking should have completed. 4.9 + assert(cm->marking_stacks_empty(), "Marking should have completed"); 4.10 + 4.11 // Follow system dictionary roots and unload classes. 4.12 bool purged_class = SystemDictionary::do_unloading(is_alive_closure()); 4.13 4.14 - // Follow code cache roots. 4.15 + // Unload nmethods. 4.16 CodeCache::do_unloading(is_alive_closure(), purged_class); 4.17 - cm->follow_marking_stacks(); // Flush marking stack. 4.18 - 4.19 - // Update subklass/sibling/implementor links of live klasses 4.20 + 4.21 + // Prune dead klasses from subklass/sibling/implementor lists. 4.22 Klass::clean_weak_klass_links(is_alive_closure()); 4.23 4.24 - // Visit interned string tables and delete unmarked oops 4.25 + // Delete entries for dead interned strings. 4.26 StringTable::unlink(is_alive_closure()); 4.27 + 4.28 // Clean up unreferenced symbols in symbol table. 4.29 SymbolTable::unlink(); 4.30 - 4.31 - assert(cm->marking_stacks_empty(), "marking stacks should be empty"); 4.32 } 4.33 4.34 void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) {
5.1 --- a/src/share/vm/memory/genMarkSweep.cpp Fri Apr 26 09:53:22 2013 +0200 5.2 +++ b/src/share/vm/memory/genMarkSweep.cpp Fri Apr 26 10:40:36 2013 +0200 5.3 @@ -223,23 +223,23 @@ 5.4 &is_alive, &keep_alive, &follow_stack_closure, NULL); 5.5 } 5.6 5.7 - // Follow system dictionary roots and unload classes 5.8 + // This is the point where the entire marking should have completed. 5.9 + assert(_marking_stack.is_empty(), "Marking should have completed"); 5.10 + 5.11 + // Unload classes and purge the SystemDictionary. 5.12 bool purged_class = SystemDictionary::do_unloading(&is_alive); 5.13 5.14 - // Follow code cache roots 5.15 + // Unload nmethods. 5.16 CodeCache::do_unloading(&is_alive, purged_class); 5.17 - follow_stack(); // Flush marking stack 5.18 5.19 - // Update subklass/sibling/implementor links of live klasses 5.20 + // Prune dead klasses from subklass/sibling/implementor lists. 5.21 Klass::clean_weak_klass_links(&is_alive); 5.22 - assert(_marking_stack.is_empty(), "just drained"); 5.23 5.24 - // Visit interned string tables and delete unmarked oops 5.25 + // Delete entries for dead interned strings. 5.26 StringTable::unlink(&is_alive); 5.27 + 5.28 // Clean up unreferenced symbols in symbol table. 5.29 SymbolTable::unlink(); 5.30 - 5.31 - assert(_marking_stack.is_empty(), "stack should be empty by now"); 5.32 } 5.33 5.34