--- old/src/hotspot/share/runtime/arguments.cpp 2018-04-17 21:08:23.469936763 -0700 +++ new/src/hotspot/share/runtime/arguments.cpp 2018-04-17 21:08:23.229927481 -0700 @@ -1820,18 +1820,6 @@ GCConfig::initialize(); -#if COMPILER2_OR_JVMCI - // Shared spaces work fine with other GCs but causes bytecode rewriting - // to be disabled, which hurts interpreter performance and decreases - // server performance. When -server is specified, keep the default off - // unless it is asked for. Future work: either add bytecode rewriting - // at link time, or rewrite bytecodes in non-shared methods. - if (is_server_compilation_mode_vm() && !DumpSharedSpaces && !RequireSharedSpaces && - (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { - no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on."); - } -#endif - #if defined(IA32) // Only server compiler can optimize safepoints well enough. if (!is_server_compilation_mode_vm()) { --- old/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java 2018-04-17 21:08:24.277968011 -0700 +++ new/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java 2018-04-17 21:08:24.037958729 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @requires vm.cds * @bug 8005933 - * @summary Test that -Xshare:auto uses CDS when explicitly specified with -server. + * @summary -Xshare:auto is the default when -Xshare is not specified * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -45,34 +45,30 @@ output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( - "-server", "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./XShareAuto.jsa", "-version"); - output = new OutputAnalyzer(pb.start()); - String outputString = output.getOutput(); - // We asked for server but it could be aliased to something else - if (outputString.contains("Server VM") && !outputString.contains("emulated-client")) { - // In server case we don't expect to see sharing flag - output.shouldNotContain("sharing"); - output.shouldHaveExitValue(0); - } - else { - System.out.println("Skipping test - no Server VM available"); - return; - } - pb = ProcessTools.createJavaProcessBuilder( - "-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xlog:cds", "-version"); - output = new OutputAnalyzer(pb.start()); - try { - output.shouldContain("sharing"); - } catch (RuntimeException e) { - // if sharing failed due to ASLR or similar reasons, - // check whether sharing was attempted at all (UseSharedSpaces) - output.shouldContain("UseSharedSpaces:"); - output.shouldNotContain("Unable to map %s"); + // We have 2 test cases: + String cases[] = { + "-Xshare:auto", // case [1]: -Xshare:auto is explicitly specified. + "-showversion" // case [2]: -Xshare:auto is not explicitly specified, + // but VM should still use it by default. + }; + + for (String x : cases) { + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./XShareAuto.jsa", + "-Xlog:cds", + x, + "-version"); + output = new OutputAnalyzer(pb.start()); + String outputString = output.getOutput(); + + if (!outputString.contains("Unable to map")) { + // sharing may not be enabled if XShareAuto.jsa cannot be mapped due to + // ASLR. + output.shouldContain("sharing"); + } + output.shouldHaveExitValue(0); } - output.shouldHaveExitValue(0); } } --- old/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java 2018-04-17 21:08:25.186003127 -0700 +++ new/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java 2018-04-17 21:08:24.705984564 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,8 @@ "-XX:SharedBaseAddress=8g", "-Xmx128m", "-Xlog:gc+metaspace=trace", + "-Xshare:off", + "-Xlog:cds=trace", "-XX:+VerifyBeforeGC", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Narrow klass base: 0x0000000000000000"); @@ -54,6 +56,8 @@ "-XX:CompressedClassSpaceSize=3g", "-Xmx128m", "-Xlog:gc+metaspace=trace", + "-Xshare:off", + "-Xlog:cds=trace", "-XX:+VerifyBeforeGC", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3"); @@ -66,6 +70,8 @@ "-Xmx30g", "-XX:-UseAOT", // AOT explicitly set klass shift to 3. "-Xlog:gc+metaspace=trace", + "-Xshare:off", + "-Xlog:cds=trace", "-XX:+VerifyBeforeGC", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Narrow klass base: 0x0000000000000000");