blob: ecf071e45962ae8769afa592adb8b15292fc6800 [file] [log] [blame]
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +00001/*
2* Copyright (C) 2014 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 class Main {
18
19 // CHECK-START: int Main.inlineInstanceCall(Main) inliner (before)
20 // CHECK-DAG: [[Invoke:i\d+]] InvokeStaticOrDirect
21 // CHECK-DAG: Return [ [[Invoke]] ]
22
23 // CHECK-START: int Main.inlineInstanceCall(Main) inliner (after)
24 // CHECK-NOT: InvokeStaticOrDirect
25
26 // CHECK-START: int Main.inlineInstanceCall(Main) inliner (after)
27 // CHECK-DAG: [[Field:i\d+]] InstanceFieldGet
28 // CHECK-DAG: Return [ [[Field]] ]
29
30 public static int inlineInstanceCall(Main m) {
31 return m.foo();
32 }
33
34 private int foo() {
35 return field;
36 }
37
38 int field = 42;
39
40 // CHECK-START: int Main.inlineNestedCall() inliner (before)
41 // CHECK-DAG: [[Invoke:i\d+]] InvokeStaticOrDirect
42 // CHECK-DAG: Return [ [[Invoke]] ]
43
44 // CHECK-START: int Main.inlineNestedCall() inliner (after)
45 // CHECK-NOT: InvokeStaticOrDirect
46
47 // CHECK-START: int Main.inlineNestedCall() inliner (after)
48 // CHECK-DAG: [[Const38:i\d+]] IntConstant 38
49 // CHECK-DAG: Return [ [[Const38]] ]
50
51 public static int inlineNestedCall() {
52 return nestedCall();
53 }
54
55 public static int nestedCall() {
56 return bar();
57 }
58
59 public static int bar() {
60 return 38;
61 }
62
63 public static void main(String[] args) {
64 if (inlineInstanceCall(new Main()) != 42) {
65 throw new Error("Expected 42");
66 }
67
68 if (inlineNestedCall() != 38) {
69 throw new Error("Expected 38");
70 }
71 }
72}