2168 // Track memory usage and detect low memory |
2168 // Track memory usage and detect low memory |
2169 MemoryService::track_memory_usage(); |
2169 MemoryService::track_memory_usage(); |
2170 heap->update_counters(); |
2170 heap->update_counters(); |
2171 } |
2171 } |
2172 |
2172 |
|
2173 #ifdef ASSERT |
|
2174 for (size_t i = 0; i < ParallelGCThreads + 1; ++i) { |
|
2175 ParCompactionManager* const cm = |
|
2176 ParCompactionManager::manager_array(int(i)); |
|
2177 assert(cm->marking_stack()->is_empty(), "should be empty"); |
|
2178 assert(cm->region_stack()->is_empty(), "should be empty"); |
|
2179 assert(cm->revisit_klass_stack()->is_empty(), "should be empty"); |
|
2180 } |
|
2181 #endif // ASSERT |
|
2182 |
2173 if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { |
2183 if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { |
2174 HandleMark hm; // Discard invalid handles created during verification |
2184 HandleMark hm; // Discard invalid handles created during verification |
2175 gclog_or_tty->print(" VerifyAfterGC:"); |
2185 gclog_or_tty->print(" VerifyAfterGC:"); |
2176 Universe::verify(false); |
2186 Universe::verify(false); |
2177 } |
2187 } |
2709 void |
2719 void |
2710 PSParallelCompact::follow_weak_klass_links() { |
2720 PSParallelCompact::follow_weak_klass_links() { |
2711 // All klasses on the revisit stack are marked at this point. |
2721 // All klasses on the revisit stack are marked at this point. |
2712 // Update and follow all subklass, sibling and implementor links. |
2722 // Update and follow all subklass, sibling and implementor links. |
2713 if (PrintRevisitStats) { |
2723 if (PrintRevisitStats) { |
2714 gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes()); |
2724 gclog_or_tty->print_cr("#classes in system dictionary = %d", |
|
2725 SystemDictionary::number_of_classes()); |
2715 } |
2726 } |
2716 for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
2727 for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
2717 ParCompactionManager* cm = ParCompactionManager::manager_array(i); |
2728 ParCompactionManager* cm = ParCompactionManager::manager_array(i); |
2718 KeepAliveClosure keep_alive_closure(cm); |
2729 KeepAliveClosure keep_alive_closure(cm); |
2719 int length = cm->revisit_klass_stack()->length(); |
2730 Stack<Klass*>* const rks = cm->revisit_klass_stack(); |
2720 if (PrintRevisitStats) { |
2731 if (PrintRevisitStats) { |
2721 gclog_or_tty->print_cr("Revisit klass stack[%d] length = %d", i, length); |
2732 gclog_or_tty->print_cr("Revisit klass stack[%u] length = " SIZE_FORMAT, |
2722 } |
2733 i, rks->size()); |
2723 for (int j = 0; j < length; j++) { |
2734 } |
2724 cm->revisit_klass_stack()->at(j)->follow_weak_klass_links( |
2735 while (!rks->is_empty()) { |
2725 is_alive_closure(), |
2736 Klass* const k = rks->pop(); |
2726 &keep_alive_closure); |
2737 k->follow_weak_klass_links(is_alive_closure(), &keep_alive_closure); |
2727 } |
2738 } |
2728 // revisit_klass_stack is cleared in reset() |
2739 |
2729 cm->follow_marking_stacks(); |
2740 cm->follow_marking_stacks(); |
2730 } |
2741 } |
2731 } |
2742 } |
2732 |
2743 |
2733 void |
2744 void |
2742 void PSParallelCompact::follow_mdo_weak_refs() { |
2753 void PSParallelCompact::follow_mdo_weak_refs() { |
2743 // All strongly reachable oops have been marked at this point; |
2754 // All strongly reachable oops have been marked at this point; |
2744 // we can visit and clear any weak references from MDO's which |
2755 // we can visit and clear any weak references from MDO's which |
2745 // we memoized during the strong marking phase. |
2756 // we memoized during the strong marking phase. |
2746 if (PrintRevisitStats) { |
2757 if (PrintRevisitStats) { |
2747 gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes()); |
2758 gclog_or_tty->print_cr("#classes in system dictionary = %d", |
|
2759 SystemDictionary::number_of_classes()); |
2748 } |
2760 } |
2749 for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
2761 for (uint i = 0; i < ParallelGCThreads + 1; i++) { |
2750 ParCompactionManager* cm = ParCompactionManager::manager_array(i); |
2762 ParCompactionManager* cm = ParCompactionManager::manager_array(i); |
2751 GrowableArray<DataLayout*>* rms = cm->revisit_mdo_stack(); |
2763 Stack<DataLayout*>* rms = cm->revisit_mdo_stack(); |
2752 int length = rms->length(); |
|
2753 if (PrintRevisitStats) { |
2764 if (PrintRevisitStats) { |
2754 gclog_or_tty->print_cr("Revisit MDO stack[%d] length = %d", i, length); |
2765 gclog_or_tty->print_cr("Revisit MDO stack[%u] size = " SIZE_FORMAT, |
2755 } |
2766 i, rms->size()); |
2756 for (int j = 0; j < length; j++) { |
2767 } |
2757 rms->at(j)->follow_weak_refs(is_alive_closure()); |
2768 while (!rms->is_empty()) { |
2758 } |
2769 rms->pop()->follow_weak_refs(is_alive_closure()); |
2759 // revisit_mdo_stack is cleared in reset() |
2770 } |
|
2771 |
2760 cm->follow_marking_stacks(); |
2772 cm->follow_marking_stacks(); |
2761 } |
2773 } |
2762 } |
2774 } |
2763 |
2775 |
2764 |
2776 |