27 import jdk.test.lib.Asserts; 28 29 /* 30 * @test 31 * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa. 32 * @library /testlibrary /test/lib /compiler/whitebox / 33 * @requires os.simpleArch == "x64" 34 * @compile TestCallingConventionC1.java 35 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform 36 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions 37 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI 38 * compiler.valhalla.valuetypes.ValueTypeTest 39 * compiler.valhalla.valuetypes.TestCallingConventionC1 40 */ 41 public class TestCallingConventionC1 extends ValueTypeTest { 42 public static final int C1 = COMP_LEVEL_SIMPLE; 43 public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; 44 45 @Override 46 public int getNumScenarios() { 47 return 4; 48 } 49 50 @Override 51 public String[] getVMParameters(int scenario) { 52 switch (scenario) { 53 case 0: return new String[] { 54 // Default: both C1 and C2 are enabled, tiered compilation enabled 55 "-XX:+EnableValhallaC1", 56 "-XX:CICompilerCount=2" 57 }; 58 case 1: return new String[] { 59 // Same as above, but flip all the compLevel=C1 and compLevel=C2, so we test 60 // the compliment of the above scenario. 61 "-XX:+EnableValhallaC1", 62 "-XX:CICompilerCount=2", 63 "-DFlipC1C2=true" 64 }; 65 case 2: return new String[] { 66 // Only C1. Tiered compilation disabled. 67 "-XX:+EnableValhallaC1", 68 "-XX:TieredStopAtLevel=1", 69 }; 70 case 3: return new String[] { 71 // Only C2. 72 "-XX:-EnableValhallaC1", 73 "-XX:TieredStopAtLevel=4", 74 }; 75 } 76 return null; 77 } 78 79 public static void main(String[] args) throws Throwable { 80 System.gc(); // Resolve this call, to avoid C1 code patching in the test cases. 81 TestCallingConventionC1 test = new TestCallingConventionC1(); 82 test.run(args, 83 Point.class, 84 Functor.class, 85 Functor1.class, 86 Functor2.class, 87 Functor3.class, 88 Functor4.class, 89 MyImplPojo0.class, 90 MyImplPojo1.class, 2098 public RefPoint test102_helper(RefPoint rp) { 2099 return rp; 2100 } 2101 2102 @DontCompile 2103 public void test102_verifier(boolean warmup) { 2104 int count = warmup ? 1 : 5; 2105 for (int i=0; i<count; i++) { 2106 RefPoint rp = new RefPoint(11, 22); 2107 Object x = rp.x; 2108 Object y = rp.y; 2109 RefPoint result = new RefPoint(333, 444); 2110 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) { 2111 result = test102(rp); 2112 } 2113 Asserts.assertEQ(rp.x, result.x); 2114 Asserts.assertEQ(rp.y, result.y); 2115 Asserts.assertEQ(x, result.x); 2116 Asserts.assertEQ(y, result.y); 2117 } 2118 } 2119 } | 27 import jdk.test.lib.Asserts; 28 29 /* 30 * @test 31 * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa. 32 * @library /testlibrary /test/lib /compiler/whitebox / 33 * @requires os.simpleArch == "x64" 34 * @compile TestCallingConventionC1.java 35 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform 36 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions 37 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI 38 * compiler.valhalla.valuetypes.ValueTypeTest 39 * compiler.valhalla.valuetypes.TestCallingConventionC1 40 */ 41 public class TestCallingConventionC1 extends ValueTypeTest { 42 public static final int C1 = COMP_LEVEL_SIMPLE; 43 public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; 44 45 @Override 46 public int getNumScenarios() { 47 return 5; 48 } 49 50 @Override 51 public String[] getVMParameters(int scenario) { 52 switch (scenario) { 53 case 0: return new String[] { 54 // Default: both C1 and C2 are enabled, tiered compilation enabled 55 "-XX:+EnableValhallaC1", 56 "-XX:CICompilerCount=2" 57 }; 58 case 1: return new String[] { 59 // Default: both C1 and C2 are enabled, tiered compilation enabled 60 "-XX:+EnableValhallaC1", 61 "-XX:CICompilerCount=2", 62 "-XX:+StressValueTypeReturnedAsFields" 63 }; 64 case 2: return new String[] { 65 // Same as above, but flip all the compLevel=C1 and compLevel=C2, so we test 66 // the compliment of the above scenario. 67 "-XX:+EnableValhallaC1", 68 "-XX:CICompilerCount=2", 69 "-DFlipC1C2=true" 70 }; 71 case 3: return new String[] { 72 // Only C1. Tiered compilation disabled. 73 "-XX:+EnableValhallaC1", 74 "-XX:TieredStopAtLevel=1", 75 }; 76 case 4: return new String[] { 77 // Only C2. 78 "-XX:-EnableValhallaC1", 79 "-XX:TieredStopAtLevel=4", 80 }; 81 } 82 return null; 83 } 84 85 public static void main(String[] args) throws Throwable { 86 System.gc(); // Resolve this call, to avoid C1 code patching in the test cases. 87 TestCallingConventionC1 test = new TestCallingConventionC1(); 88 test.run(args, 89 Point.class, 90 Functor.class, 91 Functor1.class, 92 Functor2.class, 93 Functor3.class, 94 Functor4.class, 95 MyImplPojo0.class, 96 MyImplPojo1.class, 2104 public RefPoint test102_helper(RefPoint rp) { 2105 return rp; 2106 } 2107 2108 @DontCompile 2109 public void test102_verifier(boolean warmup) { 2110 int count = warmup ? 1 : 5; 2111 for (int i=0; i<count; i++) { 2112 RefPoint rp = new RefPoint(11, 22); 2113 Object x = rp.x; 2114 Object y = rp.y; 2115 RefPoint result = new RefPoint(333, 444); 2116 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) { 2117 result = test102(rp); 2118 } 2119 Asserts.assertEQ(rp.x, result.x); 2120 Asserts.assertEQ(rp.y, result.y); 2121 Asserts.assertEQ(x, result.x); 2122 Asserts.assertEQ(y, result.y); 2123 } 2124 } 2125 2126 @Test(compLevel = C1) 2127 public void test103() { 2128 // when this method is compiled by C1, the Test103Value class is not yet loaded. 2129 test103_v = new Test103Value(); // invokestatic "Test103Value.<init>()QTest103Value;" 2130 } 2131 2132 static inline class Test103Value { 2133 int x = 112233; 2134 } 2135 2136 static Object test103_v; 2137 2138 @DontCompile 2139 public void test103_verifier(boolean warmup) { 2140 if (warmup) { 2141 // Maue sure test103() is compiled before the classes are loaded 2142 return; 2143 } 2144 test103(); 2145 Test103Value v = (Test103Value)test103_v; 2146 Asserts.assertEQ(v.x, 112233); 2147 } 2148 2149 2150 // Same as test103, but with an inline class that's too big to return as fields. 2151 @Test(compLevel = C1) 2152 public void test104() { 2153 // when this method is compiled by C1, the Test104Value class is not yet loaded. 2154 test104_v = new Test104Value(); // invokestatic "Test104Value.<init>()QTest104Value;" 2155 } 2156 2157 static inline class Test104Value { 2158 long x0 = 112233; 2159 long x1 = 112233; 2160 long x2 = 112233; 2161 long x3 = 112233; 2162 long x4 = 112233; 2163 long x5 = 112233; 2164 long x6 = 112233; 2165 long x7 = 112233; 2166 long x8 = 112233; 2167 long x9 = 112233; 2168 long xa = 112233; 2169 long xb = 112233; 2170 long xc = 112233; 2171 long xd = 112233; 2172 long xe = 112233; 2173 long xf = 112233; 2174 } 2175 2176 static Object test104_v; 2177 2178 @DontCompile 2179 public void test104_verifier(boolean warmup) { 2180 if (warmup) { 2181 // Maue sure test104() is compiled before the classes are loaded 2182 return; 2183 } 2184 test104(); 2185 Test104Value v = (Test104Value)test104_v; 2186 Asserts.assertEQ((int)(v.x0), 112233); 2187 } 2188 } |