39 #include "gc/z/zRootsIterator.hpp" |
39 #include "gc/z/zRootsIterator.hpp" |
40 #include "gc/z/zStat.hpp" |
40 #include "gc/z/zStat.hpp" |
41 #include "gc/z/zTask.hpp" |
41 #include "gc/z/zTask.hpp" |
42 #include "gc/z/zThread.hpp" |
42 #include "gc/z/zThread.hpp" |
43 #include "gc/z/zTracer.inline.hpp" |
43 #include "gc/z/zTracer.inline.hpp" |
|
44 #include "gc/z/zVerify.hpp" |
44 #include "gc/z/zVirtualMemory.inline.hpp" |
45 #include "gc/z/zVirtualMemory.inline.hpp" |
45 #include "gc/z/zWorkers.inline.hpp" |
46 #include "gc/z/zWorkers.inline.hpp" |
46 #include "logging/log.hpp" |
47 #include "logging/log.hpp" |
47 #include "memory/resourceArea.hpp" |
48 #include "memory/resourceArea.hpp" |
48 #include "oops/oop.inline.hpp" |
49 #include "oops/oop.inline.hpp" |
338 } |
339 } |
339 |
340 |
340 // Enter mark completed phase |
341 // Enter mark completed phase |
341 ZGlobalPhase = ZPhaseMarkCompleted; |
342 ZGlobalPhase = ZPhaseMarkCompleted; |
342 |
343 |
|
344 // Verify after mark |
|
345 ZVerify::after_mark(); |
|
346 |
343 // Update statistics |
347 // Update statistics |
344 ZStatSample(ZSamplerHeapUsedAfterMark, used()); |
348 ZStatSample(ZSamplerHeapUsedAfterMark, used()); |
345 ZStatHeap::set_at_mark_end(capacity(), allocated(), used()); |
349 ZStatHeap::set_at_mark_end(capacity(), allocated(), used()); |
346 |
350 |
347 // Block resurrection of weak/phantom references |
351 // Block resurrection of weak/phantom references |
466 ZStatRelocation::set_at_relocate_end(success); |
470 ZStatRelocation::set_at_relocate_end(success); |
467 ZStatHeap::set_at_relocate_end(capacity(), allocated(), reclaimed(), |
471 ZStatHeap::set_at_relocate_end(capacity(), allocated(), reclaimed(), |
468 used(), used_high(), used_low()); |
472 used(), used_high(), used_low()); |
469 } |
473 } |
470 |
474 |
471 void ZHeap::object_iterate(ObjectClosure* cl, bool visit_referents) { |
475 void ZHeap::object_iterate(ObjectClosure* cl, bool visit_weaks) { |
472 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
476 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
473 |
477 |
474 ZHeapIterator iter; |
478 ZHeapIterator iter; |
475 iter.objects_do(cl, visit_referents); |
479 iter.objects_do(cl, visit_weaks); |
476 } |
480 } |
477 |
481 |
478 void ZHeap::serviceability_initialize() { |
482 void ZHeap::serviceability_initialize() { |
479 _serviceability.initialize(); |
483 _serviceability.initialize(); |
480 } |
484 } |
516 _page_allocator.enable_deferred_delete(); |
520 _page_allocator.enable_deferred_delete(); |
517 |
521 |
518 st->cr(); |
522 st->cr(); |
519 } |
523 } |
520 |
524 |
521 class ZVerifyRootsTask : public ZTask { |
|
522 private: |
|
523 ZStatTimerDisable _disable; |
|
524 ZRootsIterator _strong_roots; |
|
525 ZWeakRootsIterator _weak_roots; |
|
526 |
|
527 public: |
|
528 ZVerifyRootsTask() : |
|
529 ZTask("ZVerifyRootsTask"), |
|
530 _disable(), |
|
531 _strong_roots(), |
|
532 _weak_roots() {} |
|
533 |
|
534 virtual void work() { |
|
535 ZStatTimerDisable disable; |
|
536 ZVerifyOopClosure cl; |
|
537 _strong_roots.oops_do(&cl); |
|
538 _weak_roots.oops_do(&cl); |
|
539 } |
|
540 }; |
|
541 |
|
542 void ZHeap::verify() { |
525 void ZHeap::verify() { |
543 // Heap verification can only be done between mark end and |
526 // Heap verification can only be done between mark end and |
544 // relocate start. This is the only window where all oop are |
527 // relocate start. This is the only window where all oop are |
545 // good and the whole heap is in a consistent state. |
528 // good and the whole heap is in a consistent state. |
546 guarantee(ZGlobalPhase == ZPhaseMarkCompleted, "Invalid phase"); |
529 guarantee(ZGlobalPhase == ZPhaseMarkCompleted, "Invalid phase"); |
547 |
530 |
548 { |
531 ZVerify::after_weak_processing(); |
549 ZVerifyRootsTask task; |
532 } |
550 _workers.run_parallel(&task); |
|
551 } |
|
552 |
|
553 { |
|
554 ZVerifyObjectClosure cl; |
|
555 object_iterate(&cl, false /* visit_referents */); |
|
556 } |
|
557 } |
|