1.1 --- a/src/share/vm/memory/defNewGeneration.cpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/share/vm/memory/defNewGeneration.cpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -30,6 +30,7 @@ 1.4 #include "memory/gcLocker.inline.hpp" 1.5 #include "memory/genCollectedHeap.hpp" 1.6 #include "memory/genOopClosures.inline.hpp" 1.7 +#include "memory/genRemSet.hpp" 1.8 #include "memory/generationSpec.hpp" 1.9 #include "memory/iterator.hpp" 1.10 #include "memory/referencePolicy.hpp" 1.11 @@ -118,7 +119,7 @@ 1.12 } 1.13 1.14 ScanClosure::ScanClosure(DefNewGeneration* g, bool gc_barrier) : 1.15 - OopsInGenClosure(g), _g(g), _gc_barrier(gc_barrier) 1.16 + OopsInKlassOrGenClosure(g), _g(g), _gc_barrier(gc_barrier) 1.17 { 1.18 assert(_g->level() == 0, "Optimized for youngest generation"); 1.19 _boundary = _g->reserved().end(); 1.20 @@ -128,7 +129,7 @@ 1.21 void ScanClosure::do_oop(narrowOop* p) { ScanClosure::do_oop_work(p); } 1.22 1.23 FastScanClosure::FastScanClosure(DefNewGeneration* g, bool gc_barrier) : 1.24 - OopsInGenClosure(g), _g(g), _gc_barrier(gc_barrier) 1.25 + OopsInKlassOrGenClosure(g), _g(g), _gc_barrier(gc_barrier) 1.26 { 1.27 assert(_g->level() == 0, "Optimized for youngest generation"); 1.28 _boundary = _g->reserved().end(); 1.29 @@ -137,8 +138,39 @@ 1.30 void FastScanClosure::do_oop(oop* p) { FastScanClosure::do_oop_work(p); } 1.31 void FastScanClosure::do_oop(narrowOop* p) { FastScanClosure::do_oop_work(p); } 1.32 1.33 +void KlassScanClosure::do_klass(Klass* klass) { 1.34 +#ifndef PRODUCT 1.35 + if (TraceScavenge) { 1.36 + ResourceMark rm; 1.37 + gclog_or_tty->print_cr("KlassScanClosure::do_klass %p, %s, dirty: %s", 1.38 + klass, 1.39 + klass->external_name(), 1.40 + klass->has_modified_oops() ? "true" : "false"); 1.41 + } 1.42 +#endif 1.43 + 1.44 + // If the klass has not been dirtied we know that there's 1.45 + // no references into the young gen and we can skip it. 1.46 + if (klass->has_modified_oops()) { 1.47 + if (_accumulate_modified_oops) { 1.48 + klass->accumulate_modified_oops(); 1.49 + } 1.50 + 1.51 + // Clear this state since we're going to scavenge all the metadata. 1.52 + klass->clear_modified_oops(); 1.53 + 1.54 + // Tell the closure which Klass is being scanned so that it can be dirtied 1.55 + // if oops are left pointing into the young gen. 1.56 + _scavenge_closure->set_scanned_klass(klass); 1.57 + 1.58 + klass->oops_do(_scavenge_closure); 1.59 + 1.60 + _scavenge_closure->set_scanned_klass(NULL); 1.61 + } 1.62 +} 1.63 + 1.64 ScanWeakRefClosure::ScanWeakRefClosure(DefNewGeneration* g) : 1.65 - OopClosure(g->ref_processor()), _g(g) 1.66 + _g(g) 1.67 { 1.68 assert(_g->level() == 0, "Optimized for youngest generation"); 1.69 _boundary = _g->reserved().end(); 1.70 @@ -150,6 +182,12 @@ 1.71 void FilteringClosure::do_oop(oop* p) { FilteringClosure::do_oop_work(p); } 1.72 void FilteringClosure::do_oop(narrowOop* p) { FilteringClosure::do_oop_work(p); } 1.73 1.74 +KlassScanClosure::KlassScanClosure(OopsInKlassOrGenClosure* scavenge_closure, 1.75 + KlassRemSet* klass_rem_set) 1.76 + : _scavenge_closure(scavenge_closure), 1.77 + _accumulate_modified_oops(klass_rem_set->accumulate_modified_oops()) {} 1.78 + 1.79 + 1.80 DefNewGeneration::DefNewGeneration(ReservedSpace rs, 1.81 size_t initial_size, 1.82 int level, 1.83 @@ -572,6 +610,9 @@ 1.84 FastScanClosure fsc_with_no_gc_barrier(this, false); 1.85 FastScanClosure fsc_with_gc_barrier(this, true); 1.86 1.87 + KlassScanClosure klass_scan_closure(&fsc_with_no_gc_barrier, 1.88 + gch->rem_set()->klass_rem_set()); 1.89 + 1.90 set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier); 1.91 FastEvacuateFollowersClosure evacuate_followers(gch, _level, this, 1.92 &fsc_with_no_gc_barrier, 1.93 @@ -580,15 +621,18 @@ 1.94 assert(gch->no_allocs_since_save_marks(0), 1.95 "save marks have not been newly set."); 1.96 1.97 + int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; 1.98 + 1.99 gch->gen_process_strong_roots(_level, 1.100 true, // Process younger gens, if any, 1.101 // as strong roots. 1.102 true, // activate StrongRootsScope 1.103 - false, // not collecting perm generation. 1.104 - SharedHeap::SO_AllClasses, 1.105 + true, // is scavenging 1.106 + SharedHeap::ScanningOption(so), 1.107 &fsc_with_no_gc_barrier, 1.108 true, // walk *all* scavengable nmethods 1.109 - &fsc_with_gc_barrier); 1.110 + &fsc_with_gc_barrier, 1.111 + &klass_scan_closure); 1.112 1.113 // "evacuate followers". 1.114 evacuate_followers.do_void();