• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = $noinline$computeDouble();
52       b = $noinline$computeDouble();
53       c = $noinline$computeDouble();
54       d = $noinline$computeDouble();
55       e = $noinline$computeDouble();
56       f = $noinline$computeDouble();
57       g = $noinline$computeDouble();
58       h = $noinline$computeDouble();
59       i = $noinline$computeDouble();
60       j = $noinline$computeDouble();
61       System.out.println(a + b + c + d + e + f + g + h + i + j);
62       aa = $noinline$computeFloat();
63       bb = $noinline$computeFloat();
64       cc = $noinline$computeFloat();
65       dd = $noinline$computeFloat();
66       ee = $noinline$computeFloat();
67       ff = $noinline$computeFloat();
68       gg = $noinline$computeFloat();
69       hh = $noinline$computeFloat();
70       ii = $noinline$computeFloat();
71       jj = $noinline$computeFloat();
72       kk = $noinline$computeFloat();
73       ll = $noinline$computeFloat();
74       mm = $noinline$computeFloat();
75       nn = $noinline$computeFloat();
76     }
77   }
78 
79   static boolean doThrow = false;
80 
$noinline$computeDouble()81   public static double $noinline$computeDouble() {
82     if (doThrow) {
83       // Try defeating inlining.
84       throw new Error();
85     }
86     return 2.0;
87   }
88 
$noinline$computeFloat()89   public static float $noinline$computeFloat() {
90     if (doThrow) {
91       // Try defeating inlining.
92       throw new Error();
93     }
94     return 4.0f;
95   }
96 }
97