comparison src/share/vm/gc_implementation/shared/markSweep.cpp @ 941:8b46c4d82093

4957990: Perm heap bloat in JVM Summary: Treat ProfileData in MDO's as a source of weak, not strong, roots. Fixes the bug for stop-world collection -- the case of concurrent collection will be fixed separately. Reviewed-by: jcoomes, jmasa, kvn, never
author ysr
date Wed, 02 Sep 2009 00:04:29 -0700
parents d1605aabd0a1
children 89e0543e1737 c3c4a1d3801a 54b3b351d6f9
comparison
equal deleted inserted replaced
940:8624da129f0b 941:8b46c4d82093
25 #include "incls/_precompiled.incl" 25 #include "incls/_precompiled.incl"
26 #include "incls/_markSweep.cpp.incl" 26 #include "incls/_markSweep.cpp.incl"
27 27
28 GrowableArray<oop>* MarkSweep::_marking_stack = NULL; 28 GrowableArray<oop>* MarkSweep::_marking_stack = NULL;
29 GrowableArray<Klass*>* MarkSweep::_revisit_klass_stack = NULL; 29 GrowableArray<Klass*>* MarkSweep::_revisit_klass_stack = NULL;
30 GrowableArray<DataLayout*>* MarkSweep::_revisit_mdo_stack = NULL;
30 31
31 GrowableArray<oop>* MarkSweep::_preserved_oop_stack = NULL; 32 GrowableArray<oop>* MarkSweep::_preserved_oop_stack = NULL;
32 GrowableArray<markOop>* MarkSweep::_preserved_mark_stack= NULL; 33 GrowableArray<markOop>* MarkSweep::_preserved_mark_stack= NULL;
33 size_t MarkSweep::_preserved_count = 0; 34 size_t MarkSweep::_preserved_count = 0;
34 size_t MarkSweep::_preserved_count_max = 0; 35 size_t MarkSweep::_preserved_count_max = 0;
60 } 61 }
61 62
62 void MarkSweep::follow_weak_klass_links() { 63 void MarkSweep::follow_weak_klass_links() {
63 // All klasses on the revisit stack are marked at this point. 64 // All klasses on the revisit stack are marked at this point.
64 // Update and follow all subklass, sibling and implementor links. 65 // Update and follow all subklass, sibling and implementor links.
66 if (PrintRevisitStats) {
67 gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes());
68 gclog_or_tty->print_cr("Revisit klass stack length = %d", _revisit_klass_stack->length());
69 }
65 for (int i = 0; i < _revisit_klass_stack->length(); i++) { 70 for (int i = 0; i < _revisit_klass_stack->length(); i++) {
66 _revisit_klass_stack->at(i)->follow_weak_klass_links(&is_alive,&keep_alive); 71 _revisit_klass_stack->at(i)->follow_weak_klass_links(&is_alive,&keep_alive);
67 } 72 }
68 follow_stack(); 73 follow_stack();
69 } 74 }
75
76 #if ( defined(COMPILER1) || defined(COMPILER2) )
77 void MarkSweep::revisit_mdo(DataLayout* p) {
78 _revisit_mdo_stack->push(p);
79 }
80
81 void MarkSweep::follow_mdo_weak_refs() {
82 // All strongly reachable oops have been marked at this point;
83 // we can visit and clear any weak references from MDO's which
84 // we memoized during the strong marking phase.
85 assert(_marking_stack->is_empty(), "Marking stack should be empty");
86 if (PrintRevisitStats) {
87 gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes());
88 gclog_or_tty->print_cr("Revisit MDO stack length = %d", _revisit_mdo_stack->length());
89 }
90 for (int i = 0; i < _revisit_mdo_stack->length(); i++) {
91 _revisit_mdo_stack->at(i)->follow_weak_refs(&is_alive);
92 }
93 follow_stack();
94 }
95 #endif // ( COMPILER1 || COMPILER2 )
70 96
71 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; 97 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure;
72 98
73 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } 99 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); }
74 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } 100 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }