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 { 18 $inline$doCall()19 public static void $inline$doCall() { 20 if (doThrow) throw new Error(""); 21 } 22 tryInline()23 public static void tryInline() { 24 if (doThrow) throw new Error(""); 25 } 26 27 /// CHECK-START: void Main.test() inliner (before) 28 /// CHECK: InvokeStaticOrDirect method_name:Main.$inline$doCall loop:none 29 30 /// CHECK-START: void Main.test() inliner (after) 31 /// CHECK-NOT: InvokeStaticOrDirect method_name:Main.$inline$doCall test()32 public static void test() { 33 $inline$doCall(); 34 } 35 36 /// CHECK-START: void Main.testInLoop() inliner (before) 37 /// CHECK: InvokeStaticOrDirect method_name:Main.$inline$doCall loop:{{B\d+}} 38 39 /// CHECK-START: void Main.testInLoop() inliner (after) 40 /// CHECK-NOT: InvokeStaticOrDirect method_name:Main.$inline$doCall testInLoop()41 public static void testInLoop() { 42 for (int i = 0; i < 10; ++i) { 43 $inline$doCall(); 44 } 45 } 46 47 /// CHECK-START: void Main.testInInfiniteLoop() inliner (before) 48 /// CHECK: InvokeStaticOrDirect method_name:Main.tryInline loop:{{B\d+}} 49 50 /// CHECK-START: void Main.testInInfiniteLoop() inliner (after) 51 /// CHECK: InvokeStaticOrDirect method_name:Main.tryInline loop:{{B\d+}} testInInfiniteLoop()52 public static void testInInfiniteLoop() { 53 while (true) { 54 tryInline(); 55 } 56 } 57 main(String[] args)58 public static void main(String[] args) { 59 test(); 60 testInLoop(); 61 } 62 63 static boolean doThrow = false; 64 } 65