175 _young_ref_counter_closure.reset_count();
176 cld->oops_do(&_young_ref_counter_closure, ClassLoaderData::_claim_none);
177 if (_young_ref_counter_closure.count() > 0) {
178 guarantee(cld->has_modified_oops(), "CLD " PTR_FORMAT ", has young %d refs but is not dirty.", p2i(cld), _young_ref_counter_closure.count());
179 }
180 }
181 };
182
183 class VerifyLivenessOopClosure: public BasicOopIterateClosure {
184 G1CollectedHeap* _g1h;
185 VerifyOption _vo;
186 public:
187 VerifyLivenessOopClosure(G1CollectedHeap* g1h, VerifyOption vo):
188 _g1h(g1h), _vo(vo)
189 { }
190 void do_oop(narrowOop *p) { do_oop_work(p); }
191 void do_oop( oop *p) { do_oop_work(p); }
192
193 template <class T> void do_oop_work(T *p) {
194 oop obj = RawAccess<>::oop_load(p);
195 guarantee(obj == NULL || !_g1h->is_obj_dead_cond(obj, _vo),
196 "Dead object referenced by a not dead object");
197 }
198 };
199
200 class VerifyObjsInRegionClosure: public ObjectClosure {
201 private:
202 G1CollectedHeap* _g1h;
203 size_t _live_bytes;
204 HeapRegion *_hr;
205 VerifyOption _vo;
206 public:
207 // _vo == UsePrevMarking -> use "prev" marking information,
208 // _vo == UseNextMarking -> use "next" marking information,
209 // _vo == UseFullMarking -> use "next" marking bitmap but no TAMS.
210 VerifyObjsInRegionClosure(HeapRegion *hr, VerifyOption vo)
211 : _live_bytes(0), _hr(hr), _vo(vo) {
212 _g1h = G1CollectedHeap::heap();
213 }
214 void do_object(oop o) {
229 o->oop_iterate(&isLive);
230 if (!_hr->obj_allocated_since_prev_marking(o)) {
231 size_t obj_size = o->size(); // Make sure we don't overflow
232 _live_bytes += (obj_size * HeapWordSize);
233 }
234 }
235 }
236 size_t live_bytes() { return _live_bytes; }
237 };
238
239 class VerifyArchiveOopClosure: public BasicOopIterateClosure {
240 HeapRegion* _hr;
241 public:
242 VerifyArchiveOopClosure(HeapRegion *hr)
243 : _hr(hr) { }
244 void do_oop(narrowOop *p) { do_oop_work(p); }
245 void do_oop( oop *p) { do_oop_work(p); }
246
247 template <class T> void do_oop_work(T *p) {
248 oop obj = RawAccess<>::oop_load(p);
249
250 if (_hr->is_open_archive()) {
251 guarantee(obj == NULL || G1ArchiveAllocator::is_archived_object(obj),
252 "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT,
253 p2i(p), p2i(obj));
254 } else {
255 assert(_hr->is_closed_archive(), "should be closed archive region");
256 guarantee(obj == NULL || G1ArchiveAllocator::is_closed_archive_object(obj),
257 "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT,
258 p2i(p), p2i(obj));
259 }
260 }
261 };
262
263 class VerifyObjectInArchiveRegionClosure: public ObjectClosure {
264 HeapRegion* _hr;
265 public:
266 VerifyObjectInArchiveRegionClosure(HeapRegion *hr, bool verbose)
267 : _hr(hr) { }
268 // Verify that all object pointers are to archive regions.
|
175 _young_ref_counter_closure.reset_count();
176 cld->oops_do(&_young_ref_counter_closure, ClassLoaderData::_claim_none);
177 if (_young_ref_counter_closure.count() > 0) {
178 guarantee(cld->has_modified_oops(), "CLD " PTR_FORMAT ", has young %d refs but is not dirty.", p2i(cld), _young_ref_counter_closure.count());
179 }
180 }
181 };
182
183 class VerifyLivenessOopClosure: public BasicOopIterateClosure {
184 G1CollectedHeap* _g1h;
185 VerifyOption _vo;
186 public:
187 VerifyLivenessOopClosure(G1CollectedHeap* g1h, VerifyOption vo):
188 _g1h(g1h), _vo(vo)
189 { }
190 void do_oop(narrowOop *p) { do_oop_work(p); }
191 void do_oop( oop *p) { do_oop_work(p); }
192
193 template <class T> void do_oop_work(T *p) {
194 oop obj = RawAccess<>::oop_load(p);
195 assert_object_is_in_heap_or_null(p, obj);
196 guarantee(obj == NULL || !_g1h->is_obj_dead_cond(obj, _vo),
197 "Dead object referenced by a not dead object");
198 }
199 };
200
201 class VerifyObjsInRegionClosure: public ObjectClosure {
202 private:
203 G1CollectedHeap* _g1h;
204 size_t _live_bytes;
205 HeapRegion *_hr;
206 VerifyOption _vo;
207 public:
208 // _vo == UsePrevMarking -> use "prev" marking information,
209 // _vo == UseNextMarking -> use "next" marking information,
210 // _vo == UseFullMarking -> use "next" marking bitmap but no TAMS.
211 VerifyObjsInRegionClosure(HeapRegion *hr, VerifyOption vo)
212 : _live_bytes(0), _hr(hr), _vo(vo) {
213 _g1h = G1CollectedHeap::heap();
214 }
215 void do_object(oop o) {
230 o->oop_iterate(&isLive);
231 if (!_hr->obj_allocated_since_prev_marking(o)) {
232 size_t obj_size = o->size(); // Make sure we don't overflow
233 _live_bytes += (obj_size * HeapWordSize);
234 }
235 }
236 }
237 size_t live_bytes() { return _live_bytes; }
238 };
239
240 class VerifyArchiveOopClosure: public BasicOopIterateClosure {
241 HeapRegion* _hr;
242 public:
243 VerifyArchiveOopClosure(HeapRegion *hr)
244 : _hr(hr) { }
245 void do_oop(narrowOop *p) { do_oop_work(p); }
246 void do_oop( oop *p) { do_oop_work(p); }
247
248 template <class T> void do_oop_work(T *p) {
249 oop obj = RawAccess<>::oop_load(p);
250 assert_object_is_in_heap_or_null(p, obj);
251
252 if (_hr->is_open_archive()) {
253 guarantee(obj == NULL || G1ArchiveAllocator::is_archived_object(obj),
254 "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT,
255 p2i(p), p2i(obj));
256 } else {
257 assert(_hr->is_closed_archive(), "should be closed archive region");
258 guarantee(obj == NULL || G1ArchiveAllocator::is_closed_archive_object(obj),
259 "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT,
260 p2i(p), p2i(obj));
261 }
262 }
263 };
264
265 class VerifyObjectInArchiveRegionClosure: public ObjectClosure {
266 HeapRegion* _hr;
267 public:
268 VerifyObjectInArchiveRegionClosure(HeapRegion *hr, bool verbose)
269 : _hr(hr) { }
270 // Verify that all object pointers are to archive regions.
|