|
49 | 49 | #include "gc/shared/gcTrace.hpp" |
50 | 50 | #include "gc/shared/gcTraceTime.inline.hpp" |
51 | 51 | #include "gc/shared/modRefBarrierSet.hpp" |
| 52 | +#include "gc/shared/oopStorageSet.inline.hpp" |
52 | 53 | #include "gc/shared/preservedMarks.inline.hpp" |
53 | 54 | #include "gc/shared/referencePolicy.hpp" |
54 | 55 | #include "gc/shared/referenceProcessorPhaseTimes.hpp" |
|
66 | 67 | #include "oops/oop.inline.hpp" |
67 | 68 | #include "oops/typeArrayOop.inline.hpp" |
68 | 69 | #include "runtime/prefetch.inline.hpp" |
| 70 | +#include "runtime/threads.hpp" |
69 | 71 | #include "utilities/align.hpp" |
70 | 72 | #include "utilities/copy.hpp" |
71 | 73 | #include "utilities/events.hpp" |
@@ -483,13 +485,22 @@ void SerialFullGC::phase1_mark(bool clear_all_softrefs) { |
483 | 485 | { |
484 | 486 | StrongRootsScope srs(0); |
485 | 487 |
|
486 | | - CLDClosure* weak_cld_closure = ClassUnloading ? nullptr : &follow_cld_closure; |
487 | | - MarkingNMethodClosure mark_code_closure(&follow_root_closure, !NMethodToOopClosure::FixRelocations, true); |
488 | | - gch->process_roots(SerialHeap::SO_None, |
489 | | - &follow_root_closure, |
490 | | - &follow_cld_closure, |
491 | | - weak_cld_closure, |
492 | | - &mark_code_closure); |
| 488 | + MarkingNMethodClosure mark_code_closure(&follow_root_closure, |
| 489 | + !NMethodToOopClosure::FixRelocations, |
| 490 | + true); |
| 491 | + |
| 492 | + // Start tracing from roots, there are 3 kinds of roots in full-gc. |
| 493 | + // |
| 494 | + // 1. CLD. This method internally takes care of whether class loading is |
| 495 | + // enabled or not, applying the closure to both strong and weak or only |
| 496 | + // strong CLDs. |
| 497 | + ClassLoaderDataGraph::always_strong_cld_do(&follow_cld_closure); |
| 498 | + |
| 499 | + // 2. Threads stack frames and active nmethods in them. |
| 500 | + Threads::oops_do(&follow_root_closure, &mark_code_closure); |
| 501 | + |
| 502 | + // 3. VM internal roots. |
| 503 | + OopStorageSet::strong_oops_do(&follow_root_closure); |
493 | 504 | } |
494 | 505 |
|
495 | 506 | // Process reference objects found during marking |
@@ -717,13 +728,20 @@ void SerialFullGC::invoke_at_safepoint(bool clear_all_softrefs) { |
717 | 728 |
|
718 | 729 | ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust); |
719 | 730 |
|
720 | | - NMethodToOopClosure code_closure(&adjust_pointer_closure, NMethodToOopClosure::FixRelocations); |
721 | | - gch->process_roots(SerialHeap::SO_AllCodeCache, |
722 | | - &adjust_pointer_closure, |
723 | | - &adjust_cld_closure, |
724 | | - &adjust_cld_closure, |
725 | | - &code_closure); |
| 731 | + // Remap strong and weak roots in adjust phase. |
| 732 | + // 1. All (strong and weak) CLDs. |
| 733 | + ClassLoaderDataGraph::cld_do(&adjust_cld_closure); |
| 734 | + |
| 735 | + // 2. Threads stack frames. No need to visit on-stack nmethods, because all |
| 736 | + // nmethods are visited in one go via CodeCache::nmethods_do. |
| 737 | + Threads::oops_do(&adjust_pointer_closure, nullptr); |
| 738 | + NMethodToOopClosure nmethod_cl(&adjust_pointer_closure, NMethodToOopClosure::FixRelocations); |
| 739 | + CodeCache::nmethods_do(&nmethod_cl); |
| 740 | + |
| 741 | + // 3. VM internal roots |
| 742 | + OopStorageSet::strong_oops_do(&adjust_pointer_closure); |
726 | 743 |
|
| 744 | + // 4. VM internal weak roots |
727 | 745 | WeakProcessor::oops_do(&adjust_pointer_closure); |
728 | 746 |
|
729 | 747 | adjust_marks(); |
|
0 commit comments