1 /* 2 * Copyright (C) 2015 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 { main(String[] args)18 public static void main(String[] args) { 19 // Create a few local variables to make sure some get spilled, and we get 20 // a conflict of swapping a single entry stack slot (float) with a double entry 21 // stack slot (double). 22 double a = 0.0; 23 double b = 1.0; 24 double c = 2.0; 25 double d = 3.0; 26 double e = 4.0; 27 double f = 5.0; 28 double g = 6.0; 29 double h = 7.0; 30 double i = 8.0; 31 double j = 9.0; 32 33 float aa = 0; 34 float bb = 1; 35 float cc = 2; 36 float dd = 3; 37 float ee = 4; 38 float ff = 5; 39 float gg = 6; 40 float hh = 7; 41 float ii = 8; 42 float jj = 9; 43 float kk = 10; 44 float ll = 10; 45 float mm = 10; 46 float nn = 10; 47 48 for (int count = 0; count < 2; count++) { 49 System.out.println(aa + bb + cc + dd + ee + ff + gg + hh + ii + jj + kk + ll + mm + nn); 50 System.out.println(a + b + c + d + e + f + g + h + i + j); 51 a = computeDouble(); 52 b = computeDouble(); 53 c = computeDouble(); 54 d = computeDouble(); 55 e = computeDouble(); 56 f = computeDouble(); 57 g = computeDouble(); 58 h = computeDouble(); 59 i = computeDouble(); 60 j = computeDouble(); 61 System.out.println(a + b + c + d + e + f + g + h + i + j); 62 aa = computeFloat(); 63 bb = computeFloat(); 64 cc = computeFloat(); 65 dd = computeFloat(); 66 ee = computeFloat(); 67 ff = computeFloat(); 68 gg = computeFloat(); 69 hh = computeFloat(); 70 ii = computeFloat(); 71 jj = computeFloat(); 72 kk = computeFloat(); 73 ll = computeFloat(); 74 mm = computeFloat(); 75 nn = computeFloat(); 76 } 77 } 78 79 static boolean doThrow = false; 80 computeDouble()81 public static double computeDouble() { 82 if (doThrow) { 83 // Try defeating inlining. 84 throw new Error(); 85 } 86 return 2.0; 87 } 88 computeFloat()89 public static float computeFloat() { 90 if (doThrow) { 91 // Try defeating inlining. 92 throw new Error(); 93 } 94 return 4.0f; 95 } 96 } 97