< prev index next >

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

Print this page
   1 /*
   2  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  25  * @test
  26  * @bug 8024927
  27  * @summary Testing address of compressed class pointer space as best as possible.
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  */
  32 
  33 import jdk.test.lib.Platform;
  34 import jdk.test.lib.process.ProcessTools;
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 
  37 public class CompressedClassPointers {
  38 
  39     public static void smallHeapTest() throws Exception {
  40         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  41             "-XX:+UnlockDiagnosticVMOptions",
  42             "-XX:SharedBaseAddress=8g",
  43             "-Xmx128m",
  44             "-Xlog:gc+metaspace=trace",


  45             "-XX:+VerifyBeforeGC", "-version");
  46         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  47         output.shouldContain("Narrow klass base: 0x0000000000000000");
  48         output.shouldHaveExitValue(0);
  49     }
  50 
  51     public static void smallHeapTestWith3G() throws Exception {
  52         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  53             "-XX:+UnlockDiagnosticVMOptions",
  54             "-XX:CompressedClassSpaceSize=3g",
  55             "-Xmx128m",
  56             "-Xlog:gc+metaspace=trace",


  57             "-XX:+VerifyBeforeGC", "-version");
  58         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  59         output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
  60         output.shouldHaveExitValue(0);
  61     }
  62 
  63     public static void largeHeapTest() throws Exception {
  64         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  65             "-XX:+UnlockDiagnosticVMOptions",
  66             "-Xmx30g",
  67             "-XX:-UseAOT", // AOT explicitly set klass shift to 3.
  68             "-Xlog:gc+metaspace=trace",


  69             "-XX:+VerifyBeforeGC", "-version");
  70         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  71         output.shouldNotContain("Narrow klass base: 0x0000000000000000");
  72         output.shouldContain("Narrow klass shift: 0");
  73         output.shouldHaveExitValue(0);
  74     }
  75 
  76     public static void largePagesTest() throws Exception {
  77         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  78             "-XX:+UnlockDiagnosticVMOptions",
  79             "-Xmx128m",
  80             "-XX:+UseLargePages",
  81             "-Xlog:gc+metaspace=trace",
  82             "-XX:+VerifyBeforeGC", "-version");
  83         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  84         output.shouldContain("Narrow klass base:");
  85         output.shouldHaveExitValue(0);
  86     }
  87 
  88     public static void heapBaseMinAddressTest() throws Exception {


   1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  25  * @test
  26  * @bug 8024927
  27  * @summary Testing address of compressed class pointer space as best as possible.
  28  * @library /test/lib
  29  * @modules java.base/jdk.internal.misc
  30  *          java.management
  31  */
  32 
  33 import jdk.test.lib.Platform;
  34 import jdk.test.lib.process.ProcessTools;
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 
  37 public class CompressedClassPointers {
  38 
  39     public static void smallHeapTest() throws Exception {
  40         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  41             "-XX:+UnlockDiagnosticVMOptions",
  42             "-XX:SharedBaseAddress=8g",
  43             "-Xmx128m",
  44             "-Xlog:gc+metaspace=trace",
  45             "-Xshare:off",
  46             "-Xlog:cds=trace",
  47             "-XX:+VerifyBeforeGC", "-version");
  48         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  49         output.shouldContain("Narrow klass base: 0x0000000000000000");
  50         output.shouldHaveExitValue(0);
  51     }
  52 
  53     public static void smallHeapTestWith3G() throws Exception {
  54         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  55             "-XX:+UnlockDiagnosticVMOptions",
  56             "-XX:CompressedClassSpaceSize=3g",
  57             "-Xmx128m",
  58             "-Xlog:gc+metaspace=trace",
  59             "-Xshare:off",
  60             "-Xlog:cds=trace",
  61             "-XX:+VerifyBeforeGC", "-version");
  62         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  63         output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
  64         output.shouldHaveExitValue(0);
  65     }
  66 
  67     public static void largeHeapTest() throws Exception {
  68         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  69             "-XX:+UnlockDiagnosticVMOptions",
  70             "-Xmx30g",
  71             "-XX:-UseAOT", // AOT explicitly set klass shift to 3.
  72             "-Xlog:gc+metaspace=trace",
  73             "-Xshare:off",
  74             "-Xlog:cds=trace",
  75             "-XX:+VerifyBeforeGC", "-version");
  76         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  77         output.shouldNotContain("Narrow klass base: 0x0000000000000000");
  78         output.shouldContain("Narrow klass shift: 0");
  79         output.shouldHaveExitValue(0);
  80     }
  81 
  82     public static void largePagesTest() throws Exception {
  83         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  84             "-XX:+UnlockDiagnosticVMOptions",
  85             "-Xmx128m",
  86             "-XX:+UseLargePages",
  87             "-Xlog:gc+metaspace=trace",
  88             "-XX:+VerifyBeforeGC", "-version");
  89         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  90         output.shouldContain("Narrow klass base:");
  91         output.shouldHaveExitValue(0);
  92     }
  93 
  94     public static void heapBaseMinAddressTest() throws Exception {


< prev index next >