2017-11-16 06:28:20 +00:00
|
|
|
/*
|
2018-03-20 05:54:32 +00:00
|
|
|
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
2017-11-16 06:28:20 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
2018-06-08 00:38:34 +00:00
|
|
|
import sun.hotspot.code.Compiler;
|
|
|
|
|
2017-11-16 06:28:20 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import jdk.test.lib.apps.LingeredApp;
|
|
|
|
import jdk.test.lib.JDKToolLauncher;
|
|
|
|
import jdk.test.lib.Platform;
|
|
|
|
import jdk.test.lib.process.OutputAnalyzer;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @summary Test the 'universe' command of jhsdb clhsdb.
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 15:40:28 +00:00
|
|
|
* @requires vm.gc != "Z"
|
2017-11-16 06:28:20 +00:00
|
|
|
* @bug 8190307
|
|
|
|
* @library /test/lib
|
|
|
|
* @build jdk.test.lib.apps.*
|
2018-06-08 00:38:34 +00:00
|
|
|
* @build sun.hotspot.WhiteBox
|
|
|
|
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 15:40:28 +00:00
|
|
|
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse withoutZ
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @summary Test the 'universe' command of jhsdb clhsdb.
|
|
|
|
* @requires vm.gc == "Z"
|
|
|
|
* @bug 8190307
|
|
|
|
* @library /test/lib
|
|
|
|
* @build jdk.test.lib.apps.*
|
|
|
|
* @build sun.hotspot.WhiteBox
|
|
|
|
* @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
|
|
|
|
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse withZ
|
2017-11-16 06:28:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
public class TestUniverse {
|
|
|
|
|
|
|
|
private static void testClhsdbForUniverse(long lingeredAppPid,
|
|
|
|
String gc) throws Exception {
|
|
|
|
|
|
|
|
Process p;
|
|
|
|
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
|
|
|
|
launcher.addToolArg("clhsdb");
|
|
|
|
launcher.addToolArg("--pid");
|
|
|
|
launcher.addToolArg(Long.toString(lingeredAppPid));
|
|
|
|
|
|
|
|
ProcessBuilder pb = new ProcessBuilder();
|
|
|
|
pb.command(launcher.getCommand());
|
|
|
|
System.out.println(
|
|
|
|
pb.command().stream().collect(Collectors.joining(" ")));
|
|
|
|
|
|
|
|
try {
|
|
|
|
p = pb.start();
|
|
|
|
} catch (Exception attachE) {
|
|
|
|
throw new Error("Couldn't start jhsdb or attach to LingeredApp : " + attachE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Issue the 'universe' command at the clhsdb prompt.
|
|
|
|
OutputStream input = p.getOutputStream();
|
|
|
|
try {
|
|
|
|
input.write("universe\n".getBytes());
|
|
|
|
input.write("quit\n".getBytes());
|
|
|
|
input.flush();
|
|
|
|
} catch (IOException ioe) {
|
|
|
|
throw new Error("Problem issuing the 'universe' command ", ioe);
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(p);
|
|
|
|
|
|
|
|
try {
|
|
|
|
p.waitFor();
|
|
|
|
} catch (InterruptedException ie) {
|
|
|
|
p.destroyForcibly();
|
|
|
|
throw new Error("Problem awaiting the child process: " + ie, ie);
|
|
|
|
}
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 15:40:28 +00:00
|
|
|
if (gc.contains("UseZGC")) {
|
|
|
|
output.shouldContain("ZHeap");
|
|
|
|
}
|
2017-11-16 06:28:20 +00:00
|
|
|
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
System.out.println(output.getOutput());
|
|
|
|
|
|
|
|
output.shouldContain("Heap Parameters");
|
|
|
|
if (gc.contains("G1GC")) {
|
|
|
|
output.shouldContain("garbage-first heap");
|
2018-03-20 05:54:32 +00:00
|
|
|
output.shouldContain("region size");
|
|
|
|
output.shouldContain("G1 Young Generation:");
|
|
|
|
output.shouldContain("regions =");
|
2017-11-16 06:28:20 +00:00
|
|
|
}
|
|
|
|
if (gc.contains("UseConcMarkSweepGC")) {
|
|
|
|
output.shouldContain("Gen 1: concurrent mark-sweep generation");
|
|
|
|
}
|
|
|
|
if (gc.contains("UseSerialGC")) {
|
|
|
|
output.shouldContain("Gen 1: old");
|
|
|
|
}
|
|
|
|
if (gc.contains("UseParallelGC")) {
|
|
|
|
output.shouldContain("ParallelScavengeHeap");
|
|
|
|
output.shouldContain("PSYoungGen");
|
|
|
|
output.shouldContain("eden");
|
|
|
|
}
|
2018-06-12 13:03:00 +00:00
|
|
|
if (gc.contains("UseEpsilonGC")) {
|
|
|
|
output.shouldContain("Epsilon heap");
|
|
|
|
output.shouldContain("reserved");
|
|
|
|
output.shouldContain("committed");
|
|
|
|
output.shouldContain("used");
|
|
|
|
}
|
2017-11-16 06:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void test(String gc) throws Exception {
|
|
|
|
LingeredApp app = null;
|
|
|
|
try {
|
|
|
|
List<String> vmArgs = new ArrayList<String>();
|
2018-06-12 13:03:00 +00:00
|
|
|
vmArgs.add("-XX:+UnlockExperimentalVMOptions"); // unlock experimental GCs
|
2017-11-16 06:28:20 +00:00
|
|
|
vmArgs.add(gc);
|
|
|
|
app = LingeredApp.startApp(vmArgs);
|
|
|
|
System.out.println ("Started LingeredApp with the GC option " + gc +
|
|
|
|
" and pid " + app.getPid());
|
|
|
|
testClhsdbForUniverse(app.getPid(), gc);
|
|
|
|
} finally {
|
|
|
|
LingeredApp.stopApp(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main (String... args) throws Exception {
|
|
|
|
|
|
|
|
if (!Platform.shouldSAAttach()) {
|
|
|
|
System.out.println(
|
|
|
|
"SA attach not expected to work - test skipped.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
test("-XX:+UseG1GC");
|
|
|
|
test("-XX:+UseParallelGC");
|
|
|
|
test("-XX:+UseSerialGC");
|
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 15:40:28 +00:00
|
|
|
if (!Compiler.isGraalEnabled()) { // Graal does not support all GCs
|
|
|
|
test("-XX:+UseConcMarkSweepGC");
|
|
|
|
if (args[0].equals("withZ")) {
|
|
|
|
test("-XX:+UseZGC");
|
|
|
|
}
|
2018-06-15 16:16:48 +00:00
|
|
|
test("-XX:+UseEpsilonGC");
|
2018-06-08 00:38:34 +00:00
|
|
|
}
|
2017-11-16 06:28:20 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
throw new Error("Test failed with " + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|