comparison src/share/vm/memory/defNewGeneration.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 9d679effd28c
children f34d701e952e
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
28 #include "gc_implementation/shared/spaceDecorator.hpp" 28 #include "gc_implementation/shared/spaceDecorator.hpp"
29 #include "memory/defNewGeneration.inline.hpp" 29 #include "memory/defNewGeneration.inline.hpp"
30 #include "memory/gcLocker.inline.hpp" 30 #include "memory/gcLocker.inline.hpp"
31 #include "memory/genCollectedHeap.hpp" 31 #include "memory/genCollectedHeap.hpp"
32 #include "memory/genOopClosures.inline.hpp" 32 #include "memory/genOopClosures.inline.hpp"
33 #include "memory/genRemSet.hpp"
33 #include "memory/generationSpec.hpp" 34 #include "memory/generationSpec.hpp"
34 #include "memory/iterator.hpp" 35 #include "memory/iterator.hpp"
35 #include "memory/referencePolicy.hpp" 36 #include "memory/referencePolicy.hpp"
36 #include "memory/space.inline.hpp" 37 #include "memory/space.inline.hpp"
37 #include "oops/instanceRefKlass.hpp" 38 #include "oops/instanceRefKlass.hpp"
116 } while (!_gch->no_allocs_since_save_marks(_level)); 117 } while (!_gch->no_allocs_since_save_marks(_level));
117 guarantee(_gen->promo_failure_scan_is_complete(), "Failed to finish scan"); 118 guarantee(_gen->promo_failure_scan_is_complete(), "Failed to finish scan");
118 } 119 }
119 120
120 ScanClosure::ScanClosure(DefNewGeneration* g, bool gc_barrier) : 121 ScanClosure::ScanClosure(DefNewGeneration* g, bool gc_barrier) :
121 OopsInGenClosure(g), _g(g), _gc_barrier(gc_barrier) 122 OopsInKlassOrGenClosure(g), _g(g), _gc_barrier(gc_barrier)
122 { 123 {
123 assert(_g->level() == 0, "Optimized for youngest generation"); 124 assert(_g->level() == 0, "Optimized for youngest generation");
124 _boundary = _g->reserved().end(); 125 _boundary = _g->reserved().end();
125 } 126 }
126 127
127 void ScanClosure::do_oop(oop* p) { ScanClosure::do_oop_work(p); } 128 void ScanClosure::do_oop(oop* p) { ScanClosure::do_oop_work(p); }
128 void ScanClosure::do_oop(narrowOop* p) { ScanClosure::do_oop_work(p); } 129 void ScanClosure::do_oop(narrowOop* p) { ScanClosure::do_oop_work(p); }
129 130
130 FastScanClosure::FastScanClosure(DefNewGeneration* g, bool gc_barrier) : 131 FastScanClosure::FastScanClosure(DefNewGeneration* g, bool gc_barrier) :
131 OopsInGenClosure(g), _g(g), _gc_barrier(gc_barrier) 132 OopsInKlassOrGenClosure(g), _g(g), _gc_barrier(gc_barrier)
132 { 133 {
133 assert(_g->level() == 0, "Optimized for youngest generation"); 134 assert(_g->level() == 0, "Optimized for youngest generation");
134 _boundary = _g->reserved().end(); 135 _boundary = _g->reserved().end();
135 } 136 }
136 137
137 void FastScanClosure::do_oop(oop* p) { FastScanClosure::do_oop_work(p); } 138 void FastScanClosure::do_oop(oop* p) { FastScanClosure::do_oop_work(p); }
138 void FastScanClosure::do_oop(narrowOop* p) { FastScanClosure::do_oop_work(p); } 139 void FastScanClosure::do_oop(narrowOop* p) { FastScanClosure::do_oop_work(p); }
139 140
141 void KlassScanClosure::do_klass(Klass* klass) {
142 #ifndef PRODUCT
143 if (TraceScavenge) {
144 ResourceMark rm;
145 gclog_or_tty->print_cr("KlassScanClosure::do_klass %p, %s, dirty: %s",
146 klass,
147 klass->external_name(),
148 klass->has_modified_oops() ? "true" : "false");
149 }
150 #endif
151
152 // If the klass has not been dirtied we know that there's
153 // no references into the young gen and we can skip it.
154 if (klass->has_modified_oops()) {
155 if (_accumulate_modified_oops) {
156 klass->accumulate_modified_oops();
157 }
158
159 // Clear this state since we're going to scavenge all the metadata.
160 klass->clear_modified_oops();
161
162 // Tell the closure which Klass is being scanned so that it can be dirtied
163 // if oops are left pointing into the young gen.
164 _scavenge_closure->set_scanned_klass(klass);
165
166 klass->oops_do(_scavenge_closure);
167
168 _scavenge_closure->set_scanned_klass(NULL);
169 }
170 }
171
140 ScanWeakRefClosure::ScanWeakRefClosure(DefNewGeneration* g) : 172 ScanWeakRefClosure::ScanWeakRefClosure(DefNewGeneration* g) :
141 OopClosure(g->ref_processor()), _g(g) 173 _g(g)
142 { 174 {
143 assert(_g->level() == 0, "Optimized for youngest generation"); 175 assert(_g->level() == 0, "Optimized for youngest generation");
144 _boundary = _g->reserved().end(); 176 _boundary = _g->reserved().end();
145 } 177 }
146 178
147 void ScanWeakRefClosure::do_oop(oop* p) { ScanWeakRefClosure::do_oop_work(p); } 179 void ScanWeakRefClosure::do_oop(oop* p) { ScanWeakRefClosure::do_oop_work(p); }
148 void ScanWeakRefClosure::do_oop(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); } 180 void ScanWeakRefClosure::do_oop(narrowOop* p) { ScanWeakRefClosure::do_oop_work(p); }
149 181
150 void FilteringClosure::do_oop(oop* p) { FilteringClosure::do_oop_work(p); } 182 void FilteringClosure::do_oop(oop* p) { FilteringClosure::do_oop_work(p); }
151 void FilteringClosure::do_oop(narrowOop* p) { FilteringClosure::do_oop_work(p); } 183 void FilteringClosure::do_oop(narrowOop* p) { FilteringClosure::do_oop_work(p); }
184
185 KlassScanClosure::KlassScanClosure(OopsInKlassOrGenClosure* scavenge_closure,
186 KlassRemSet* klass_rem_set)
187 : _scavenge_closure(scavenge_closure),
188 _accumulate_modified_oops(klass_rem_set->accumulate_modified_oops()) {}
189
152 190
153 DefNewGeneration::DefNewGeneration(ReservedSpace rs, 191 DefNewGeneration::DefNewGeneration(ReservedSpace rs,
154 size_t initial_size, 192 size_t initial_size,
155 int level, 193 int level,
156 const char* policy) 194 const char* policy)
570 CollectorPolicy* cp = gch->collector_policy(); 608 CollectorPolicy* cp = gch->collector_policy();
571 609
572 FastScanClosure fsc_with_no_gc_barrier(this, false); 610 FastScanClosure fsc_with_no_gc_barrier(this, false);
573 FastScanClosure fsc_with_gc_barrier(this, true); 611 FastScanClosure fsc_with_gc_barrier(this, true);
574 612
613 KlassScanClosure klass_scan_closure(&fsc_with_no_gc_barrier,
614 gch->rem_set()->klass_rem_set());
615
575 set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier); 616 set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier);
576 FastEvacuateFollowersClosure evacuate_followers(gch, _level, this, 617 FastEvacuateFollowersClosure evacuate_followers(gch, _level, this,
577 &fsc_with_no_gc_barrier, 618 &fsc_with_no_gc_barrier,
578 &fsc_with_gc_barrier); 619 &fsc_with_gc_barrier);
579 620
580 assert(gch->no_allocs_since_save_marks(0), 621 assert(gch->no_allocs_since_save_marks(0),
581 "save marks have not been newly set."); 622 "save marks have not been newly set.");
582 623
624 int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache;
625
583 gch->gen_process_strong_roots(_level, 626 gch->gen_process_strong_roots(_level,
584 true, // Process younger gens, if any, 627 true, // Process younger gens, if any,
585 // as strong roots. 628 // as strong roots.
586 true, // activate StrongRootsScope 629 true, // activate StrongRootsScope
587 false, // not collecting perm generation. 630 true, // is scavenging
588 SharedHeap::SO_AllClasses, 631 SharedHeap::ScanningOption(so),
589 &fsc_with_no_gc_barrier, 632 &fsc_with_no_gc_barrier,
590 true, // walk *all* scavengable nmethods 633 true, // walk *all* scavengable nmethods
591 &fsc_with_gc_barrier); 634 &fsc_with_gc_barrier,
635 &klass_scan_closure);
592 636
593 // "evacuate followers". 637 // "evacuate followers".
594 evacuate_followers.do_void(); 638 evacuate_followers.do_void();
595 639
596 FastKeepAliveClosure keep_alive(this, &scan_weak_ref); 640 FastKeepAliveClosure keep_alive(this, &scan_weak_ref);