| Nicolas Geoffray | 2c4ffe1 | 2018-09-06 10:05:57 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | // This test depends on the exact format of the DEX file. Since dx is deprecated, |
| 18 | // the classes.dex file is packaged as a test input. It was created with: |
| 19 | // |
| 20 | // $ javac -g -Xlint:-options -source 1.7 -target 1.7 -d classes src/Main.java |
| 21 | // $ dx --debug --dex --output=classes.dex classes |
| 22 | |
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 23 | public class Main { |
| 24 | public Main() { |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 25 | } |
| 26 | |
| Guillaume "Vermeille" Sanchez | e918d38 | 2015-06-03 15:32:41 +0100 | [diff] [blame] | 27 | int $noinline$f() throws Exception { |
| Nicolas Geoffray | 2c4ffe1 | 2018-09-06 10:05:57 +0100 | [diff] [blame^] | 28 | $noinline$g(1); |
| 29 | $noinline$g(2); |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 30 | return 0; |
| 31 | } |
| 32 | |
| Nicolas Geoffray | 2c4ffe1 | 2018-09-06 10:05:57 +0100 | [diff] [blame^] | 33 | void $noinline$g(int num_calls) { |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 34 | if (num_calls == 1) { |
| 35 | System.out.println("1st call"); |
| 36 | } else if (num_calls == 2) { |
| 37 | System.out.println("2nd call"); |
| 38 | } |
| 39 | System.out.println(shlemiel()); |
| 40 | } |
| 41 | |
| 42 | String shlemiel() { |
| 43 | String s0 = new String("0"); |
| 44 | String s1 = new String("1"); |
| 45 | String s2 = new String("2"); |
| 46 | String s3 = new String("3"); |
| 47 | String s4 = new String("4"); |
| 48 | String s5 = new String("5"); |
| 49 | String s6 = new String("6"); |
| 50 | String s7 = new String("7"); |
| 51 | String s8 = new String("8"); |
| 52 | String s9 = new String("9"); |
| 53 | String s10 = new String("10"); |
| 54 | String s11 = new String("11"); |
| 55 | String s12 = new String("12"); |
| 56 | String s13 = new String("13"); |
| 57 | String s14 = new String("14"); |
| 58 | String s15 = new String("15"); |
| 59 | String s16 = new String("16"); |
| 60 | String s17 = new String("17"); |
| 61 | String s18 = new String("18"); |
| 62 | String s19 = new String("19"); |
| 63 | String s20 = new String("20"); |
| 64 | String s = new String(); |
| 65 | s += s0; |
| 66 | s += s1; |
| 67 | s += s2; |
| 68 | s += s3; |
| 69 | s += s4; |
| 70 | s += s5; |
| 71 | s += s6; |
| 72 | s += s7; |
| 73 | s += s8; |
| 74 | s += s9; |
| 75 | s += s10; |
| 76 | s += s11; |
| 77 | s += s12; |
| 78 | s += s13; |
| 79 | s += s14; |
| 80 | s += s15; |
| 81 | s += s16; |
| 82 | s += s17; |
| 83 | s += s18; |
| 84 | s += s19; |
| 85 | s += s20; |
| 86 | |
| 87 | s += s6; |
| 88 | s += s5; |
| 89 | s += s2; |
| 90 | s += s3; |
| 91 | |
| 92 | s10 = s + s10; |
| 93 | s10 += s20; |
| 94 | |
| 95 | s20 += s10; |
| 96 | s = s17 + s20; |
| 97 | |
| 98 | s4 = s18 = s19; |
| 99 | s += s4; |
| 100 | s += s18; |
| Nicolas Geoffray | 2c4ffe1 | 2018-09-06 10:05:57 +0100 | [diff] [blame^] | 101 | // Add a branch to workaround ART's large methods without branches heuristic. |
| 102 | if (testStackWalk(0) != 0) { |
| 103 | return s; |
| 104 | } |
| 105 | return s18; |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| Nicolas Geoffray | 2c4ffe1 | 2018-09-06 10:05:57 +0100 | [diff] [blame^] | 108 | native int testStackWalk(int x); |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 109 | |
| Nicolas Geoffray | d23eeef | 2015-05-18 22:31:29 +0100 | [diff] [blame] | 110 | public static void main(String[] args) throws Exception { |
| Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 111 | System.loadLibrary(args[0]); |
| Andreas Gampe | 1c83cbc | 2014-07-22 18:52:29 -0700 | [diff] [blame] | 112 | Main st = new Main(); |
| Guillaume "Vermeille" Sanchez | e918d38 | 2015-06-03 15:32:41 +0100 | [diff] [blame] | 113 | st.$noinline$f(); |
| Shih-wei Liao | 9407c60 | 2011-09-16 10:36:43 -0700 | [diff] [blame] | 114 | } |
| 115 | } |