1 /* 2 * Copyright (C) 2016 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 for (int i = 0; i < 20000; ++i) { 20 $noinline$testInTryCatch(new Main(), i); 21 $noinline$testInTryCatch(new SubMain(), i); 22 } 23 } 24 $noinline$testInTryCatch(Main m, int i)25 public static void $noinline$testInTryCatch(Main m, int i) { 26 final int value; 27 try { 28 throw new Exception(); 29 } catch (Exception e) { 30 // The polymorphic inlining of 'willInlineVoid' used to generate an 31 // incorrect graph, by setting the inlined blocks as catch blocks. 32 m.willInlineVoid(i); 33 return; 34 } 35 } 36 willInlineVoid(int i)37 public void willInlineVoid(int i) { 38 if (i == 0) { 39 $noinline$foo(); 40 } else { 41 $noinline$foo(); 42 $noinline$foo(); 43 } 44 } 45 $noinline$foo()46 public static void $noinline$foo() { 47 if (doThrow) throw new Error(""); 48 } 49 50 public static boolean doThrow; 51 } 52 53 class SubMain extends Main { willInlineVoid(int i)54 public void willInlineVoid(int i) { 55 } 56 } 57