Mercurial > hg > graal-compiler
diff src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 1836:894b1d7c7e01
6423256: GC stacks should use a better data structure
6942771: SEGV in ParScanThreadState::take_from_overflow_stack
Reviewed-by: apetrusenko, ysr, pbk
author | jcoomes |
---|---|
date | Tue, 28 Sep 2010 15:56:15 -0700 |
parents | 8b10f48633dc |
children | f95d63e2154a |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Sep 28 09:51:37 2010 -0700 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Sep 28 15:56:15 2010 -0700 @@ -2170,6 +2170,16 @@ heap->update_counters(); } +#ifdef ASSERT + for (size_t i = 0; i < ParallelGCThreads + 1; ++i) { + ParCompactionManager* const cm = + ParCompactionManager::manager_array(int(i)); + assert(cm->marking_stack()->is_empty(), "should be empty"); + assert(cm->region_stack()->is_empty(), "should be empty"); + assert(cm->revisit_klass_stack()->is_empty(), "should be empty"); + } +#endif // ASSERT + if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); @@ -2711,21 +2721,22 @@ // All klasses on the revisit stack are marked at this point. // Update and follow all subklass, sibling and implementor links. if (PrintRevisitStats) { - gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes()); + gclog_or_tty->print_cr("#classes in system dictionary = %d", + SystemDictionary::number_of_classes()); } for (uint i = 0; i < ParallelGCThreads + 1; i++) { ParCompactionManager* cm = ParCompactionManager::manager_array(i); KeepAliveClosure keep_alive_closure(cm); - int length = cm->revisit_klass_stack()->length(); + Stack<Klass*>* const rks = cm->revisit_klass_stack(); if (PrintRevisitStats) { - gclog_or_tty->print_cr("Revisit klass stack[%d] length = %d", i, length); + gclog_or_tty->print_cr("Revisit klass stack[%u] length = " SIZE_FORMAT, + i, rks->size()); } - for (int j = 0; j < length; j++) { - cm->revisit_klass_stack()->at(j)->follow_weak_klass_links( - is_alive_closure(), - &keep_alive_closure); + while (!rks->is_empty()) { + Klass* const k = rks->pop(); + k->follow_weak_klass_links(is_alive_closure(), &keep_alive_closure); } - // revisit_klass_stack is cleared in reset() + cm->follow_marking_stacks(); } } @@ -2744,19 +2755,20 @@ // we can visit and clear any weak references from MDO's which // we memoized during the strong marking phase. if (PrintRevisitStats) { - gclog_or_tty->print_cr("#classes in system dictionary = %d", SystemDictionary::number_of_classes()); + gclog_or_tty->print_cr("#classes in system dictionary = %d", + SystemDictionary::number_of_classes()); } for (uint i = 0; i < ParallelGCThreads + 1; i++) { ParCompactionManager* cm = ParCompactionManager::manager_array(i); - GrowableArray<DataLayout*>* rms = cm->revisit_mdo_stack(); - int length = rms->length(); + Stack<DataLayout*>* rms = cm->revisit_mdo_stack(); if (PrintRevisitStats) { - gclog_or_tty->print_cr("Revisit MDO stack[%d] length = %d", i, length); + gclog_or_tty->print_cr("Revisit MDO stack[%u] size = " SIZE_FORMAT, + i, rms->size()); } - for (int j = 0; j < length; j++) { - rms->at(j)->follow_weak_refs(is_alive_closure()); + while (!rms->is_empty()) { + rms->pop()->follow_weak_refs(is_alive_closure()); } - // revisit_mdo_stack is cleared in reset() + cm->follow_marking_stacks(); } }