blob: de00a09256e6398c12e5a2d3f0d5feb05942b8a9 [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
David Brazdila06d66a2015-05-28 11:14:54 +010019 /// CHECK-START: int Main.inlineInstanceCall(Main) inliner (before)
20 /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect
21 /// CHECK-DAG: Return [<<Invoke>>]
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000022
David Brazdila06d66a2015-05-28 11:14:54 +010023 /// CHECK-START: int Main.inlineInstanceCall(Main) inliner (after)
24 /// CHECK-NOT: InvokeStaticOrDirect
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000025
David Brazdila06d66a2015-05-28 11:14:54 +010026 /// CHECK-START: int Main.inlineInstanceCall(Main) inliner (after)
27 /// CHECK-DAG: <<Field:i\d+>> InstanceFieldGet
28 /// CHECK-DAG: Return [<<Field>>]
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000029
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
David Brazdila06d66a2015-05-28 11:14:54 +010040 /// CHECK-START: int Main.inlineNestedCall() inliner (before)
41 /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect
42 /// CHECK-DAG: Return [<<Invoke>>]
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000043
David Brazdila06d66a2015-05-28 11:14:54 +010044 /// CHECK-START: int Main.inlineNestedCall() inliner (after)
45 /// CHECK-NOT: InvokeStaticOrDirect
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000046
David Brazdila06d66a2015-05-28 11:14:54 +010047 /// CHECK-START: int Main.inlineNestedCall() inliner (after)
48 /// CHECK-DAG: <<Const38:i\d+>> IntConstant 38
49 /// CHECK-DAG: Return [<<Const38>>]
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000050
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}