Mon, 03 Jun 2019 16:14:54 +0100
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
Summary: Includes compile_id addition from JDK-8054492
Reviewed-by: andrew
xliu@9689 | 1 | /* |
xliu@9689 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
xliu@9689 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
xliu@9689 | 4 | * |
xliu@9689 | 5 | * This code is free software; you can redistribute it and/or modify it |
xliu@9689 | 6 | * under the terms of the GNU General Public License version 2 only, as |
xliu@9689 | 7 | * published by the Free Software Foundation. |
xliu@9689 | 8 | * |
xliu@9689 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
xliu@9689 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
xliu@9689 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
xliu@9689 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
xliu@9689 | 13 | * accompanied this code). |
xliu@9689 | 14 | * |
xliu@9689 | 15 | * You should have received a copy of the GNU General Public License version |
xliu@9689 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
xliu@9689 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
xliu@9689 | 18 | * |
xliu@9689 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
xliu@9689 | 20 | * or visit www.oracle.com if you need additional information or have any |
xliu@9689 | 21 | * questions. |
xliu@9689 | 22 | */ |
xliu@9689 | 23 | |
xliu@9689 | 24 | import java.lang.reflect.Executable; |
xliu@9689 | 25 | import java.util.concurrent.Callable; |
xliu@9689 | 26 | |
xliu@9689 | 27 | /** |
xliu@9689 | 28 | * @test ConstantGettersTransitionsTest |
xliu@9689 | 29 | * @library /testlibrary /testlibrary/whitebox /compiler/whitebox |
xliu@9689 | 30 | * @build TransitionsTestExecutor ConstantGettersTransitionsTest |
xliu@9689 | 31 | * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
xliu@9689 | 32 | * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
xliu@9689 | 33 | * -XX:+WhiteBoxAPI -XX:+TieredCompilation |
xliu@9689 | 34 | * -XX:CompileCommand=compileonly,ConstantGettersTestCase$TrivialMethods::* |
xliu@9689 | 35 | * TransitionsTestExecutor ConstantGettersTransitionsTest |
xliu@9689 | 36 | * @summary Test the correctness of compilation level transitions for constant getters methods |
xliu@9689 | 37 | */ |
xliu@9689 | 38 | public class ConstantGettersTransitionsTest extends LevelTransitionTest { |
xliu@9689 | 39 | public static void main(String[] args) { |
xliu@9689 | 40 | assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); |
xliu@9689 | 41 | |
xliu@9689 | 42 | // run test cases |
xliu@9689 | 43 | for (TestCase testCase : ConstantGettersTestCase.values()) { |
xliu@9689 | 44 | new ConstantGettersTransitionsTest(testCase).runTest(); |
xliu@9689 | 45 | } |
xliu@9689 | 46 | } |
xliu@9689 | 47 | |
xliu@9689 | 48 | @Override |
xliu@9689 | 49 | protected boolean isTrivial() { |
xliu@9689 | 50 | return true; |
xliu@9689 | 51 | } |
xliu@9689 | 52 | |
xliu@9689 | 53 | private ConstantGettersTransitionsTest(TestCase testCase) { |
xliu@9689 | 54 | super(testCase); |
xliu@9689 | 55 | } |
xliu@9689 | 56 | } |
xliu@9689 | 57 | |
xliu@9689 | 58 | enum ConstantGettersTestCase implements CompilerWhiteBoxTest.TestCase { |
xliu@9689 | 59 | ICONST_M1, |
xliu@9689 | 60 | ICONST_0, |
xliu@9689 | 61 | ICONST_1, |
xliu@9689 | 62 | ICONST_2, |
xliu@9689 | 63 | ICONST_3, |
xliu@9689 | 64 | ICONST_4, |
xliu@9689 | 65 | ICONST_5, |
xliu@9689 | 66 | LCONST_0, |
xliu@9689 | 67 | LCONST_1, |
xliu@9689 | 68 | FCONST_0, |
xliu@9689 | 69 | FCONST_1, |
xliu@9689 | 70 | FCONST_2, |
xliu@9689 | 71 | DCONST_0, |
xliu@9689 | 72 | DCONST_1, |
xliu@9689 | 73 | DCONST_W, |
xliu@9689 | 74 | BYTE, |
xliu@9689 | 75 | SHORT, |
xliu@9689 | 76 | CHAR; |
xliu@9689 | 77 | |
xliu@9689 | 78 | private final Executable executable; |
xliu@9689 | 79 | private final Callable<Integer> callable; |
xliu@9689 | 80 | |
xliu@9689 | 81 | @Override |
xliu@9689 | 82 | public Executable getExecutable() { |
xliu@9689 | 83 | return executable; |
xliu@9689 | 84 | } |
xliu@9689 | 85 | |
xliu@9689 | 86 | @Override |
xliu@9689 | 87 | public Callable<Integer> getCallable() { |
xliu@9689 | 88 | return callable; |
xliu@9689 | 89 | } |
xliu@9689 | 90 | |
xliu@9689 | 91 | @Override |
xliu@9689 | 92 | public boolean isOsr() { |
xliu@9689 | 93 | return false; |
xliu@9689 | 94 | } |
xliu@9689 | 95 | |
xliu@9689 | 96 | private ConstantGettersTestCase() { |
xliu@9689 | 97 | String name = "make" + this.name(); |
xliu@9689 | 98 | this.executable = LevelTransitionTest.Helper.getMethod(TrivialMethods.class, name); |
xliu@9689 | 99 | this.callable = LevelTransitionTest.Helper.getCallable(new TrivialMethods(), name); |
xliu@9689 | 100 | } |
xliu@9689 | 101 | |
xliu@9689 | 102 | /** |
xliu@9689 | 103 | * Contains methods that load constants with certain types of bytecodes |
xliu@9689 | 104 | * See JVMS 2.11.2. Load and Store Instructions |
xliu@9689 | 105 | * Note that it doesn't have a method for ldc_w instruction |
xliu@9689 | 106 | */ |
xliu@9689 | 107 | private static class TrivialMethods { |
xliu@9689 | 108 | public static int makeICONST_M1() { |
xliu@9689 | 109 | return -1; |
xliu@9689 | 110 | } |
xliu@9689 | 111 | |
xliu@9689 | 112 | public static int makeICONST_0() { |
xliu@9689 | 113 | return 0; |
xliu@9689 | 114 | } |
xliu@9689 | 115 | |
xliu@9689 | 116 | public static int makeICONST_1() { |
xliu@9689 | 117 | return 1; |
xliu@9689 | 118 | } |
xliu@9689 | 119 | |
xliu@9689 | 120 | public static int makeICONST_2() { |
xliu@9689 | 121 | return 2; |
xliu@9689 | 122 | } |
xliu@9689 | 123 | |
xliu@9689 | 124 | public static int makeICONST_3() { |
xliu@9689 | 125 | return 3; |
xliu@9689 | 126 | } |
xliu@9689 | 127 | |
xliu@9689 | 128 | public static int makeICONST_4() { |
xliu@9689 | 129 | return 4; |
xliu@9689 | 130 | } |
xliu@9689 | 131 | |
xliu@9689 | 132 | public static int makeICONST_5() { |
xliu@9689 | 133 | return 5; |
xliu@9689 | 134 | } |
xliu@9689 | 135 | |
xliu@9689 | 136 | public static long makeLCONST_0() { |
xliu@9689 | 137 | return 0L; |
xliu@9689 | 138 | } |
xliu@9689 | 139 | |
xliu@9689 | 140 | public static long makeLCONST_1() { |
xliu@9689 | 141 | return 1L; |
xliu@9689 | 142 | } |
xliu@9689 | 143 | |
xliu@9689 | 144 | public static float makeFCONST_0() { |
xliu@9689 | 145 | return 0F; |
xliu@9689 | 146 | } |
xliu@9689 | 147 | |
xliu@9689 | 148 | public static float makeFCONST_1() { |
xliu@9689 | 149 | return 1F; |
xliu@9689 | 150 | } |
xliu@9689 | 151 | |
xliu@9689 | 152 | public static float makeFCONST_2() { |
xliu@9689 | 153 | return 2F; |
xliu@9689 | 154 | } |
xliu@9689 | 155 | |
xliu@9689 | 156 | public static double makeDCONST_0() { |
xliu@9689 | 157 | return 0D; |
xliu@9689 | 158 | } |
xliu@9689 | 159 | |
xliu@9689 | 160 | public static double makeDCONST_1() { |
xliu@9689 | 161 | return 1D; |
xliu@9689 | 162 | } |
xliu@9689 | 163 | |
xliu@9689 | 164 | public static double makeDCONST_W() { |
xliu@9689 | 165 | // ldc2_w |
xliu@9689 | 166 | return Double.MAX_VALUE; |
xliu@9689 | 167 | } |
xliu@9689 | 168 | |
xliu@9689 | 169 | public static Object makeOBJECT() { |
xliu@9689 | 170 | // aconst_null |
xliu@9689 | 171 | return null; |
xliu@9689 | 172 | } |
xliu@9689 | 173 | |
xliu@9689 | 174 | public static byte makeBYTE() { |
xliu@9689 | 175 | // bipush |
xliu@9689 | 176 | return (byte) 0x7F; |
xliu@9689 | 177 | } |
xliu@9689 | 178 | |
xliu@9689 | 179 | public static short makeSHORT() { |
xliu@9689 | 180 | // sipush |
xliu@9689 | 181 | return (short) 0x7FFF; |
xliu@9689 | 182 | } |
xliu@9689 | 183 | |
xliu@9689 | 184 | public static char makeCHAR() { |
xliu@9689 | 185 | // ldc |
xliu@9689 | 186 | return (char) 0xFFFF; |
xliu@9689 | 187 | } |
xliu@9689 | 188 | |
xliu@9689 | 189 | public static boolean makeBOOLEAN() { |
xliu@9689 | 190 | return true; |
xliu@9689 | 191 | } |
xliu@9689 | 192 | } |
xliu@9689 | 193 | } |