8081607: Change default GC for server configurations to G1
authorsjohanss
Wed, 24 Jun 2015 08:37:12 +0200
changeset 31390 7f35f0462aea
parent 31388 40814c7eba5c
child 31391 dbef845a80ba
8081607: Change default GC for server configurations to G1 Summary: For more info see JEP 248. Reviewed-by: pliden, tschatzl
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/test/gc/arguments/TestSelectDefaultGC.java
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Jun 23 22:10:33 2015 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jun 24 08:37:12 2015 +0200
@@ -1535,7 +1535,11 @@
     if (should_auto_select_low_pause_collector()) {
       FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
     } else {
+#if defined(JAVASE_EMBEDDED)
       FLAG_SET_ERGO(bool, UseParallelGC, true);
+#else
+      FLAG_SET_ERGO(bool, UseG1GC, true);
+#endif
     }
   } else {
     FLAG_SET_ERGO(bool, UseSerialGC, true);
--- a/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Tue Jun 23 22:10:33 2015 -0400
+++ b/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Wed Jun 24 08:37:12 2015 +0200
@@ -36,11 +36,6 @@
 import java.util.regex.*;
 
 public class TestSelectDefaultGC {
-    public static boolean versionStringContains(OutputAnalyzer output, String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStderr());
-        return matcher.find();
-    }
-
     public static void assertVMOption(OutputAnalyzer output, String option, boolean value) {
         output.shouldMatch(" " + option + " .*=.* " + value + " ");
     }
@@ -51,14 +46,18 @@
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldHaveExitValue(0);
 
-        boolean isServerVM = versionStringContains(output, "Server VM");
+        boolean isServerVM = Platform.isServer();
+        boolean isEmbeddedVM = Platform.isEmbedded();
 
         // Verify GC selection
-        assertVMOption(output, "UseParallelGC",      isServerVM);
-        assertVMOption(output, "UseParallelOldGC",   isServerVM);
+        // G1 is default for non-embedded server VMs
+        assertVMOption(output, "UseG1GC",            isServerVM && !isEmbeddedVM);
+        // Parallel is default for embedded server VMs
+        assertVMOption(output, "UseParallelGC",      isServerVM && isEmbeddedVM);
+        assertVMOption(output, "UseParallelOldGC",   isServerVM && isEmbeddedVM);
+        // Serial is default for non-server VMs
         assertVMOption(output, "UseSerialGC",        !isServerVM);
         assertVMOption(output, "UseConcMarkSweepGC", false);
-        assertVMOption(output, "UseG1GC",            false);
         assertVMOption(output, "UseParNewGC",        false);
     }
 }