blob: 413f2dd51d0fdb385f74e99d22c4f39264398d7e [file] [log] [blame]
Nicolas Geoffray5bf7bac2016-07-06 14:18:23 +00001/*
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
17public final class Main implements Interface {
18
19 static void methodWithInvokeInterface(Interface interf) {
20 interf.doCall();
21 }
22
23 public void doCall() {
24 if (doThrow) throw new Error("");
25 }
26
27 public static void main(String[] args) {
28 testInlineInterfaceCall();
29 testInterfaceToVirtualCall();
30 }
31
32 /// CHECK-START: void Main.testInlineInterfaceCall() inliner (before)
33 /// CHECK: InvokeStaticOrDirect method_name:Main.methodWithInvokeInterface
34
35 /// CHECK-START: void Main.testInlineInterfaceCall() inliner (before)
36 /// CHECK-NOT: InvokeInterface
37
38 /// CHECK-START: void Main.testInlineInterfaceCall() inliner (after)
39 /// CHECK: InvokeInterface method_name:Interface.doCall
40
41 /// CHECK-START: void Main.testInlineInterfaceCall() inliner (after)
42 /// CHECK-NOT: InvokeStaticOrDirect
43 public static void testInlineInterfaceCall() {
44 methodWithInvokeInterface(itf);
45 }
46
47 /// CHECK-START: void Main.testInterfaceToVirtualCall() inliner (before)
48 /// CHECK: InvokeStaticOrDirect method_name:Main.methodWithInvokeInterface
49
50 /// CHECK-START: void Main.testInterfaceToVirtualCall() inliner (before)
51 /// CHECK-NOT: InvokeInterface
52
53 /// CHECK-START: void Main.testInterfaceToVirtualCall() inliner (after)
54 /// CHECK: InvokeVirtual method_name:Main.doCall
55
56 /// CHECK-START: void Main.testInterfaceToVirtualCall() inliner (after)
57 /// CHECK-NOT: InvokeStaticOrDirect
58 /// CHECK-NOT: InvokeInterface
59 public static void testInterfaceToVirtualCall() {
60 methodWithInvokeInterface(m);
61 }
62
63 static Interface itf = new Main();
64 static Main m = new Main();
65 static boolean doThrow = false;
66}
67
68interface Interface {
69 public void doCall();
70}