comparison src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp @ 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 95f6641e38e0
children 47bdfb3d010f
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" 30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
31 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" 31 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
32 #include "gc_implementation/parallelScavenge/psScavenge.hpp" 32 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
33 #include "memory/iterator.hpp"
33 34
34 inline void PSScavenge::save_to_space_top_before_gc() { 35 inline void PSScavenge::save_to_space_top_before_gc() {
35 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 36 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
36 _to_space_top_before_gc = heap->young_gen()->to_space()->top(); 37 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
37 } 38 }
73 74
74 oop o = oopDesc::load_decode_heap_oop_not_null(p); 75 oop o = oopDesc::load_decode_heap_oop_not_null(p);
75 oop new_obj = o->is_forwarded() 76 oop new_obj = o->is_forwarded()
76 ? o->forwardee() 77 ? o->forwardee()
77 : pm->copy_to_survivor_space<promote_immediately>(o); 78 : pm->copy_to_survivor_space<promote_immediately>(o);
79
80 #ifndef PRODUCT
81 // This code must come after the CAS test, or it will print incorrect
82 // information.
83 if (TraceScavenge && o->is_forwarded()) {
84 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
85 "forwarding",
86 new_obj->klass()->internal_name(), o, new_obj, new_obj->size());
87 }
88 #endif
89
78 oopDesc::encode_store_heap_oop_not_null(p, new_obj); 90 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
79 91
80 // We cannot mark without test, as some code passes us pointers 92 // We cannot mark without test, as some code passes us pointers
81 // that are outside the heap. 93 // that are outside the heap. These pointers are either from roots
94 // or from metadata.
82 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && 95 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
83 Universe::heap()->is_in_reserved(p)) { 96 Universe::heap()->is_in_reserved(p)) {
84 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) { 97 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
85 card_table()->inline_write_ref_field_gc(p, new_obj); 98 card_table()->inline_write_ref_field_gc(p, new_obj);
86 } 99 }
106 }; 119 };
107 120
108 typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure; 121 typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
109 typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure; 122 typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
110 123
124 // Scavenges a single oop in a Klass.
125 class PSScavengeFromKlassClosure: public OopClosure {
126 private:
127 PSPromotionManager* _pm;
128 // Used to redirty a scanned klass if it has oops
129 // pointing to the young generation after being scanned.
130 Klass* _scanned_klass;
131 public:
132 PSScavengeFromKlassClosure(PSPromotionManager* pm) : _pm(pm), _scanned_klass(NULL) { }
133 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
134 void do_oop(oop* p) {
135 ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
136 assert(!psh->is_in_reserved(p), "GC barrier needed");
137 if (PSScavenge::should_scavenge(p)) {
138 assert(!Universe::heap()->is_in_reserved(p), "Not from meta-data?");
139 assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
140
141 oop o = *p;
142 oop new_obj;
143 if (o->is_forwarded()) {
144 new_obj = o->forwardee();
145 } else {
146 new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
147 }
148 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
149
150 if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) {
151 do_klass_barrier();
152 }
153 }
154 }
155
156 void set_scanned_klass(Klass* klass) {
157 assert(_scanned_klass == NULL || klass == NULL, "Should always only handling one klass at a time");
158 _scanned_klass = klass;
159 }
160
161 private:
162 void do_klass_barrier() {
163 assert(_scanned_klass != NULL, "Should not be called without having a scanned klass");
164 _scanned_klass->record_modified_oops();
165 }
166
167 };
168
169 // Scavenges the oop in a Klass.
170 class PSScavengeKlassClosure: public KlassClosure {
171 private:
172 PSScavengeFromKlassClosure _oop_closure;
173 protected:
174 public:
175 PSScavengeKlassClosure(PSPromotionManager* pm) : _oop_closure(pm) { }
176 void do_klass(Klass* klass) {
177 // If the klass has not been dirtied we know that there's
178 // no references into the young gen and we can skip it.
179
180 #ifndef PRODUCT
181 if (TraceScavenge) {
182 ResourceMark rm;
183 gclog_or_tty->print_cr("PSScavengeKlassClosure::do_klass %p, %s, dirty: %s",
184 klass,
185 klass->external_name(),
186 klass->has_modified_oops() ? "true" : "false");
187 }
188 #endif
189
190 if (klass->has_modified_oops()) {
191 // Clean the klass since we're going to scavenge all the metadata.
192 klass->clear_modified_oops();
193
194 // Setup the promotion manager to redirty this klass
195 // if references are left in the young gen.
196 _oop_closure.set_scanned_klass(klass);
197
198 klass->oops_do(&_oop_closure);
199
200 _oop_closure.set_scanned_klass(NULL);
201 }
202 }
203 };
204
111 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP 205 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP