test/hotspot/jtreg/runtime/SharedArchiveFile/TestInterpreterMethodEntries.java
author iklam
Tue, 02 Oct 2018 14:32:33 -0700
changeset 51990 6003e034cdd8
parent 49008 d777541fceba
child 55350 1224b16c8ff4
permissions -rw-r--r--
8209946: [TESTBUG] CDS tests should use "@run driver" Reviewed-by: ccheung, jiangli, mseledtsov
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
/*
49008
d777541fceba 8191375: Add high-level jtreg VMProps to filter out CDS tests
iklam
parents: 48469
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
42580
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
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 46417
diff changeset
    24
/**
42580
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.
48469
7312ae4465d6 8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents: 47216
diff changeset
    29
 * @requires vm.cds
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    30
 * @library /test/lib
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    31
 * @modules java.base/jdk.internal.misc
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    32
 *          java.management
51990
6003e034cdd8 8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents: 49008
diff changeset
    33
 * @run driver TestInterpreterMethodEntries
42580
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
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    36
import java.lang.Math;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    37
import java.util.zip.CRC32;
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    38
import java.util.zip.CRC32C;
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    39
import jdk.test.lib.cds.CDSOptions;
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    40
import jdk.test.lib.cds.CDSTestUtils;
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    41
import jdk.test.lib.process.OutputAnalyzer;
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 class TestInterpreterMethodEntries {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    44
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    45
    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
    46
        if (args.length == 0) {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    47
          // 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
    48
          dumpAndUseSharedArchive("+", "-");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    49
          dumpAndUseSharedArchive("-", "+");
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    50
        } else {
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    51
          // Call intrinsified java.lang.Math::fma()
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    52
          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
    53
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    54
          byte[] buffer = new byte[256];
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    55
          // Call intrinsified java.util.zip.CRC32::update()
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    56
          CRC32 crc32 = new CRC32();
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    57
          crc32.update(buffer, 0, 256);
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    58
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    59
          // Call intrinsified java.util.zip.CRC32C::updateBytes(..)
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    60
          CRC32C crc32c = new CRC32C();
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    61
          crc32c.update(buffer, 0, 256);
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
    }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    64
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    65
    private static void dumpAndUseSharedArchive(String dump, String use) throws Exception {
46399
ba815aa3765d 8179064: TestInterpreterMethodEntries.java is missing -XX:+UnlockDiagnosticVMOptions
ehelin
parents: 46389
diff changeset
    66
        String unlock     = "-XX:+UnlockDiagnosticVMOptions";
ba815aa3765d 8179064: TestInterpreterMethodEntries.java is missing -XX:+UnlockDiagnosticVMOptions
ehelin
parents: 46389
diff changeset
    67
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    68
        String dumpFMA    = "-XX:" + dump + "UseFMA";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    69
        String dumpCRC32  = "-XX:" + dump + "UseCRC32Intrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    70
        String dumpCRC32C = "-XX:" + dump + "UseCRC32CIntrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    71
        String useFMA     = "-XX:" + use  + "UseFMA";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    72
        String useCRC32   = "-XX:" + use  + "UseCRC32Intrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    73
        String useCRC32C  = "-XX:" + use  + "UseCRC32CIntrinsics";
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    74
46399
ba815aa3765d 8179064: TestInterpreterMethodEntries.java is missing -XX:+UnlockDiagnosticVMOptions
ehelin
parents: 46389
diff changeset
    75
        CDSTestUtils.createArchiveAndCheck(unlock, dumpFMA, dumpCRC32, dumpCRC32C);
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    76
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    77
        CDSOptions opts = (new CDSOptions())
46399
ba815aa3765d 8179064: TestInterpreterMethodEntries.java is missing -XX:+UnlockDiagnosticVMOptions
ehelin
parents: 46389
diff changeset
    78
            .addPrefix(unlock, useFMA, useCRC32, useCRC32C, "-showversion")
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    79
            .addSuffix("TestInterpreterMethodEntries", "run")
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    80
            .setUseVersion(false);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 42580
diff changeset
    81
        CDSTestUtils.runWithArchiveAndCheck(opts);
42580
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    82
    }
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    83
}
56304dee97f3 8169711: CDS does not patch entry trampoline if intrinsic method is disabled
thartmann
parents:
diff changeset
    84