hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java
author thartmann
Fri, 12 Dec 2014 09:37:38 +0100
changeset 28190 5a6b07edeb21
parent 25958 8dc85547d6d6
child 28498 c90265622ab7
permissions -rw-r--r--
8066433: Move Whitebox test library to top level repository Summary: Moved Whitebox test library to top level repository. Reviewed-by: iignatyev, sla, mr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24006
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     1
/*
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     4
 *
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     8
 *
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    14
 *
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    18
 *
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    21
 * questions.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    22
 *
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    23
 */
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    24
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    25
/**
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    26
 * @test
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    27
 * @bug 8031320
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    28
 * @summary Verify that rtm locking statistics contain proper information
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    29
 *          on overall aborts and locks count and count of aborts of
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    30
 *          different types. Test also verify that VM output does not
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    31
 *          contain rtm locking statistics when it should not.
28190
5a6b07edeb21 8066433: Move Whitebox test library to top level repository
thartmann
parents: 25958
diff changeset
    32
 * @library /testlibrary /../../test/lib /compiler/testlibrary
24006
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    33
 * @build TestPrintPreciseRTMLockingStatistics
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    34
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
25958
8dc85547d6d6 8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents: 24006
diff changeset
    35
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
24006
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    36
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    37
 *                   -XX:+WhiteBoxAPI TestPrintPreciseRTMLockingStatistics
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    38
 */
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    39
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    40
import java.util.*;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    41
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    42
import com.oracle.java.testlibrary.*;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    43
import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    44
import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    45
import rtm.*;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    46
import rtm.predicate.SupportedCPU;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    47
import rtm.predicate.SupportedVM;
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    48
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    49
/**
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    50
 * Test verifies that VM output does not contain RTM locking statistics when it
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    51
 * should not (when PrintPreciseRTMLockingStatistics is off) and that with
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    52
 * -XX:+PrintPreciseRTMLockingStatistics locking statistics contains sane
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    53
 * total locks and aborts count as well as for specific abort types.
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    54
 */
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    55
public class TestPrintPreciseRTMLockingStatistics
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    56
        extends CommandLineOptionTest {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    57
    private TestPrintPreciseRTMLockingStatistics() {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    58
        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    59
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    60
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    61
    @Override
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    62
    public void runTestCases() throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    63
        verifyNoStatistics();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    64
        verifyStatistics();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    65
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    66
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    67
    // verify that VM output does not contain
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    68
    // rtm locking statistics
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    69
    private void verifyNoStatistics() throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    70
        verifyNoStatistics(AbortType.XABORT);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    71
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    72
        verifyNoStatistics(AbortType.XABORT,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    73
                "-XX:-PrintPreciseRTMLockingStatistics");
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    74
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    75
        verifyNoStatistics(AbortType.XABORT, "-XX:-UseRTMLocking",
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    76
                "-XX:+PrintPreciseRTMLockingStatistics");
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    77
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    78
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    79
    // verify that rtm locking statistics contain information
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    80
    // about each type of aborts
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    81
    private void verifyStatistics() throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    82
        verifyAbortsCount(AbortType.XABORT);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    83
        verifyAbortsCount(AbortType.MEM_CONFLICT);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    84
        verifyAbortsCount(AbortType.BUF_OVERFLOW);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    85
        verifyAbortsCount(AbortType.NESTED_ABORT);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    86
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    87
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    88
    private void verifyNoStatistics(AbortType abortProvokerType,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    89
            String... vmOpts) throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    90
        AbortProvoker provoker = abortProvokerType.provoker();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    91
        List<String> finalVMOpts = new LinkedList<>();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    92
        Collections.addAll(finalVMOpts, vmOpts);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    93
        Collections.addAll(finalVMOpts, AbortProvoker.class.getName(),
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    94
                abortProvokerType.toString());
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    95
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    96
        OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(provoker,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    97
                finalVMOpts.toArray(new String[finalVMOpts.size()]));
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    98
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
    99
        outputAnalyzer.shouldHaveExitValue(0);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   100
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   101
        List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   102
                outputAnalyzer.getOutput());
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   103
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   104
        Asserts.assertEQ(statistics.size(), 0, "VM output should not contain "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   105
                + "any RTM locking statistics");
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   106
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   107
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   108
    private void verifyAbortsCount(AbortType abortType) throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   109
        AbortProvoker provoker = abortType.provoker();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   110
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   111
        OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   112
                provoker,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   113
                "-XX:+PrintPreciseRTMLockingStatistics",
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   114
                AbortProvoker.class.getName(),
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   115
                abortType.toString());
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   116
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   117
        outputAnalyzer.shouldHaveExitValue(0);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   118
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   119
        List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   120
                provoker.getMethodWithLockName(),outputAnalyzer.getOutput());
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   121
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   122
        Asserts.assertGT(statistics.size(), 0, "VM output should contain one "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   123
                + "rtm locking statistics entry for method "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   124
                + provoker.getMethodWithLockName());
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   125
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   126
        RTMLockingStatistics lock = statistics.get(0);
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   127
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   128
        Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM locking statistics "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   129
                + "should contain non zero total locks count");
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   130
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   131
        Asserts.assertGT(lock.getTotalAborts(), 0L,
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   132
                "RTM locking statistics should contain non zero total aborts "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   133
                + "count");
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   134
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   135
        Asserts.assertGT(lock.getAborts(abortType), 0L, String.format(
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   136
                "RTM locking statistics should contain non zero aborts count "
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   137
                + "for abort reason %s", abortType));
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   138
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   139
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   140
    public static void main(String args[]) throws Throwable {
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   141
        new TestPrintPreciseRTMLockingStatistics().test();
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   142
    }
54399106938f 8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff changeset
   143
}