1198 |
1198 |
1199 if (VerifyDuringGC) { |
1199 if (VerifyDuringGC) { |
1200 HandleMark hm; // handle scope |
1200 HandleMark hm; // handle scope |
1201 gclog_or_tty->print(" VerifyDuringGC:(before)"); |
1201 gclog_or_tty->print(" VerifyDuringGC:(before)"); |
1202 Universe::heap()->prepare_for_verify(); |
1202 Universe::heap()->prepare_for_verify(); |
1203 Universe::verify(true, false, true); |
1203 Universe::verify(/* allow dirty */ true, |
|
1204 /* silent */ false, |
|
1205 /* option */ VerifyOption_G1UsePrevMarking); |
1204 } |
1206 } |
1205 |
1207 |
1206 G1CollectorPolicy* g1p = g1h->g1_policy(); |
1208 G1CollectorPolicy* g1p = g1h->g1_policy(); |
1207 g1p->record_concurrent_mark_remark_start(); |
1209 g1p->record_concurrent_mark_remark_start(); |
1208 |
1210 |
1231 |
1233 |
1232 if (VerifyDuringGC) { |
1234 if (VerifyDuringGC) { |
1233 HandleMark hm; // handle scope |
1235 HandleMark hm; // handle scope |
1234 gclog_or_tty->print(" VerifyDuringGC:(after)"); |
1236 gclog_or_tty->print(" VerifyDuringGC:(after)"); |
1235 Universe::heap()->prepare_for_verify(); |
1237 Universe::heap()->prepare_for_verify(); |
1236 Universe::heap()->verify(/* allow_dirty */ true, |
1238 Universe::verify(/* allow dirty */ true, |
1237 /* silent */ false, |
1239 /* silent */ false, |
1238 /* use_prev_marking */ false); |
1240 /* option */ VerifyOption_G1UseNextMarking); |
1239 } |
1241 } |
1240 assert(!restart_for_overflow(), "sanity"); |
1242 assert(!restart_for_overflow(), "sanity"); |
1241 } |
1243 } |
1242 |
1244 |
1243 // Reset the marking state if marking completed |
1245 // Reset the marking state if marking completed |
1723 |
1725 |
1724 if (VerifyDuringGC) { |
1726 if (VerifyDuringGC) { |
1725 HandleMark hm; // handle scope |
1727 HandleMark hm; // handle scope |
1726 gclog_or_tty->print(" VerifyDuringGC:(before)"); |
1728 gclog_or_tty->print(" VerifyDuringGC:(before)"); |
1727 Universe::heap()->prepare_for_verify(); |
1729 Universe::heap()->prepare_for_verify(); |
1728 Universe::verify(/* allow dirty */ true, |
1730 Universe::verify(/* allow dirty */ true, |
1729 /* silent */ false, |
1731 /* silent */ false, |
1730 /* prev marking */ true); |
1732 /* option */ VerifyOption_G1UsePrevMarking); |
1731 } |
1733 } |
1732 |
1734 |
1733 G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy(); |
1735 G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy(); |
1734 g1p->record_concurrent_mark_cleanup_start(); |
1736 g1p->record_concurrent_mark_cleanup_start(); |
1735 |
1737 |
2342 #ifndef PRODUCT |
2344 #ifndef PRODUCT |
2343 |
2345 |
2344 class PrintReachableOopClosure: public OopClosure { |
2346 class PrintReachableOopClosure: public OopClosure { |
2345 private: |
2347 private: |
2346 G1CollectedHeap* _g1h; |
2348 G1CollectedHeap* _g1h; |
2347 CMBitMapRO* _bitmap; |
|
2348 outputStream* _out; |
2349 outputStream* _out; |
2349 bool _use_prev_marking; |
2350 VerifyOption _vo; |
2350 bool _all; |
2351 bool _all; |
2351 |
2352 |
2352 public: |
2353 public: |
2353 PrintReachableOopClosure(CMBitMapRO* bitmap, |
2354 PrintReachableOopClosure(outputStream* out, |
2354 outputStream* out, |
2355 VerifyOption vo, |
2355 bool use_prev_marking, |
|
2356 bool all) : |
2356 bool all) : |
2357 _g1h(G1CollectedHeap::heap()), |
2357 _g1h(G1CollectedHeap::heap()), |
2358 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } |
2358 _out(out), _vo(vo), _all(all) { } |
2359 |
2359 |
2360 void do_oop(narrowOop* p) { do_oop_work(p); } |
2360 void do_oop(narrowOop* p) { do_oop_work(p); } |
2361 void do_oop( oop* p) { do_oop_work(p); } |
2361 void do_oop( oop* p) { do_oop_work(p); } |
2362 |
2362 |
2363 template <class T> void do_oop_work(T* p) { |
2363 template <class T> void do_oop_work(T* p) { |
2371 str = " O"; |
2371 str = " O"; |
2372 } else { |
2372 } else { |
2373 HeapRegion* hr = _g1h->heap_region_containing(obj); |
2373 HeapRegion* hr = _g1h->heap_region_containing(obj); |
2374 guarantee(hr != NULL, "invariant"); |
2374 guarantee(hr != NULL, "invariant"); |
2375 bool over_tams = false; |
2375 bool over_tams = false; |
2376 if (_use_prev_marking) { |
2376 bool marked = false; |
2377 over_tams = hr->obj_allocated_since_prev_marking(obj); |
2377 |
2378 } else { |
2378 switch (_vo) { |
2379 over_tams = hr->obj_allocated_since_next_marking(obj); |
2379 case VerifyOption_G1UsePrevMarking: |
|
2380 over_tams = hr->obj_allocated_since_prev_marking(obj); |
|
2381 marked = _g1h->isMarkedPrev(obj); |
|
2382 break; |
|
2383 case VerifyOption_G1UseNextMarking: |
|
2384 over_tams = hr->obj_allocated_since_next_marking(obj); |
|
2385 marked = _g1h->isMarkedNext(obj); |
|
2386 break; |
|
2387 case VerifyOption_G1UseMarkWord: |
|
2388 marked = obj->is_gc_marked(); |
|
2389 break; |
|
2390 default: |
|
2391 ShouldNotReachHere(); |
2380 } |
2392 } |
2381 bool marked = _bitmap->isMarked((HeapWord*) obj); |
|
2382 |
2393 |
2383 if (over_tams) { |
2394 if (over_tams) { |
2384 str = " >"; |
2395 str = " >"; |
2385 if (marked) { |
2396 if (marked) { |
2386 str2 = " AND MARKED"; |
2397 str2 = " AND MARKED"; |
2397 } |
2408 } |
2398 }; |
2409 }; |
2399 |
2410 |
2400 class PrintReachableObjectClosure : public ObjectClosure { |
2411 class PrintReachableObjectClosure : public ObjectClosure { |
2401 private: |
2412 private: |
2402 CMBitMapRO* _bitmap; |
2413 G1CollectedHeap* _g1h; |
2403 outputStream* _out; |
2414 outputStream* _out; |
2404 bool _use_prev_marking; |
2415 VerifyOption _vo; |
2405 bool _all; |
2416 bool _all; |
2406 HeapRegion* _hr; |
2417 HeapRegion* _hr; |
2407 |
2418 |
2408 public: |
2419 public: |
2409 PrintReachableObjectClosure(CMBitMapRO* bitmap, |
2420 PrintReachableObjectClosure(outputStream* out, |
2410 outputStream* out, |
2421 VerifyOption vo, |
2411 bool use_prev_marking, |
|
2412 bool all, |
2422 bool all, |
2413 HeapRegion* hr) : |
2423 HeapRegion* hr) : |
2414 _bitmap(bitmap), _out(out), |
2424 _g1h(G1CollectedHeap::heap()), |
2415 _use_prev_marking(use_prev_marking), _all(all), _hr(hr) { } |
2425 _out(out), _vo(vo), _all(all), _hr(hr) { } |
2416 |
2426 |
2417 void do_object(oop o) { |
2427 void do_object(oop o) { |
2418 bool over_tams; |
2428 bool over_tams = false; |
2419 if (_use_prev_marking) { |
2429 bool marked = false; |
2420 over_tams = _hr->obj_allocated_since_prev_marking(o); |
2430 |
2421 } else { |
2431 switch (_vo) { |
2422 over_tams = _hr->obj_allocated_since_next_marking(o); |
2432 case VerifyOption_G1UsePrevMarking: |
2423 } |
2433 over_tams = _hr->obj_allocated_since_prev_marking(o); |
2424 bool marked = _bitmap->isMarked((HeapWord*) o); |
2434 marked = _g1h->isMarkedPrev(o); |
|
2435 break; |
|
2436 case VerifyOption_G1UseNextMarking: |
|
2437 over_tams = _hr->obj_allocated_since_next_marking(o); |
|
2438 marked = _g1h->isMarkedNext(o); |
|
2439 break; |
|
2440 case VerifyOption_G1UseMarkWord: |
|
2441 marked = o->is_gc_marked(); |
|
2442 break; |
|
2443 default: |
|
2444 ShouldNotReachHere(); |
|
2445 } |
2425 bool print_it = _all || over_tams || marked; |
2446 bool print_it = _all || over_tams || marked; |
2426 |
2447 |
2427 if (print_it) { |
2448 if (print_it) { |
2428 _out->print_cr(" "PTR_FORMAT"%s", |
2449 _out->print_cr(" "PTR_FORMAT"%s", |
2429 o, (over_tams) ? " >" : (marked) ? " M" : ""); |
2450 o, (over_tams) ? " >" : (marked) ? " M" : ""); |
2430 PrintReachableOopClosure oopCl(_bitmap, _out, _use_prev_marking, _all); |
2451 PrintReachableOopClosure oopCl(_out, _vo, _all); |
2431 o->oop_iterate(&oopCl); |
2452 o->oop_iterate(&oopCl); |
2432 } |
2453 } |
2433 } |
2454 } |
2434 }; |
2455 }; |
2435 |
2456 |
2436 class PrintReachableRegionClosure : public HeapRegionClosure { |
2457 class PrintReachableRegionClosure : public HeapRegionClosure { |
2437 private: |
2458 private: |
2438 CMBitMapRO* _bitmap; |
|
2439 outputStream* _out; |
2459 outputStream* _out; |
2440 bool _use_prev_marking; |
2460 VerifyOption _vo; |
2441 bool _all; |
2461 bool _all; |
2442 |
2462 |
2443 public: |
2463 public: |
2444 bool doHeapRegion(HeapRegion* hr) { |
2464 bool doHeapRegion(HeapRegion* hr) { |
2445 HeapWord* b = hr->bottom(); |
2465 HeapWord* b = hr->bottom(); |
2446 HeapWord* e = hr->end(); |
2466 HeapWord* e = hr->end(); |
2447 HeapWord* t = hr->top(); |
2467 HeapWord* t = hr->top(); |
2448 HeapWord* p = NULL; |
2468 HeapWord* p = NULL; |
2449 if (_use_prev_marking) { |
2469 |
2450 p = hr->prev_top_at_mark_start(); |
2470 switch (_vo) { |
2451 } else { |
2471 case VerifyOption_G1UsePrevMarking: |
2452 p = hr->next_top_at_mark_start(); |
2472 p = hr->prev_top_at_mark_start(); |
|
2473 break; |
|
2474 case VerifyOption_G1UseNextMarking: |
|
2475 p = hr->next_top_at_mark_start(); |
|
2476 break; |
|
2477 case VerifyOption_G1UseMarkWord: |
|
2478 // When we are verifying marking using the mark word |
|
2479 // TAMS has no relevance. |
|
2480 assert(p == NULL, "post-condition"); |
|
2481 break; |
|
2482 default: |
|
2483 ShouldNotReachHere(); |
2453 } |
2484 } |
2454 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " |
2485 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " |
2455 "TAMS: "PTR_FORMAT, b, e, t, p); |
2486 "TAMS: "PTR_FORMAT, b, e, t, p); |
2456 _out->cr(); |
2487 _out->cr(); |
2457 |
2488 |
2459 HeapWord* to = t; |
2490 HeapWord* to = t; |
2460 |
2491 |
2461 if (to > from) { |
2492 if (to > from) { |
2462 _out->print_cr("Objects in ["PTR_FORMAT", "PTR_FORMAT"]", from, to); |
2493 _out->print_cr("Objects in ["PTR_FORMAT", "PTR_FORMAT"]", from, to); |
2463 _out->cr(); |
2494 _out->cr(); |
2464 PrintReachableObjectClosure ocl(_bitmap, _out, |
2495 PrintReachableObjectClosure ocl(_out, _vo, _all, hr); |
2465 _use_prev_marking, _all, hr); |
|
2466 hr->object_iterate_mem_careful(MemRegion(from, to), &ocl); |
2496 hr->object_iterate_mem_careful(MemRegion(from, to), &ocl); |
2467 _out->cr(); |
2497 _out->cr(); |
2468 } |
2498 } |
2469 |
2499 |
2470 return false; |
2500 return false; |
2471 } |
2501 } |
2472 |
2502 |
2473 PrintReachableRegionClosure(CMBitMapRO* bitmap, |
2503 PrintReachableRegionClosure(outputStream* out, |
2474 outputStream* out, |
2504 VerifyOption vo, |
2475 bool use_prev_marking, |
|
2476 bool all) : |
2505 bool all) : |
2477 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } |
2506 _out(out), _vo(vo), _all(all) { } |
2478 }; |
2507 }; |
2479 |
2508 |
|
2509 static const char* verify_option_to_tams(VerifyOption vo) { |
|
2510 switch (vo) { |
|
2511 case VerifyOption_G1UsePrevMarking: |
|
2512 return "PTAMS"; |
|
2513 case VerifyOption_G1UseNextMarking: |
|
2514 return "NTAMS"; |
|
2515 default: |
|
2516 return "NONE"; |
|
2517 } |
|
2518 } |
|
2519 |
2480 void ConcurrentMark::print_reachable(const char* str, |
2520 void ConcurrentMark::print_reachable(const char* str, |
2481 bool use_prev_marking, |
2521 VerifyOption vo, |
2482 bool all) { |
2522 bool all) { |
2483 gclog_or_tty->cr(); |
2523 gclog_or_tty->cr(); |
2484 gclog_or_tty->print_cr("== Doing heap dump... "); |
2524 gclog_or_tty->print_cr("== Doing heap dump... "); |
2485 |
2525 |
2486 if (G1PrintReachableBaseFile == NULL) { |
2526 if (G1PrintReachableBaseFile == NULL) { |
2503 gclog_or_tty->print_cr(" #### error: could not open file"); |
2543 gclog_or_tty->print_cr(" #### error: could not open file"); |
2504 return; |
2544 return; |
2505 } |
2545 } |
2506 |
2546 |
2507 outputStream* out = &fout; |
2547 outputStream* out = &fout; |
2508 |
2548 out->print_cr("-- USING %s", verify_option_to_tams(vo)); |
2509 CMBitMapRO* bitmap = NULL; |
|
2510 if (use_prev_marking) { |
|
2511 bitmap = _prevMarkBitMap; |
|
2512 } else { |
|
2513 bitmap = _nextMarkBitMap; |
|
2514 } |
|
2515 |
|
2516 out->print_cr("-- USING %s", (use_prev_marking) ? "PTAMS" : "NTAMS"); |
|
2517 out->cr(); |
2549 out->cr(); |
2518 |
2550 |
2519 out->print_cr("--- ITERATING OVER REGIONS"); |
2551 out->print_cr("--- ITERATING OVER REGIONS"); |
2520 out->cr(); |
2552 out->cr(); |
2521 PrintReachableRegionClosure rcl(bitmap, out, use_prev_marking, all); |
2553 PrintReachableRegionClosure rcl(out, vo, all); |
2522 _g1h->heap_region_iterate(&rcl); |
2554 _g1h->heap_region_iterate(&rcl); |
2523 out->cr(); |
2555 out->cr(); |
2524 |
2556 |
2525 gclog_or_tty->print_cr(" done"); |
2557 gclog_or_tty->print_cr(" done"); |
2526 gclog_or_tty->flush(); |
2558 gclog_or_tty->flush(); |