1 /* 2 * Copyright (c) 2016, 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 */ 23 24 /** 25 * @test InterpreterMethodEntries 26 * @requires vm.cds 27 * @bug 8169711 28 * @summary Test interpreter method entries for intrinsics with CDS (class data sharing) 29 * and different settings of the intrinsic flag during dump/use of the archive. 30 * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) 31 * @library /test/lib 32 * @modules java.base/jdk.internal.misc 33 * java.management 34 * @run main TestInterpreterMethodEntries 35 */ 36 37 import java.lang.Math; 38 import java.util.zip.CRC32; 39 import java.util.zip.CRC32C; 40 import jdk.test.lib.cds.CDSOptions; 41 import jdk.test.lib.cds.CDSTestUtils; 42 import jdk.test.lib.process.OutputAnalyzer; 43 44 public class TestInterpreterMethodEntries { 45 46 public static void main(String[] args) throws Exception { 47 if (args.length == 0) { 48 // Dump and use shared archive with different flag combinations 49 dumpAndUseSharedArchive("+", "-"); 50 dumpAndUseSharedArchive("-", "+"); 51 } else { 52 // Call intrinsified java.lang.Math::fma() 53 Math.fma(1.0, 2.0, 3.0); 54 55 byte[] buffer = new byte[256]; 56 // Call intrinsified java.util.zip.CRC32::update() 57 CRC32 crc32 = new CRC32(); 58 crc32.update(buffer, 0, 256); 59 60 // Call intrinsified java.util.zip.CRC32C::updateBytes(..) 61 CRC32C crc32c = new CRC32C(); 62 crc32c.update(buffer, 0, 256); 63 } 64 } 65 66 private static void dumpAndUseSharedArchive(String dump, String use) throws Exception { 67 String unlock = "-XX:+UnlockDiagnosticVMOptions"; 68 69 String dumpFMA = "-XX:" + dump + "UseFMA"; 70 String dumpCRC32 = "-XX:" + dump + "UseCRC32Intrinsics"; 71 String dumpCRC32C = "-XX:" + dump + "UseCRC32CIntrinsics"; 72 String useFMA = "-XX:" + use + "UseFMA"; 73 String useCRC32 = "-XX:" + use + "UseCRC32Intrinsics"; 74 String useCRC32C = "-XX:" + use + "UseCRC32CIntrinsics"; 75 76 CDSTestUtils.createArchiveAndCheck(unlock, dumpFMA, dumpCRC32, dumpCRC32C); 77 78 CDSOptions opts = (new CDSOptions()) 79 .addPrefix(unlock, useFMA, useCRC32, useCRC32C, "-showversion") 80 .addSuffix("TestInterpreterMethodEntries", "run") 81 .setUseVersion(false); 82 CDSTestUtils.runWithArchiveAndCheck(opts); 83 } 84 } 85