test/runtime/CompressedOops/CompressedClassPointers.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2013, 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  */
    24 /*
    25  * @test
    26  * @bug 8024927
    27  * @summary Testing address of compressed class pointer space as best as possible.
    28  * @library /testlibrary
    29  */
    31 import com.oracle.java.testlibrary.*;
    33 public class CompressedClassPointers {
    35     public static void smallHeapTest() throws Exception {
    36         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    37             "-XX:+UnlockDiagnosticVMOptions",
    38             "-XX:SharedBaseAddress=8g",
    39             "-Xmx128m",
    40             "-XX:+PrintCompressedOopsMode",
    41             "-XX:+VerifyBeforeGC", "-version");
    42         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    43         output.shouldContain("Narrow klass base: 0x0000000000000000");
    44         output.shouldHaveExitValue(0);
    45     }
    47     public static void smallHeapTestWith3G() throws Exception {
    48         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    49             "-XX:+UnlockDiagnosticVMOptions",
    50             "-XX:CompressedClassSpaceSize=3g",
    51             "-Xmx128m",
    52             "-XX:+PrintCompressedOopsMode",
    53             "-XX:+VerifyBeforeGC", "-version");
    54         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    55         output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
    56         output.shouldHaveExitValue(0);
    57     }
    59     public static void largeHeapTest() throws Exception {
    60         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    61             "-XX:+UnlockDiagnosticVMOptions",
    62             "-Xmx30g",
    63             "-XX:+PrintCompressedOopsMode",
    64             "-XX:+VerifyBeforeGC", "-version");
    65         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    66         output.shouldNotContain("Narrow klass base: 0x0000000000000000");
    67         output.shouldContain("Narrow klass shift: 0");
    68         output.shouldHaveExitValue(0);
    69     }
    71     public static void largePagesTest() throws Exception {
    72         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    73             "-XX:+UnlockDiagnosticVMOptions",
    74             "-Xmx128m",
    75             "-XX:+UseLargePages",
    76             "-XX:+PrintCompressedOopsMode",
    77             "-XX:+VerifyBeforeGC", "-version");
    78         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    79         output.shouldContain("Narrow klass base:");
    80         output.shouldHaveExitValue(0);
    81     }
    83     public static void sharingTest() throws Exception {
    84         // Test small heaps
    85         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    86             "-XX:+UnlockDiagnosticVMOptions",
    87             "-XX:SharedArchiveFile=./sample.jsa",
    88             "-Xmx128m",
    89             "-XX:SharedBaseAddress=8g",
    90             "-XX:+PrintCompressedOopsMode",
    91             "-XX:+VerifyBeforeGC",
    92             "-Xshare:dump");
    93         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    94         try {
    95           output.shouldContain("Loading classes to share");
    96           output.shouldHaveExitValue(0);
    98           pb = ProcessTools.createJavaProcessBuilder(
    99             "-XX:+UnlockDiagnosticVMOptions",
   100             "-XX:SharedArchiveFile=./sample.jsa",
   101             "-Xmx128m",
   102             "-XX:SharedBaseAddress=8g",
   103             "-XX:+PrintCompressedOopsMode",
   104             "-Xshare:on",
   105             "-version");
   106           output = new OutputAnalyzer(pb.start());
   107           output.shouldContain("sharing");
   108           output.shouldHaveExitValue(0);
   110         } catch (RuntimeException e) {
   111           output.shouldContain("Unable to use shared archive");
   112           output.shouldHaveExitValue(1);
   113         }
   114     }
   116   public static void main(String[] args) throws Exception {
   117       if (!Platform.is64bit()) {
   118           // Can't test this on 32 bit, just pass
   119           System.out.println("Skipping test on 32bit");
   120           return;
   121       }
   122       // Solaris 10 can't mmap compressed oops space without a base
   123       if (Platform.isSolaris()) {
   124            String name = System.getProperty("os.version");
   125            if (name.equals("5.10")) {
   126                System.out.println("Skipping test on Solaris 10");
   127                return;
   128            }
   129       }
   130       smallHeapTest();
   131       smallHeapTestWith3G();
   132       largeHeapTest();
   133       largePagesTest();
   134       sharingTest();
   135   }
   136 }

mercurial