Skip to content

Commit cac6379

Browse files
committed
8188105: Make -Xshare:auto the default for server VM
Reviewed-by: dholmes, lfoltan, acorn, mseledtsov, jiangli
1 parent 2329ce7 commit cac6379

3 files changed

Lines changed: 32 additions & 42 deletions

File tree

src/hotspot/share/runtime/arguments.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,18 +1820,6 @@ jint Arguments::set_ergonomics_flags() {
18201820

18211821
GCConfig::initialize();
18221822

1823-
#if COMPILER2_OR_JVMCI
1824-
// Shared spaces work fine with other GCs but causes bytecode rewriting
1825-
// to be disabled, which hurts interpreter performance and decreases
1826-
// server performance. When -server is specified, keep the default off
1827-
// unless it is asked for. Future work: either add bytecode rewriting
1828-
// at link time, or rewrite bytecodes in non-shared methods.
1829-
if (is_server_compilation_mode_vm() && !DumpSharedSpaces && !RequireSharedSpaces &&
1830-
(FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1831-
no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1832-
}
1833-
#endif
1834-
18351823
#if defined(IA32)
18361824
// Only server compiler can optimize safepoints well enough.
18371825
if (!is_server_compilation_mode_vm()) {

test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
2525
* @test
2626
* @requires vm.cds
2727
* @bug 8005933
28-
* @summary Test that -Xshare:auto uses CDS when explicitly specified with -server.
28+
* @summary -Xshare:auto is the default when -Xshare is not specified
2929
* @library /test/lib
3030
* @modules java.base/jdk.internal.misc
3131
* java.management
@@ -45,34 +45,30 @@ public static void main(String[] args) throws Exception {
4545
output.shouldContain("Loading classes to share");
4646
output.shouldHaveExitValue(0);
4747

48-
pb = ProcessTools.createJavaProcessBuilder(
49-
"-server", "-XX:+UnlockDiagnosticVMOptions",
50-
"-XX:SharedArchiveFile=./XShareAuto.jsa", "-version");
51-
output = new OutputAnalyzer(pb.start());
52-
String outputString = output.getOutput();
53-
// We asked for server but it could be aliased to something else
54-
if (outputString.contains("Server VM") && !outputString.contains("emulated-client")) {
55-
// In server case we don't expect to see sharing flag
56-
output.shouldNotContain("sharing");
57-
output.shouldHaveExitValue(0);
58-
}
59-
else {
60-
System.out.println("Skipping test - no Server VM available");
61-
return;
62-
}
6348

64-
pb = ProcessTools.createJavaProcessBuilder(
65-
"-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions",
66-
"-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xlog:cds", "-version");
67-
output = new OutputAnalyzer(pb.start());
68-
try {
69-
output.shouldContain("sharing");
70-
} catch (RuntimeException e) {
71-
// if sharing failed due to ASLR or similar reasons,
72-
// check whether sharing was attempted at all (UseSharedSpaces)
73-
output.shouldContain("UseSharedSpaces:");
74-
output.shouldNotContain("Unable to map %s");
49+
// We have 2 test cases:
50+
String cases[] = {
51+
"-Xshare:auto", // case [1]: -Xshare:auto is explicitly specified.
52+
"-showversion" // case [2]: -Xshare:auto is not explicitly specified,
53+
// but VM should still use it by default.
54+
};
55+
56+
for (String x : cases) {
57+
pb = ProcessTools.createJavaProcessBuilder(
58+
"-XX:+UnlockDiagnosticVMOptions",
59+
"-XX:SharedArchiveFile=./XShareAuto.jsa",
60+
"-Xlog:cds",
61+
x,
62+
"-version");
63+
output = new OutputAnalyzer(pb.start());
64+
String outputString = output.getOutput();
65+
66+
if (!outputString.contains("Unable to map")) {
67+
// sharing may not be enabled if XShareAuto.jsa cannot be mapped due to
68+
// ASLR.
69+
output.shouldContain("sharing");
70+
}
71+
output.shouldHaveExitValue(0);
7572
}
76-
output.shouldHaveExitValue(0);
7773
}
7874
}

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@ public static void smallHeapTest() throws Exception {
4242
"-XX:SharedBaseAddress=8g",
4343
"-Xmx128m",
4444
"-Xlog:gc+metaspace=trace",
45+
"-Xshare:off",
46+
"-Xlog:cds=trace",
4547
"-XX:+VerifyBeforeGC", "-version");
4648
OutputAnalyzer output = new OutputAnalyzer(pb.start());
4749
output.shouldContain("Narrow klass base: 0x0000000000000000");
@@ -54,6 +56,8 @@ public static void smallHeapTestWith3G() throws Exception {
5456
"-XX:CompressedClassSpaceSize=3g",
5557
"-Xmx128m",
5658
"-Xlog:gc+metaspace=trace",
59+
"-Xshare:off",
60+
"-Xlog:cds=trace",
5761
"-XX:+VerifyBeforeGC", "-version");
5862
OutputAnalyzer output = new OutputAnalyzer(pb.start());
5963
output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
@@ -66,6 +70,8 @@ public static void largeHeapTest() throws Exception {
6670
"-Xmx30g",
6771
"-XX:-UseAOT", // AOT explicitly set klass shift to 3.
6872
"-Xlog:gc+metaspace=trace",
73+
"-Xshare:off",
74+
"-Xlog:cds=trace",
6975
"-XX:+VerifyBeforeGC", "-version");
7076
OutputAnalyzer output = new OutputAnalyzer(pb.start());
7177
output.shouldNotContain("Narrow klass base: 0x0000000000000000");

0 commit comments

Comments
 (0)