hotspot/test/runtime/SharedArchiveFile/TestInterpreterMethodEntries.java
author rriggs
Wed, 12 Apr 2017 11:43:49 -0400
changeset 44633 d2f5e8921045
parent 42580 56304dee97f3
child 46389 d55896236dfd
permissions -rw-r--r--
8178347: Process and ProcessHandle getPid method name inconsistency Reviewed-by: hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     1
/*
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     4
 *
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     8
 *
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    13
 * accompanied this code).
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    14
 *
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    18
 *
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    21
 * questions.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    22
 */
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    23
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    24
/*
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    25
 * @test InterpreterMethodEntries
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    26
 * @bug 8169711
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    27
 * @summary Test interpreter method entries for intrinsics with CDS (class data sharing)
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    28
 *          and different settings of the intrinsic flag during dump/use of the archive.
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    29
 * @library /test/lib
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    31
 *          java.management
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    32
 * @run main TestInterpreterMethodEntries
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    33
 */
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    34
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    35
import java.lang.Math;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    36
import java.util.zip.CRC32;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    37
import java.util.zip.CRC32C;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    38
import jdk.test.lib.process.ProcessTools;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    40
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    41
public class TestInterpreterMethodEntries {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    42
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    44
        if (args.length == 0) {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    45
          // Dump and use shared archive with different flag combinations
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    46
          dumpAndUseSharedArchive("+", "-");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    47
          dumpAndUseSharedArchive("-", "+");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    48
        } else {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    49
          // Call intrinsified java.lang.Math::fma()
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    50
          Math.fma(1.0, 2.0, 3.0);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    51
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    52
          byte[] buffer = new byte[256];
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    53
          // Call intrinsified java.util.zip.CRC32::update()
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    54
          CRC32 crc32 = new CRC32();
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    55
          crc32.update(buffer, 0, 256);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    56
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    57
          // Call intrinsified java.util.zip.CRC32C::updateBytes(..)
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    58
          CRC32C crc32c = new CRC32C();
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    59
          crc32c.update(buffer, 0, 256);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    60
        }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    61
    }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    62
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    63
    private static void dumpAndUseSharedArchive(String dump, String use) throws Exception {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    64
        String dumpFMA    = "-XX:" + dump + "UseFMA";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    65
        String dumpCRC32  = "-XX:" + dump + "UseCRC32Intrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    66
        String dumpCRC32C = "-XX:" + dump + "UseCRC32CIntrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    67
        String useFMA     = "-XX:" + use  + "UseFMA";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    68
        String useCRC32   = "-XX:" + use  + "UseCRC32Intrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    69
        String useCRC32C  = "-XX:" + use  + "UseCRC32CIntrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    70
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    71
        // Dump shared archive
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    72
        String filename = "./TestInterpreterMethodEntries" + dump + ".jsa";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    73
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    74
            "-XX:+UnlockDiagnosticVMOptions",
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    75
            "-XX:SharedArchiveFile=" + filename,
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    76
            "-Xshare:dump",
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    77
            dumpFMA, dumpCRC32, dumpCRC32C);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    78
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    79
        CDSTestUtils.checkDump(output);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    80
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    81
        // Use shared archive
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    82
        pb = ProcessTools.createJavaProcessBuilder(
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    83
            "-XX:+UnlockDiagnosticVMOptions",
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    84
            "-XX:SharedArchiveFile=" + filename,
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    85
            "-Xshare:on",
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    86
            useFMA, useCRC32, useCRC32C,
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    87
            "TestInterpreterMethodEntries", "run");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    88
        output = new OutputAnalyzer(pb.start());
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    89
        if (CDSTestUtils.isUnableToMap(output)) {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    90
          System.out.println("Unable to map shared archive: test did not complete; assumed PASS");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    91
          return;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    92
        }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    93
        output.shouldHaveExitValue(0);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    94
    }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    95
}
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    96