Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java
32285 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 802492726* @summary Testing address of compressed class pointer space as best as possible.27* @library /testlibrary28*/2930import com.oracle.java.testlibrary.*;3132public class CompressedClassPointers {3334public static void smallHeapTest() throws Exception {35ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(36"-XX:+UnlockDiagnosticVMOptions",37"-XX:SharedBaseAddress=8g",38"-Xmx128m",39"-XX:+PrintCompressedOopsMode",40"-XX:+VerifyBeforeGC", "-version");41OutputAnalyzer output = new OutputAnalyzer(pb.start());42output.shouldContain("Narrow klass base: 0x0000000000000000");43output.shouldHaveExitValue(0);44}4546public static void smallHeapTestWith3G() throws Exception {47ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(48"-XX:+UnlockDiagnosticVMOptions",49"-XX:CompressedClassSpaceSize=3g",50"-Xmx128m",51"-XX:+PrintCompressedOopsMode",52"-XX:+VerifyBeforeGC", "-version");53OutputAnalyzer output = new OutputAnalyzer(pb.start());54output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");55output.shouldHaveExitValue(0);56}5758public static void largeHeapTest() throws Exception {59ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(60"-XX:+UnlockDiagnosticVMOptions",61"-Xmx30g",62"-XX:+PrintCompressedOopsMode",63"-XX:+VerifyBeforeGC", "-version");64OutputAnalyzer output = new OutputAnalyzer(pb.start());65output.shouldNotContain("Narrow klass base: 0x0000000000000000");66output.shouldContain("Narrow klass shift: 0");67output.shouldHaveExitValue(0);68}6970public static void largePagesTest() throws Exception {71ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(72"-XX:+UnlockDiagnosticVMOptions",73"-Xmx128m",74"-XX:+UseLargePages",75"-XX:+PrintCompressedOopsMode",76"-XX:+VerifyBeforeGC", "-version");77OutputAnalyzer output = new OutputAnalyzer(pb.start());78output.shouldContain("Narrow klass base:");79output.shouldHaveExitValue(0);80}8182public static void sharingTest() throws Exception {83// Test small heaps84ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(85"-XX:+UnlockDiagnosticVMOptions",86"-XX:SharedArchiveFile=./sample.jsa",87"-Xmx128m",88"-XX:SharedBaseAddress=8g",89"-XX:+PrintCompressedOopsMode",90"-XX:+VerifyBeforeGC",91"-Xshare:dump");92OutputAnalyzer output = new OutputAnalyzer(pb.start());93try {94output.shouldContain("Loading classes to share");95output.shouldHaveExitValue(0);9697pb = ProcessTools.createJavaProcessBuilder(98"-XX:+UnlockDiagnosticVMOptions",99"-XX:SharedArchiveFile=./sample.jsa",100"-Xmx128m",101"-XX:SharedBaseAddress=8g",102"-XX:+PrintCompressedOopsMode",103"-Xshare:on",104"-version");105output = new OutputAnalyzer(pb.start());106output.shouldContain("sharing");107output.shouldHaveExitValue(0);108109} catch (RuntimeException e) {110output.shouldContain("Unable to use shared archive");111output.shouldHaveExitValue(1);112}113}114115public static void main(String[] args) throws Exception {116if (!Platform.is64bit()) {117// Can't test this on 32 bit, just pass118System.out.println("Skipping test on 32bit");119return;120}121// Solaris 10 can't mmap compressed oops space without a base122if (Platform.isSolaris()) {123String name = System.getProperty("os.version");124if (name.equals("5.10")) {125System.out.println("Skipping test on Solaris 10");126return;127}128}129smallHeapTest();130smallHeapTestWith3G();131largeHeapTest();132largePagesTest();133sharingTest();134}135}136137138