2017-11-16 11:58:20 +05:30
|
|
|
/*
|
2021-03-13 14:51:53 +00:00
|
|
|
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
2017-11-16 11:58:20 +05:30
|
|
|
* 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-07 17:38:34 -07:00
|
|
|
import sun.hotspot.code.Compiler;
|
|
|
|
|
2017-11-16 11:58:20 +05:30
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2019-02-05 00:43:38 +05:30
|
|
|
import java.util.Map;
|
|
|
|
import java.util.HashMap;
|
2017-11-16 11:58:20 +05:30
|
|
|
import jdk.test.lib.apps.LingeredApp;
|
2019-02-05 00:43:38 +05:30
|
|
|
import jtreg.SkippedException;
|
2019-03-27 10:38:49 +01:00
|
|
|
import sun.hotspot.gc.GC;
|
2017-11-16 11:58:20 +05:30
|
|
|
|
2018-06-25 23:04:21 +02:00
|
|
|
/**
|
2017-11-16 11:58:20 +05:30
|
|
|
* @test
|
|
|
|
* @summary Test the 'universe' command of jhsdb clhsdb.
|
2020-03-17 18:04:59 -07:00
|
|
|
* @requires vm.hasSA
|
2017-11-16 11:58:20 +05:30
|
|
|
* @bug 8190307
|
|
|
|
* @library /test/lib
|
|
|
|
* @build jdk.test.lib.apps.*
|
2018-06-07 17:38:34 -07:00
|
|
|
* @build sun.hotspot.WhiteBox
|
2021-03-13 14:51:53 +00:00
|
|
|
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
|
2019-03-27 10:38:49 +01:00
|
|
|
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestUniverse
|
2017-11-16 11:58:20 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
public class TestUniverse {
|
|
|
|
|
2019-03-27 10:38:49 +01:00
|
|
|
private static void testClhsdbForUniverse(long lingeredAppPid, GC gc) throws Exception {
|
2019-02-05 00:43:38 +05:30
|
|
|
ClhsdbLauncher launcher = new ClhsdbLauncher();
|
|
|
|
List<String> cmds = List.of("universe");
|
|
|
|
Map<String, List<String>> expStrMap = new HashMap<>();
|
|
|
|
List<String> expStrings = new ArrayList<String>();
|
|
|
|
expStrings.add("Heap Parameters");
|
2017-11-16 11:58:20 +05:30
|
|
|
|
2019-03-27 10:38:49 +01:00
|
|
|
switch (gc) {
|
|
|
|
case Serial:
|
2019-02-05 00:43:38 +05:30
|
|
|
expStrings.add("Gen 1: old");
|
2019-03-27 10:38:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Parallel:
|
2019-02-05 00:43:38 +05:30
|
|
|
expStrings.add("ParallelScavengeHeap");
|
|
|
|
expStrings.add("PSYoungGen");
|
|
|
|
expStrings.add("eden");
|
2019-03-27 10:38:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G1:
|
|
|
|
expStrings.add("garbage-first heap");
|
|
|
|
expStrings.add("region size");
|
|
|
|
expStrings.add("G1 Young Generation:");
|
|
|
|
expStrings.add("regions =");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Epsilon:
|
2019-02-05 00:43:38 +05:30
|
|
|
expStrings.add("Epsilon heap");
|
|
|
|
expStrings.add("reserved");
|
|
|
|
expStrings.add("committed");
|
|
|
|
expStrings.add("used");
|
2019-03-27 10:38:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Z:
|
|
|
|
expStrings.add("ZHeap");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Shenandoah:
|
2019-10-08 15:08:59 +02:00
|
|
|
expStrings.add("Shenandoah heap");
|
2019-03-27 10:38:49 +01:00
|
|
|
break;
|
2018-06-12 15:03:00 +02:00
|
|
|
}
|
2019-03-27 10:38:49 +01:00
|
|
|
|
2019-02-05 00:43:38 +05:30
|
|
|
expStrMap.put("universe", expStrings);
|
|
|
|
launcher.run(lingeredAppPid, cmds, expStrMap, null);
|
2017-11-16 11:58:20 +05:30
|
|
|
}
|
|
|
|
|
2019-03-27 10:38:49 +01:00
|
|
|
private static void test(GC gc) throws Exception {
|
2017-11-16 11:58:20 +05:30
|
|
|
LingeredApp app = null;
|
|
|
|
try {
|
2020-01-24 10:31:45 +01:00
|
|
|
app = LingeredApp.startApp("-XX:+UnlockExperimentalVMOptions", "-XX:+Use" + gc + "GC");
|
2019-03-27 10:38:49 +01:00
|
|
|
System.out.println ("Started LingeredApp with " + gc + "GC and pid " + app.getPid());
|
2017-11-16 11:58:20 +05:30
|
|
|
testClhsdbForUniverse(app.getPid(), gc);
|
|
|
|
} finally {
|
|
|
|
LingeredApp.stopApp(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-27 10:38:49 +01:00
|
|
|
private static boolean isSelectedAndSupported(GC gc) {
|
|
|
|
if (!gc.isSelected()) {
|
|
|
|
// Not selected
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Compiler.isGraalEnabled()) {
|
2019-11-13 11:37:29 +01:00
|
|
|
if (gc == GC.Epsilon || gc == GC.Z || gc == GC.Shenandoah) {
|
2019-03-27 10:38:49 +01:00
|
|
|
// Not supported
|
|
|
|
System.out.println ("Skipped testing of " + gc + "GC, not supported by Graal");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Selected and supported
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-16 11:58:20 +05:30
|
|
|
public static void main (String... args) throws Exception {
|
2019-03-27 10:38:49 +01:00
|
|
|
System.out.println("Starting TestUniverse");
|
2017-11-16 11:58:20 +05:30
|
|
|
try {
|
2019-03-27 10:38:49 +01:00
|
|
|
for (GC gc: GC.values()) {
|
|
|
|
if (isSelectedAndSupported(gc)) {
|
|
|
|
test(gc);
|
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 17:40:28 +02:00
|
|
|
}
|
2018-06-07 17:38:34 -07:00
|
|
|
}
|
2019-02-05 00:43:38 +05:30
|
|
|
} catch (SkippedException se) {
|
|
|
|
throw se;
|
2017-11-16 11:58:20 +05:30
|
|
|
} catch (Exception e) {
|
2019-02-05 00:43:38 +05:30
|
|
|
System.out.println(e.getMessage());
|
|
|
|
e.printStackTrace();
|
2017-11-16 11:58:20 +05:30
|
|
|
throw new Error("Test failed with " + e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|