hotspot/test/compiler/aot/RecompilationTest.java
author kvn
Tue, 13 Dec 2016 17:58:19 -0800
changeset 42660 90e411b50d88
parent 42657 9e1850986b28
child 42662 ba98de0931bb
permissions -rw-r--r--
8171187: Expected compilation level after compilation to be no less than 1 Summary: prevent inlining of test method into other AOT methods Reviewed-by: iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     4
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     8
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    13
 * accompanied this code).
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    14
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    18
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    21
 * questions.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    22
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    23
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    24
/*
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    25
 * @test
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
 * @library /test/lib /testlibrary /
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
 * @requires vm.bits == "64" & os.arch == "amd64" & os.family == "linux"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
 * @modules java.base/jdk.internal.misc
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
 * @build compiler.aot.RecompilationTest
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    30
 *        compiler.aot.AotCompiler
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
 *     sun.hotspot.WhiteBox$WhiteBoxPermission
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    33
 * @run main compiler.aot.AotCompiler -libname libRecompilationTest1.so
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
 *     -class compiler.whitebox.SimpleTestCaseHelper
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
 *     -extraopt -Dgraal.TieredAOT=true -extraopt -Dgraal.ProfileSimpleMethods=true
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
 *     -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
42657
9e1850986b28 8171134: Unexpected output in compiler/aot/SharedUsageTest.java
kvn
parents: 42650
diff changeset
    37
 *     -extraopt -XX:-UseCompressedOops
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    38
 *     -extraopt -XX:CompileCommand=dontinline,compiler.whitebox.SimpleTestCaseHelper::method
42657
9e1850986b28 8171134: Unexpected output in compiler/aot/SharedUsageTest.java
kvn
parents: 42650
diff changeset
    39
 * @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:+TieredCompilation
9e1850986b28 8171134: Unexpected output in compiler/aot/SharedUsageTest.java
kvn
parents: 42650
diff changeset
    40
 *     -XX:-UseCounterDecay -XX:-UseCompressedOops
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    41
 *     -XX:-Inline
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    42
 *     -XX:AOTLibrary=./libRecompilationTest1.so -Xbootclasspath/a:.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
 *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    44
 *     -Dcompiler.aot.RecompilationTest.check_level=1
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
 *     compiler.aot.RecompilationTest
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    46
 * @run main compiler.aot.AotCompiler -libname libRecompilationTest2.so
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
 *     -class compiler.whitebox.SimpleTestCaseHelper
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
 *     -extraopt -Dgraal.TieredAOT=false
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
 *     -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    50
 *     -extraopt -XX:-UseCompressedOops
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    51
 *     -extraopt -XX:CompileCommand=dontinline,compiler.whitebox.SimpleTestCaseHelper::method
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    52
 * @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:+TieredCompilation
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    53
 *     -XX:-UseCounterDecay -XX:-UseCompressedOops
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    54
 *     -XX:-Inline
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    55
 *     -XX:AOTLibrary=./libRecompilationTest2.so -Xbootclasspath/a:.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
 *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
 *     -Dcompiler.aot.RecompilationTest.check_level=-1
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
 *     compiler.aot.RecompilationTest
42660
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    59
 * @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:-TieredCompilation
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    60
 *     -XX:-UseCounterDecay -XX:-UseCompressedOops
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    61
 *     -XX:-Inline
90e411b50d88 8171187: Expected compilation level after compilation to be no less than 1
kvn
parents: 42657
diff changeset
    62
 *     -XX:AOTLibrary=./libRecompilationTest2.so -Xbootclasspath/a:.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
 *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
 *     -Dcompiler.aot.RecompilationTest.check_level=-1
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
 *     compiler.aot.RecompilationTest
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
 * @summary check if recompilation after aot goes fine
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    68
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    69
 /* having whitebox-related options for aot compiler is a temporary solution,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    70
    because of JDK-8146201
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
package compiler.aot;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
import compiler.whitebox.CompilerWhiteBoxTest;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
import java.lang.reflect.Executable;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
import jdk.test.lib.Asserts;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
public final class RecompilationTest extends CompilerWhiteBoxTest {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
    private static final int CHECK_LEVEL = Integer.getInteger(
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
                "compiler.aot.RecompilationTest.check_level");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
    public static void main(String args[]) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
        CompilerWhiteBoxTest.main(RecompilationTest::new, args);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
    private RecompilationTest(TestCase testCase) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
        super(testCase);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
    @Override
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
    protected void test() throws Exception {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
        if (testCase.isOsr()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
            /* aot compiler is not using osr compilation */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
            System.out.println("Skipping OSR case");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
            return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
        Executable e = testCase.getExecutable();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
        Asserts.assertTrue(WHITE_BOX.isMethodCompiled(e),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
                testCase.name() +  ": an executable expected to be compiled");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
        Asserts.assertEQ(WHITE_BOX.getMethodCompilationLevel(e),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
                COMP_LEVEL_AOT,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
                String.format("%s: unexpected compilation level at start",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
                        testCase.name()));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
        compile();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
        Asserts.assertTrue(WHITE_BOX.isMethodCompiled(e), testCase.name()
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
                + ": method expected to be compiled");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
        /* a case with AOT'ed code checks exact compilation level equality
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
           while another case checks minimum level and if method compiled
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
           because there might be different compilation level transitions */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
        if (CHECK_LEVEL != COMP_LEVEL_AOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
            Asserts.assertGTE(WHITE_BOX.getMethodCompilationLevel(e),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
                CHECK_LEVEL,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
                String.format("%s: expected compilation level"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
                        + " after compilation to be no less than %d for %s",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
                        testCase.name(), CHECK_LEVEL, testCase.name()));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
        } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
            Asserts.assertEQ(WHITE_BOX.getMethodCompilationLevel(e),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
                COMP_LEVEL_AOT, String.format("%s: expected compilation"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
                        + " level after compilation to be equal to %d for %s",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
                        testCase.name(), COMP_LEVEL_AOT, testCase.name()));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   122
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
}