rev 12887 : 8179064: TestInterpreterMethodEntries.java is missing -XX:+UnlockDiagnosticVMOptions

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