diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp index 50e073d24aa8c51b58e3da540322f6c8bcc9e0e9..482aa15752ae29f8fc5b8f627f76a680429d400f 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp @@ -1963,10 +1963,21 @@ CompactibleFreeListSpace::gc_epilogue() { // Iteration support, mostly delegated from a CMS generation void CompactibleFreeListSpace::save_marks() { - // mark the "end" of the used space at the time of this call; + assert(Thread::current()->is_VM_thread(), + "Global variable should only be set when single-threaded"); + // Mark the "end" of the used space at the time of this call; // note, however, that promoted objects from this point // on are tracked in the _promoInfo below. set_saved_mark_word(unallocated_block()); +#ifdef ASSERT + // Check the sanity of save_marks() etc. + MemRegion ur = used_region(); + MemRegion urasm = used_region_at_save_marks(); + assert(ur.contains(urasm), + err_msg(" Error at save_marks(): [" PTR_FORMAT "," PTR_FORMAT ")" + " should contain [" PTR_FORMAT "," PTR_FORMAT ")", + ur.start(), ur.end(), urasm.start(), urasm.end())); +#endif // inform allocator that promotions should be tracked. assert(_promoInfo.noPromotions(), "_promoInfo inconsistency"); _promoInfo.startTrackingPromotions(); diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 307a8500ca6fb76c22b4dc0fe8e82619102480af..bd49b0f9fc6869d883e7a5614fbef9807b750707 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -3189,10 +3189,9 @@ bool ConcurrentMarkSweepGeneration::is_too_full() const { } void CMSCollector::setup_cms_unloading_and_verification_state() { - const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC + const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC || VerifyBeforeExit; - const int rso = SharedHeap::SO_Symbols | SharedHeap::SO_Strings - | SharedHeap::SO_CodeCache; + const int rso = SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; if (should_unload_classes()) { // Should unload classes this cycle remove_root_scanning_option(rso); // Shrink the root set appropriately diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index d8a9c07f5227736f78a8fc32f05095e629e7e04a..642c7acb74ee9a54918d7a4f2ac7c1bf37fcf4ea 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2805,17 +2805,26 @@ void G1CollectedHeap::verify(bool allow_dirty, bool silent, bool use_prev_marking) { if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) { - if (!silent) { gclog_or_tty->print("roots "); } + if (!silent) { gclog_or_tty->print("Roots (excluding permgen) "); } VerifyRootsClosure rootsCl(use_prev_marking); CodeBlobToOopClosure blobsCl(&rootsCl, /*do_marking=*/ false); - process_strong_roots(true, // activate StrongRootsScope - false, - SharedHeap::SO_AllClasses, + // We apply the relevant closures to all the oops in the + // system dictionary, the string table and the code cache. + const int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; + process_strong_roots(true, // activate StrongRootsScope + true, // we set "collecting perm gen" to true, + // so we don't reset the dirty cards in the perm gen. + SharedHeap::ScanningOption(so), // roots scanning options &rootsCl, &blobsCl, &rootsCl); + // Since we used "collecting_perm_gen" == true above, we will not have + // checked the refs from perm into the G1-collected heap. We check those + // references explicitly below. Whether the relevant cards are dirty + // is checked further below in the rem set verification. + if (!silent) { gclog_or_tty->print("Permgen roots "); } + perm_gen()->oop_iterate(&rootsCl); bool failures = rootsCl.failures(); - rem_set()->invalidate(perm_gen()->used_region(), false); if (!silent) { gclog_or_tty->print("HeapRegionSets "); } verify_region_sets(); if (!silent) { gclog_or_tty->print("HeapRegions "); } diff --git a/src/share/vm/memory/cardTableRS.cpp b/src/share/vm/memory/cardTableRS.cpp index 4a22ba73a215bf3f41d9b7200366e624987c8413..551ba7eb8a4d414b849c405d67153a3b99a61660 100644 --- a/src/share/vm/memory/cardTableRS.cpp +++ b/src/share/vm/memory/cardTableRS.cpp @@ -250,7 +250,34 @@ void CardTableRS::younger_refs_in_space_iterate(Space* sp, cl->gen_boundary()); ClearNoncleanCardWrapper clear_cl(dcto_cl, this); - _ct_bs->non_clean_card_iterate_possibly_parallel(sp, sp->used_region_at_save_marks(), + const MemRegion urasm = sp->used_region_at_save_marks(); +#ifdef ASSERT + // Convert the assertion check to a warning if we are running + // CMS+ParNew until related bug is fixed. + MemRegion ur = sp->used_region(); + assert(ur.contains(urasm) || (UseConcMarkSweepGC && UseParNewGC), + err_msg("Did you forget to call save_marks()? " + "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in " + "[" PTR_FORMAT ", " PTR_FORMAT ")", + urasm.start(), urasm.end(), ur.start(), ur.end())); + // In the case of CMS+ParNew, issue a warning + if (!ur.contains(urasm)) { + assert(UseConcMarkSweepGC && UseParNewGC, "Tautology: see assert above"); + warning("CMS+ParNew: Did you forget to call save_marks()? " + "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in " + "[" PTR_FORMAT ", " PTR_FORMAT ")", + urasm.start(), urasm.end(), ur.start(), ur.end()); + MemRegion ur2 = sp->used_region(); + MemRegion urasm2 = sp->used_region_at_save_marks(); + if (!ur.equals(ur2)) { + warning("CMS+ParNew: Flickering used_region()!!"); + } + if (!urasm.equals(urasm2)) { + warning("CMS+ParNew: Flickering used_region_at_save_marks()!!"); + } + } +#endif + _ct_bs->non_clean_card_iterate_possibly_parallel(sp, urasm, dcto_cl, &clear_cl); } diff --git a/src/share/vm/memory/genCollectedHeap.hpp b/src/share/vm/memory/genCollectedHeap.hpp index de8070b81c75a955ee3504aa3fbe77c362627d2a..383936699d6c0b4e47fe439dd7889d389178c0ce 100644 --- a/src/share/vm/memory/genCollectedHeap.hpp +++ b/src/share/vm/memory/genCollectedHeap.hpp @@ -427,13 +427,13 @@ public: // explicitly mark reachable objects in younger generations, to avoid // excess storage retention.) If "collecting_perm_gen" is false, then // roots that may only contain references to permGen objects are not - // scanned. The "so" argument determines which of the roots + // scanned; instead, the older_gens closure is applied to all outgoing + // references in the perm gen. The "so" argument determines which of the roots // the closure is applied to: // "SO_None" does none; // "SO_AllClasses" applies the closure to all entries in the SystemDictionary; // "SO_SystemClasses" to all the "system" classes and loaders; - // "SO_Symbols_and_Strings" applies the closure to all entries in - // SymbolsTable and StringTable. + // "SO_Strings" applies the closure to all entries in the StringTable. void gen_process_strong_roots(int level, bool younger_gens_as_roots, // The remaining arguments are in an order diff --git a/src/share/vm/memory/sharedHeap.cpp b/src/share/vm/memory/sharedHeap.cpp index 37c17b038614f8cec55ede5e27e1cdc38f5c62b1..24a2373acec8e150344d99fcd0f853e9a7a3bd71 100644 --- a/src/share/vm/memory/sharedHeap.cpp +++ b/src/share/vm/memory/sharedHeap.cpp @@ -46,7 +46,6 @@ enum SH_process_strong_roots_tasks { SH_PS_Management_oops_do, SH_PS_SystemDictionary_oops_do, SH_PS_jvmti_oops_do, - SH_PS_SymbolTable_oops_do, SH_PS_StringTable_oops_do, SH_PS_CodeCache_oops_do, // Leave this one last. @@ -161,13 +160,9 @@ void SharedHeap::process_strong_roots(bool activate_scope, if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) { if (so & SO_AllClasses) { SystemDictionary::oops_do(roots); - } else - if (so & SO_SystemClasses) { - SystemDictionary::always_strong_oops_do(roots); - } - } - - if (!_process_strong_tasks->is_task_claimed(SH_PS_SymbolTable_oops_do)) { + } else if (so & SO_SystemClasses) { + SystemDictionary::always_strong_oops_do(roots); + } } if (!_process_strong_tasks->is_task_claimed(SH_PS_StringTable_oops_do)) { diff --git a/src/share/vm/memory/sharedHeap.hpp b/src/share/vm/memory/sharedHeap.hpp index 54af68a421f9d3ff21a975c5d18708b84bdad0ce..55a9b569d9ca0015214651eb0b0c830e6a595116 100644 --- a/src/share/vm/memory/sharedHeap.hpp +++ b/src/share/vm/memory/sharedHeap.hpp @@ -192,9 +192,8 @@ public: SO_None = 0x0, SO_AllClasses = 0x1, SO_SystemClasses = 0x2, - SO_Symbols = 0x4, - SO_Strings = 0x8, - SO_CodeCache = 0x10 + SO_Strings = 0x4, + SO_CodeCache = 0x8 }; FlexibleWorkGang* workers() const { return _workers; } @@ -208,14 +207,13 @@ public: // Invoke the "do_oop" method the closure "roots" on all root locations. // If "collecting_perm_gen" is false, then roots that may only contain - // references to permGen objects are not scanned. If true, the - // "perm_gen" closure is applied to all older-to-younger refs in the + // references to permGen objects are not scanned; instead, in that case, + // the "perm_blk" closure is applied to all outgoing refs in the // permanent generation. The "so" argument determines which of roots // the closure is applied to: // "SO_None" does none; // "SO_AllClasses" applies the closure to all entries in the SystemDictionary; // "SO_SystemClasses" to all the "system" classes and loaders; - // "SO_Symbols" applies the closure to all entries in SymbolsTable; // "SO_Strings" applies the closure to all entries in StringTable; // "SO_CodeCache" applies the closure to all elements of the CodeCache. void process_strong_roots(bool activate_scope, diff --git a/src/share/vm/runtime/vmThread.cpp b/src/share/vm/runtime/vmThread.cpp index 68890c7d9de755d12d0a069cf80f72d17573e2e9..c50e0a1d7a78002c95800c108fdc048bcce100e2 100644 --- a/src/share/vm/runtime/vmThread.cpp +++ b/src/share/vm/runtime/vmThread.cpp @@ -291,7 +291,9 @@ void VMThread::run() { // Among other things, this ensures that Eden top is correct. Universe::heap()->prepare_for_verify(); os::check_heap(); - Universe::verify(true, true); // Silent verification to not polute normal output + // Silent verification so as not to pollute normal output, + // unless we really asked for it. + Universe::verify(true, !(PrintGCDetails || Verbose)); } CompileBroker::set_should_block();