--- old/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2015-06-04 22:45:29.820046434 +0900 +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2015-06-04 22:45:29.697213899 +0900 @@ -290,9 +290,9 @@ if (_gc_cause != GCCause::_gc_locker && gch->total_full_collections_completed() <= _full_gc_count_before) { // maybe we should change the condition to test _gc_cause == - // GCCause::_java_lang_system_gc, instead of - // _gc_cause != GCCause::_gc_locker - assert(_gc_cause == GCCause::_java_lang_system_gc, + // GCCause::_java_lang_system_gc or GCCause::_dcmd_gc_run, + // instead of _gc_cause != GCCause::_gc_locker + assert(GCCause::is_user_requested_gc(_gc_cause), "the only way to get here if this was a System.gc()-induced GC"); assert(ExplicitGCInvokesConcurrent, "Error"); // Now, wait for witnessing concurrent gc cycle to complete, --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-06-04 22:45:30.429625806 +0900 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-06-04 22:45:30.280210111 +0900 @@ -1285,7 +1285,7 @@ IsGCActiveMark x; // Timing - assert(gc_cause() != GCCause::_java_lang_system_gc || explicit_gc, "invariant"); + assert(!GCCause::is_user_requested_gc(gc_cause()) || explicit_gc, "invariant"); TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); { @@ -2329,6 +2329,7 @@ switch (cause) { case GCCause::_gc_locker: return GCLockerInvokesConcurrent; case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent; + case GCCause::_dcmd_gc_run: return ExplicitGCInvokesConcurrent; case GCCause::_g1_humongous_allocation: return true; case GCCause::_update_allocation_context_stats_inc: return true; default: return false; --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-06-04 22:45:31.204204107 +0900 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-06-04 22:45:31.037371857 +0900 @@ -341,7 +341,8 @@ // explicitly started if: // (a) cause == _gc_locker and +GCLockerInvokesConcurrent, or // (b) cause == _java_lang_system_gc and +ExplicitGCInvokesConcurrent. - // (c) cause == _g1_humongous_allocation + // (c) cause == _dcmd_gc_run and +ExplicitGCInvokesConcurrent. + // (d) cause == _g1_humongous_allocation bool should_do_concurrent_full_gc(GCCause::Cause cause); // Keeps track of how many "old marking cycles" (i.e., Full GCs or --- old/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp 2015-06-04 22:45:31.818366783 +0900 +++ new/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp 2015-06-04 22:45:31.672617730 +0900 @@ -173,7 +173,7 @@ // +ExplicitGCInvokesConcurrent, we have to wait here for the cycle // that just started (or maybe one that was already in progress) to // finish. - if (_gc_cause == GCCause::_java_lang_system_gc && + if (GCCause::is_user_requested_gc(_gc_cause) && _should_initiate_conc_mark) { assert(ExplicitGCInvokesConcurrent, "the only way to be here is if ExplicitGCInvokesConcurrent is set"); --- old/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp 2015-06-04 22:45:32.383029781 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp 2015-06-04 22:45:32.250113978 +0900 @@ -132,7 +132,7 @@ // Update the pause time. _major_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || + if (!GCCause::is_user_requested_gc(gc_cause) || UseAdaptiveSizePolicyWithSystemGC) { double major_pause_in_seconds = _major_timer.seconds(); double major_pause_in_ms = major_pause_in_seconds * MILLIUNITS; --- old/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp 2015-06-04 22:45:32.902776403 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp 2015-06-04 22:45:32.779027208 +0900 @@ -279,7 +279,7 @@ // Don't check if the size_policy is ready here. Let // the size_policy check that internally. if (UseAdaptiveGenerationSizePolicyAtMajorCollection && - ((gc_cause != GCCause::_java_lang_system_gc) || + (!GCCause::is_user_requested_gc(gc_cause) || UseAdaptiveSizePolicyWithSystemGC)) { // Calculate optimal free space amounts assert(young_gen->max_size() > --- old/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp 2015-06-04 22:45:33.430772973 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp 2015-06-04 22:45:33.293273866 +0900 @@ -2078,7 +2078,7 @@ marking_phase(vmthread_cm, maximum_heap_compaction, &_gc_tracer); bool max_on_system_gc = UseMaximumCompactionOnSystemGC - && gc_cause == GCCause::_java_lang_system_gc; + && GCCause::is_user_requested_gc(gc_cause); summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc); COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity")); @@ -2113,7 +2113,7 @@ // Don't check if the size_policy is ready here. Let // the size_policy check that internally. if (UseAdaptiveGenerationSizePolicyAtMajorCollection && - ((gc_cause != GCCause::_java_lang_system_gc) || + (!GCCause::is_user_requested_gc(gc_cause) || UseAdaptiveSizePolicyWithSystemGC)) { // Calculate optimal free space amounts assert(young_gen->max_size() > --- old/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp 2015-06-04 22:45:34.022935792 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp 2015-06-04 22:45:33.894603292 +0900 @@ -297,7 +297,7 @@ AdaptiveSizePolicyOutput(size_policy, heap->total_collections()); - if ((gc_cause != GCCause::_java_lang_system_gc) || + if (!GCCause::is_user_requested_gc(gc_cause) || UseAdaptiveSizePolicyWithSystemGC) { // Gather the feedback data for eden occupancy. young_gen->eden_space()->accumulate_statistics(); --- old/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp 2015-06-04 22:45:34.533515808 +0900 +++ new/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp 2015-06-04 22:45:34.405183308 +0900 @@ -244,7 +244,7 @@ // Update the pause time. _minor_timer.stop(); - if (gc_cause != GCCause::_java_lang_system_gc || + if (!GCCause::is_user_requested_gc(gc_cause) || UseAdaptiveSizePolicyWithSystemGC) { double minor_pause_in_seconds = _minor_timer.seconds(); double minor_pause_in_ms = minor_pause_in_seconds * MILLIUNITS; --- old/src/share/vm/gc_interface/gcCause.cpp 2015-06-04 22:45:35.039512520 +0900 +++ new/src/share/vm/gc_interface/gcCause.cpp 2015-06-04 22:45:34.912096681 +0900 @@ -100,6 +100,9 @@ case _last_ditch_collection: return "Last ditch collection"; + case _dcmd_gc_run: + return "Diagnostic Command"; + case _last_gc_cause: return "ILLEGAL VALUE - last gc cause - ILLEGAL VALUE"; --- old/src/share/vm/gc_interface/gcCause.hpp 2015-06-04 22:45:35.523509375 +0900 +++ new/src/share/vm/gc_interface/gcCause.hpp 2015-06-04 22:45:35.396093536 +0900 @@ -73,12 +73,15 @@ _g1_humongous_allocation, _last_ditch_collection, + + _dcmd_gc_run, + _last_gc_cause }; inline static bool is_user_requested_gc(GCCause::Cause cause) { return (cause == GCCause::_java_lang_system_gc || - cause == GCCause::_jvmti_force_gc); + cause == GCCause::_dcmd_gc_run); } inline static bool is_serviceability_requested_gc(GCCause::Cause --- old/src/share/vm/memory/defNewGeneration.cpp 2015-06-04 22:45:36.011172873 +0900 +++ new/src/share/vm/memory/defNewGeneration.cpp 2015-06-04 22:45:35.886507016 +0900 @@ -953,7 +953,7 @@ GCCause::to_string(gch->gc_cause())); } assert(gch->gc_cause() == GCCause::_scavenge_alot || - (gch->gc_cause() == GCCause::_java_lang_system_gc && UseConcMarkSweepGC && ExplicitGCInvokesConcurrent) || + (GCCause::is_user_requested_gc(gch->gc_cause()) && UseConcMarkSweepGC && ExplicitGCInvokesConcurrent) || !gch->incremental_collection_failed(), "Twice in a row"); seen_incremental_collection_failed = false; --- old/src/share/vm/memory/genCollectedHeap.cpp 2015-06-04 22:45:36.527252853 +0900 +++ new/src/share/vm/memory/genCollectedHeap.cpp 2015-06-04 22:45:36.400753675 +0900 @@ -349,9 +349,16 @@ } bool GenCollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { - return UseConcMarkSweepGC && - ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) || - (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); + if (!UseConcMarkSweepGC) { + return false; + } + + switch (cause) { + case GCCause::_gc_locker: return GCLockerInvokesConcurrent; + case GCCause::_java_lang_system_gc: + case GCCause::_dcmd_gc_run: return ExplicitGCInvokesConcurrent; + default: return false; + } } void GenCollectedHeap::do_collection(bool full, --- old/src/share/vm/services/diagnosticCommand.cpp 2015-06-04 22:45:37.069915994 +0900 +++ new/src/share/vm/services/diagnosticCommand.cpp 2015-06-04 22:45:36.939750173 +0900 @@ -257,7 +257,7 @@ void SystemGCDCmd::execute(DCmdSource source, TRAPS) { if (!DisableExplicitGC) { - Universe::heap()->collect(GCCause::_java_lang_system_gc); + Universe::heap()->collect(GCCause::_dcmd_gc_run); } else { output()->print_cr("Explicit GC is disabled, no GC has been performed."); }