--- old/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2015-03-11 22:04:28.567867000 +0900 +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2015-03-11 22:04:28.145867000 +0900 @@ -256,9 +256,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 + // GCCause::_java_lang_system_gc or _dcmd_gc_run, instead of // _gc_cause != GCCause::_gc_locker - assert(_gc_cause == GCCause::_java_lang_system_gc, + 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-03-11 22:04:29.284867000 +0900 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-03-11 22:04:29.117867000 +0900 @@ -1221,7 +1221,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); { @@ -2252,6 +2252,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; case GCCause::_wb_conc_mark: return true; --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-03-11 22:04:29.959867000 +0900 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-03-11 22:04:29.830867000 +0900 @@ -321,7 +321,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-03-11 22:04:30.542867000 +0900 +++ new/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp 2015-03-11 22:04:30.342867000 +0900 @@ -169,7 +169,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-03-11 22:04:31.036867000 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp 2015-03-11 22:04:30.910867000 +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-03-11 22:04:31.543867000 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp 2015-03-11 22:04:31.417867000 +0900 @@ -275,7 +275,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)) { // Swap the survivor spaces if from_space is empty. The // resize_young_gen() called below is normally used after --- old/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp 2015-03-11 22:04:32.035867000 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp 2015-03-11 22:04:31.905867000 +0900 @@ -2074,7 +2074,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")); @@ -2110,7 +2110,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)) { // Swap the survivor spaces if from_space is empty. The // resize_young_gen() called below is normally used after --- old/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp 2015-03-11 22:04:32.608867000 +0900 +++ new/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp 2015-03-11 22:04:32.481867000 +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-03-11 22:04:33.112867000 +0900 +++ new/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp 2015-03-11 22:04:32.987867000 +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-03-11 22:04:33.700867000 +0900 +++ new/src/share/vm/gc_interface/gcCause.cpp 2015-03-11 22:04:33.521867000 +0900 @@ -103,6 +103,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-03-11 22:04:34.160867000 +0900 +++ new/src/share/vm/gc_interface/gcCause.hpp 2015-03-11 22:04:34.038867000 +0900 @@ -74,12 +74,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-03-11 22:04:34.647867000 +0900 +++ new/src/share/vm/memory/defNewGeneration.cpp 2015-03-11 22:04:34.497867000 +0900 @@ -952,7 +952,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-03-11 22:04:35.141867000 +0900 +++ new/src/share/vm/memory/genCollectedHeap.cpp 2015-03-11 22:04:35.014867000 +0900 @@ -310,9 +310,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::collect_generation(Generation* gen, bool full, size_t size, --- old/src/share/vm/services/diagnosticCommand.cpp 2015-03-11 22:04:35.736867000 +0900 +++ new/src/share/vm/services/diagnosticCommand.cpp 2015-03-11 22:04:35.550867000 +0900 @@ -269,7 +269,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."); } --- old/test/serviceability/dcmd/gc/RunGCTest.java 2015-03-11 22:04:36.312867000 +0900 +++ new/test/serviceability/dcmd/gc/RunGCTest.java 2015-03-11 22:04:36.152867000 +0900 @@ -55,7 +55,7 @@ } OutputAnalyzer output = new OutputAnalyzer(gcLog, ""); - output.shouldMatch(".*\\[Full GC \\(System(\\.gc\\(\\))?.*"); + output.shouldContain("[Full GC (Diagnostic Command)"); } @Test