--- old/src/share/vm/gc/cms/vmCMSOperations.cpp 2015-05-28 12:11:59.185252624 +0900 +++ new/src/share/vm/gc/cms/vmCMSOperations.cpp 2015-05-28 12:11:58.968587459 +0900 @@ -254,9 +254,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/g1/g1CollectedHeap.cpp 2015-05-28 12:11:59.862331265 +0900 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2015-05-28 12:11:59.671665919 +0900 @@ -1183,7 +1183,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); { @@ -2199,6 +2199,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/g1/g1CollectedHeap.hpp 2015-05-28 12:12:00.587076242 +0900 +++ new/src/share/vm/gc/g1/g1CollectedHeap.hpp 2015-05-28 12:12:00.460327120 +0900 @@ -324,7 +324,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/g1/vm_operations_g1.cpp 2015-05-28 12:12:01.151488997 +0900 +++ new/src/share/vm/gc/g1/vm_operations_g1.cpp 2015-05-28 12:12:01.024739875 +0900 @@ -168,7 +168,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/parallel/psAdaptiveSizePolicy.cpp 2015-05-28 12:12:01.736484942 +0900 +++ new/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp 2015-05-28 12:12:01.550152900 +0900 @@ -130,7 +130,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/parallel/psMarkSweep.cpp 2015-05-28 12:12:02.297647720 +0900 +++ new/src/share/vm/gc/parallel/psMarkSweep.cpp 2015-05-28 12:12:02.169815273 +0900 @@ -272,7 +272,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/parallel/psParallelCompact.cpp 2015-05-28 12:12:02.837143981 +0900 +++ new/src/share/vm/gc/parallel/psParallelCompact.cpp 2015-05-28 12:12:02.708228208 +0900 @@ -2053,7 +2053,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")); @@ -2089,7 +2089,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/parallel/psScavenge.cpp 2015-05-28 12:12:03.471972915 +0900 +++ new/src/share/vm/gc/parallel/psScavenge.cpp 2015-05-28 12:12:03.340890490 +0900 @@ -290,7 +290,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/serial/defNewGeneration.cpp 2015-05-28 12:12:04.019052456 +0900 +++ new/src/share/vm/gc/serial/defNewGeneration.cpp 2015-05-28 12:12:03.890136683 +0900 @@ -960,7 +960,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/gc/shared/adaptiveSizePolicy.cpp 2015-05-28 12:12:04.572631953 +0900 +++ new/src/share/vm/gc/shared/adaptiveSizePolicy.cpp 2015-05-28 12:12:04.444799506 +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/shared/gcCause.cpp 2015-05-28 12:12:05.109961563 +0900 +++ new/src/share/vm/gc/shared/gcCause.cpp 2015-05-28 12:12:04.984295767 +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/shared/gcCause.hpp 2015-05-28 12:12:05.628874633 +0900 +++ new/src/share/vm/gc/shared/gcCause.hpp 2015-05-28 12:12:05.501042185 +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/gc/shared/genCollectedHeap.cpp 2015-05-28 12:12:06.201953994 +0900 +++ new/src/share/vm/gc/shared/genCollectedHeap.cpp 2015-05-28 12:12:06.022121907 +0900 @@ -304,9 +304,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-05-28 12:12:06.771783379 +0900 +++ new/src/share/vm/services/diagnosticCommand.cpp 2015-05-28 12:12:06.634200999 +0900 @@ -315,7 +315,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-05-28 12:12:07.498695007 +0900 +++ new/test/serviceability/dcmd/gc/RunGCTest.java 2015-05-28 12:12:07.186697170 +0900 @@ -59,7 +59,7 @@ } OutputAnalyzer output = new OutputAnalyzer(gcLog, ""); - output.shouldMatch(".*\\[Full GC \\(System(\\.gc\\(\\))?.*"); + output.shouldContain("[Full GC (Diagnostic Command)"); } @Test