blob: 1b25b4257faa8676e754525f6fa051ce6a67cf6e [file] [log] [blame]
Nicolas Geoffray79041292015-03-26 10:05:54 +00001/*
2* Copyright (C) 2015 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 {
18
19 public void invokeVirtual() {
20 }
21
22 // CHECK-START: void Main.inlineSharpenInvokeVirtual(Main) inliner (before)
23 // CHECK-DAG: [[Invoke:v\d+]] InvokeStaticOrDirect
24 // CHECK-DAG: ReturnVoid
25
26 // CHECK-START: void Main.inlineSharpenInvokeVirtual(Main) inliner (after)
27 // CHECK-NOT: InvokeStaticOrDirect
28
29 public static void inlineSharpenInvokeVirtual(Main m) {
30 m.invokeVirtual();
31 }
32
33 // CHECK-START: int Main.inlineSharpenStringInvoke() inliner (before)
34 // CHECK-DAG: [[Invoke:i\d+]] InvokeStaticOrDirect
35 // CHECK-DAG: Return [ [[Invoke]] ]
36
37 // CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after)
38 // CHECK-NOT: InvokeStaticOrDirect
39
40 // CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after)
41 // CHECK-DAG: [[Field:i\d+]] InstanceFieldGet
42 // CHECK-DAG: Return [ [[Field]] ]
43
44 public static int inlineSharpenStringInvoke() {
45 return "Foo".length();
46 }
47
48 public static void main(String[] args) {
49 inlineSharpenInvokeVirtual(new Main());
50 if (inlineSharpenStringInvoke() != 3) {
51 throw new Error("Expected 3");
52 }
53 }
54}