1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 public class Main { 18 19 Object i0000, i0001, i0002, i0003, i0004, i0005, i0006, i0007, i0008, i0009; 20 Object i0010, i0011, i0012, i0013, i0014, i0015, i0016, i0017, i0018, i0019; 21 Object i0020, i0021, i0022, i0023, i0024, i0025, i0026, i0027, i0028, i0029; 22 Object i0030, i0031, i0032, i0033, i0034, i0035, i0036, i0037, i0038, i0039; 23 Object i0040, i0041, i0042, i0043, i0044, i0045, i0046, i0047, i0048, i0049; 24 Object i0050, i0051, i0052, i0053, i0054, i0055, i0056, i0057, i0058, i0059; 25 Object i0060, i0061, i0062, i0063, i0064, i0065, i0066, i0067, i0068, i0069; 26 Object i0070, i0071, i0072, i0073, i0074, i0075, i0076, i0077, i0078, i0079; 27 Object i0080, i0081, i0082, i0083, i0084, i0085, i0086, i0087, i0088, i0089; 28 Object i0090, i0091, i0092, i0093, i0094, i0095, i0096, i0097, i0098, i0099; 29 30 Object i0100, i0101, i0102, i0103, i0104, i0105, i0106, i0107, i0108, i0109; 31 Object i0110, i0111, i0112, i0113, i0114, i0115, i0116, i0117, i0118, i0119; 32 Object i0120, i0121, i0122, i0123, i0124, i0125, i0126, i0127, i0128, i0129; 33 Object i0130, i0131, i0132, i0133, i0134, i0135, i0136, i0137, i0138, i0139; 34 Object i0140, i0141, i0142, i0143, i0144, i0145, i0146, i0147, i0148, i0149; 35 Object i0150, i0151, i0152, i0153, i0154, i0155, i0156, i0157, i0158, i0159; 36 Object i0160, i0161, i0162, i0163, i0164, i0165, i0166, i0167, i0168, i0169; 37 Object i0170, i0171, i0172, i0173, i0174, i0175, i0176, i0177, i0178, i0179; 38 Object i0180, i0181, i0182, i0183, i0184, i0185, i0186, i0187, i0188, i0189; 39 Object i0190, i0191, i0192, i0193, i0194, i0195, i0196, i0197, i0198, i0199; 40 41 Object i0200, i0201, i0202, i0203, i0204, i0205, i0206, i0207, i0208, i0209; 42 Object i0210, i0211, i0212, i0213, i0214, i0215, i0216, i0217, i0218, i0219; 43 Object i0220, i0221, i0222, i0223, i0224, i0225, i0226, i0227, i0228, i0229; 44 Object i0230, i0231, i0232, i0233, i0234, i0235, i0236, i0237, i0238, i0239; 45 Object i0240, i0241, i0242, i0243, i0244, i0245, i0246, i0247, i0248, i0249; 46 Object i0250, i0251, i0252, i0253, i0254, i0255, i0256, i0257, i0258, i0259; 47 Object i0260, i0261, i0262, i0263, i0264, i0265, i0266, i0267, i0268, i0269; 48 Object i0270, i0271, i0272, i0273, i0274, i0275, i0276, i0277, i0278, i0279; 49 Object i0280, i0281, i0282, i0283, i0284, i0285, i0286, i0287, i0288, i0289; 50 Object i0290, i0291, i0292, i0293, i0294, i0295, i0296, i0297, i0298, i0299; 51 52 Object i0300, i0301, i0302, i0303, i0304, i0305, i0306, i0307, i0308, i0309; 53 Object i0310, i0311, i0312, i0313, i0314, i0315, i0316, i0317, i0318, i0319; 54 Object i0320, i0321, i0322, i0323, i0324, i0325, i0326, i0327, i0328, i0329; 55 Object i0330, i0331, i0332, i0333, i0334, i0335, i0336, i0337, i0338, i0339; 56 Object i0340, i0341, i0342, i0343, i0344, i0345, i0346, i0347, i0348, i0349; 57 Object i0350, i0351, i0352, i0353, i0354, i0355, i0356, i0357, i0358, i0359; 58 Object i0360, i0361, i0362, i0363, i0364, i0365, i0366, i0367, i0368, i0369; 59 Object i0370, i0371, i0372, i0373, i0374, i0375, i0376, i0377, i0378, i0379; 60 Object i0380, i0381, i0382, i0383, i0384, i0385, i0386, i0387, i0388, i0389; 61 Object i0390, i0391, i0392, i0393, i0394, i0395, i0396, i0397, i0398, i0399; 62 63 Object i0400, i0401, i0402, i0403, i0404, i0405, i0406, i0407, i0408, i0409; 64 Object i0410, i0411, i0412, i0413, i0414, i0415, i0416, i0417, i0418, i0419; 65 Object i0420, i0421, i0422, i0423, i0424, i0425, i0426, i0427, i0428, i0429; 66 Object i0430, i0431, i0432, i0433, i0434, i0435, i0436, i0437, i0438, i0439; 67 Object i0440, i0441, i0442, i0443, i0444, i0445, i0446, i0447, i0448, i0449; 68 Object i0450, i0451, i0452, i0453, i0454, i0455, i0456, i0457, i0458, i0459; 69 Object i0460, i0461, i0462, i0463, i0464, i0465, i0466, i0467, i0468, i0469; 70 Object i0470, i0471, i0472, i0473, i0474, i0475, i0476, i0477, i0478, i0479; 71 Object i0480, i0481, i0482, i0483, i0484, i0485, i0486, i0487, i0488, i0489; 72 Object i0490, i0491, i0492, i0493, i0494, i0495, i0496, i0497, i0498, i0499; 73 74 Object i0500, i0501, i0502, i0503, i0504, i0505, i0506, i0507, i0508, i0509; 75 Object i0510, i0511, i0512, i0513, i0514, i0515, i0516, i0517, i0518, i0519; 76 Object i0520, i0521, i0522, i0523, i0524, i0525, i0526, i0527, i0528, i0529; 77 Object i0530, i0531, i0532, i0533, i0534, i0535, i0536, i0537, i0538, i0539; 78 Object i0540, i0541, i0542, i0543, i0544, i0545, i0546, i0547, i0548, i0549; 79 Object i0550, i0551, i0552, i0553, i0554, i0555, i0556, i0557, i0558, i0559; 80 Object i0560, i0561, i0562, i0563, i0564, i0565, i0566, i0567, i0568, i0569; 81 Object i0570, i0571, i0572, i0573, i0574, i0575, i0576, i0577, i0578, i0579; 82 Object i0580, i0581, i0582, i0583, i0584, i0585, i0586, i0587, i0588, i0589; 83 Object i0590, i0591, i0592, i0593, i0594, i0595, i0596, i0597, i0598, i0599; 84 85 Object i0600, i0601, i0602, i0603, i0604, i0605, i0606, i0607, i0608, i0609; 86 Object i0610, i0611, i0612, i0613, i0614, i0615, i0616, i0617, i0618, i0619; 87 Object i0620, i0621, i0622, i0623, i0624, i0625, i0626, i0627, i0628, i0629; 88 Object i0630, i0631, i0632, i0633, i0634, i0635, i0636, i0637, i0638, i0639; 89 Object i0640, i0641, i0642, i0643, i0644, i0645, i0646, i0647, i0648, i0649; 90 Object i0650, i0651, i0652, i0653, i0654, i0655, i0656, i0657, i0658, i0659; 91 Object i0660, i0661, i0662, i0663, i0664, i0665, i0666, i0667, i0668, i0669; 92 Object i0670, i0671, i0672, i0673, i0674, i0675, i0676, i0677, i0678, i0679; 93 Object i0680, i0681, i0682, i0683, i0684, i0685, i0686, i0687, i0688, i0689; 94 Object i0690, i0691, i0692, i0693, i0694, i0695, i0696, i0697, i0698, i0699; 95 96 Object i0700, i0701, i0702, i0703, i0704, i0705, i0706, i0707, i0708, i0709; 97 Object i0710, i0711, i0712, i0713, i0714, i0715, i0716, i0717, i0718, i0719; 98 Object i0720, i0721, i0722, i0723, i0724, i0725, i0726, i0727, i0728, i0729; 99 Object i0730, i0731, i0732, i0733, i0734, i0735, i0736, i0737, i0738, i0739; 100 Object i0740, i0741, i0742, i0743, i0744, i0745, i0746, i0747, i0748, i0749; 101 Object i0750, i0751, i0752, i0753, i0754, i0755, i0756, i0757, i0758, i0759; 102 Object i0760, i0761, i0762, i0763, i0764, i0765, i0766, i0767, i0768, i0769; 103 Object i0770, i0771, i0772, i0773, i0774, i0775, i0776, i0777, i0778, i0779; 104 Object i0780, i0781, i0782, i0783, i0784, i0785, i0786, i0787, i0788, i0789; 105 Object i0790, i0791, i0792, i0793, i0794, i0795, i0796, i0797, i0798, i0799; 106 107 Object i0800, i0801, i0802, i0803, i0804, i0805, i0806, i0807, i0808, i0809; 108 Object i0810, i0811, i0812, i0813, i0814, i0815, i0816, i0817, i0818, i0819; 109 Object i0820, i0821, i0822, i0823, i0824, i0825, i0826, i0827, i0828, i0829; 110 Object i0830, i0831, i0832, i0833, i0834, i0835, i0836, i0837, i0838, i0839; 111 Object i0840, i0841, i0842, i0843, i0844, i0845, i0846, i0847, i0848, i0849; 112 Object i0850, i0851, i0852, i0853, i0854, i0855, i0856, i0857, i0858, i0859; 113 Object i0860, i0861, i0862, i0863, i0864, i0865, i0866, i0867, i0868, i0869; 114 Object i0870, i0871, i0872, i0873, i0874, i0875, i0876, i0877, i0878, i0879; 115 Object i0880, i0881, i0882, i0883, i0884, i0885, i0886, i0887, i0888, i0889; 116 Object i0890, i0891, i0892, i0893, i0894, i0895, i0896, i0897, i0898, i0899; 117 118 Object i0900, i0901, i0902, i0903, i0904, i0905, i0906, i0907, i0908, i0909; 119 Object i0910, i0911, i0912, i0913, i0914, i0915, i0916, i0917, i0918, i0919; 120 Object i0920, i0921, i0922, i0923, i0924, i0925, i0926, i0927, i0928, i0929; 121 Object i0930, i0931, i0932, i0933, i0934, i0935, i0936, i0937, i0938, i0939; 122 Object i0940, i0941, i0942, i0943, i0944, i0945, i0946, i0947, i0948, i0949; 123 Object i0950, i0951, i0952, i0953, i0954, i0955, i0956, i0957, i0958, i0959; 124 Object i0960, i0961, i0962, i0963, i0964, i0965, i0966, i0967, i0968, i0969; 125 Object i0970, i0971, i0972, i0973, i0974, i0975, i0976, i0977, i0978, i0979; 126 Object i0980, i0981, i0982, i0983, i0984, i0985, i0986, i0987, i0988, i0989; 127 Object i0990, i0991, i0992, i0993, i0994, i0995, i0996, i0997, i0998, i0999; 128 129 Object i1000, i1001, i1002, i1003, i1004, i1005, i1006, i1007, i1008, i1009; 130 Object i1010, i1011, i1012, i1013, i1014, i1015, i1016, i1017, i1018, i1019; 131 Object i1020, i1021, i1022, i1023, i1024, i1025, i1026, i1027, i1028, i1029; 132 Object i1030, i1031, i1032, i1033, i1034, i1035, i1036, i1037, i1038, i1039; 133 Object i1040, i1041, i1042, i1043, i1044, i1045, i1046, i1047, i1048, i1049; 134 Object i1050, i1051, i1052, i1053, i1054, i1055, i1056, i1057, i1058, i1059; 135 Object i1060, i1061, i1062, i1063, i1064, i1065, i1066, i1067, i1068, i1069; 136 Object i1070, i1071, i1072, i1073, i1074, i1075, i1076, i1077, i1078, i1079; 137 Object i1080, i1081, i1082, i1083, i1084, i1085, i1086, i1087, i1088, i1089; 138 Object i1090, i1091, i1092, i1093, i1094, i1095, i1096, i1097, i1098, i1099; 139 140 volatile Object volatileObjectField; 141 volatile int volatileIntField; 142 volatile long volatileWideField; 143 144 Object objectField; 145 int intField; 146 long wideField; 147 148 volatile Object putVolatileObjectField; 149 volatile int putVolatileIntField; 150 volatile long putVolatileWideField; 151 152 Object putObjectField; 153 int putIntField; 154 long putWideField; 155 check(NullPointerException npe, int firstLine)156 static void check(NullPointerException npe, int firstLine) { 157 StackTraceElement[] trace = npe.getStackTrace(); 158 checkElement(trace[0], "Main", "test", "Main.java", firstLine); 159 checkElement(trace[1], "Main", "main", "Main.java", 179); 160 } 161 checkElement(StackTraceElement element, String declaringClass, String methodName, String fileName, int lineNumber)162 static void checkElement(StackTraceElement element, 163 String declaringClass, String methodName, 164 String fileName, int lineNumber) { 165 assertEquals(declaringClass, element.getClassName()); 166 assertEquals(methodName, element.getMethodName()); 167 assertEquals(fileName, element.getFileName()); 168 assertEquals(lineNumber, element.getLineNumber()); 169 } 170 assertEquals(Object expected, Object actual)171 static void assertEquals(Object expected, Object actual) { 172 if (!expected.equals(actual)) { 173 String msg = "Expected \"" + expected + "\" but got \"" + actual + "\""; 174 throw new AssertionError(msg); 175 } 176 } 177 main(String[] args)178 public static void main(String[] args) { 179 test(); 180 } 181 test()182 public static void test() { 183 NullPointerException npe = null; 184 int thisLine = 184; 185 186 // We do each kind of test twice, to both test the fast path and the slow path 187 // of nterp. 188 189 try { 190 System.out.println($noinline$getNull().objectField); 191 } catch (NullPointerException e) { 192 npe = e; 193 } 194 check(npe, thisLine += 6); 195 196 try { 197 System.out.println($noinline$getNull().objectField); 198 } catch (NullPointerException e) { 199 npe = e; 200 } 201 check(npe, thisLine += 7); 202 203 try { 204 System.out.println($noinline$getNull().intField); 205 } catch (NullPointerException e) { 206 npe = e; 207 } 208 check(npe, thisLine += 7); 209 210 try { 211 System.out.println($noinline$getNull().intField); 212 } catch (NullPointerException e) { 213 npe = e; 214 } 215 check(npe, thisLine += 7); 216 217 try { 218 System.out.println($noinline$getNull().wideField); 219 } catch (NullPointerException e) { 220 npe = e; 221 } 222 check(npe, thisLine += 7); 223 224 try { 225 System.out.println($noinline$getNull().wideField); 226 } catch (NullPointerException e) { 227 npe = e; 228 } 229 check(npe, thisLine += 7); 230 231 try { 232 System.out.println($noinline$getNull().volatileObjectField); 233 } catch (NullPointerException e) { 234 npe = e; 235 } 236 check(npe, thisLine += 7); 237 238 try { 239 System.out.println($noinline$getNull().volatileObjectField); 240 } catch (NullPointerException e) { 241 npe = e; 242 } 243 check(npe, thisLine += 7); 244 245 try { 246 System.out.println($noinline$getNull().volatileIntField); 247 } catch (NullPointerException e) { 248 npe = e; 249 } 250 check(npe, thisLine += 7); 251 252 try { 253 System.out.println($noinline$getNull().volatileIntField); 254 } catch (NullPointerException e) { 255 npe = e; 256 } 257 check(npe, thisLine += 7); 258 259 try { 260 System.out.println($noinline$getNull().volatileWideField); 261 } catch (NullPointerException e) { 262 npe = e; 263 } 264 check(npe, thisLine += 7); 265 266 try { 267 System.out.println($noinline$getNull().volatileWideField); 268 } catch (NullPointerException e) { 269 npe = e; 270 } 271 check(npe, thisLine += 7); 272 273 try { 274 $noinline$getNull().putObjectField = null; 275 } catch (NullPointerException e) { 276 npe = e; 277 } 278 check(npe, thisLine += 7); 279 280 try { 281 $noinline$getNull().putObjectField = null; 282 } catch (NullPointerException e) { 283 npe = e; 284 } 285 check(npe, thisLine += 7); 286 287 try { 288 $noinline$getNull().putIntField = 42; 289 } catch (NullPointerException e) { 290 npe = e; 291 } 292 check(npe, thisLine += 7); 293 294 try { 295 $noinline$getNull().putIntField = 42; 296 } catch (NullPointerException e) { 297 npe = e; 298 } 299 check(npe, thisLine += 7); 300 301 try { 302 $noinline$getNull().putWideField = 42L; 303 } catch (NullPointerException e) { 304 npe = e; 305 } 306 check(npe, thisLine += 7); 307 308 try { 309 $noinline$getNull().putWideField = 42L; 310 } catch (NullPointerException e) { 311 npe = e; 312 } 313 check(npe, thisLine += 7); 314 315 try { 316 $noinline$getNull().putVolatileObjectField = null; 317 } catch (NullPointerException e) { 318 npe = e; 319 } 320 check(npe, thisLine += 7); 321 322 try { 323 $noinline$getNull().putVolatileObjectField = null; 324 } catch (NullPointerException e) { 325 npe = e; 326 } 327 check(npe, thisLine += 7); 328 329 try { 330 $noinline$getNull().putVolatileIntField = 42; 331 } catch (NullPointerException e) { 332 npe = e; 333 } 334 check(npe, thisLine += 7); 335 336 try { 337 $noinline$getNull().putVolatileIntField = 42; 338 } catch (NullPointerException e) { 339 npe = e; 340 } 341 check(npe, thisLine += 7); 342 343 try { 344 $noinline$getNull().putVolatileWideField = 42L; 345 } catch (NullPointerException e) { 346 npe = e; 347 } 348 check(npe, thisLine += 7); 349 350 try { 351 $noinline$getNull().putVolatileWideField = 42L; 352 } catch (NullPointerException e) { 353 npe = e; 354 } 355 check(npe, thisLine += 7); 356 } 357 $noinline$getNull()358 public static Main $noinline$getNull() { 359 return null; 360 } 361 } 362