blob: e451f703c27d14148d52e885fb58cf158da1bd9e [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)
David Brazdilc2c48ff2015-05-15 14:24:31 +010023 // CHECK-DAG: <<Invoke:v\d+>> InvokeStaticOrDirect
Nicolas Geoffray79041292015-03-26 10:05:54 +000024 // 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)
David Brazdilc2c48ff2015-05-15 14:24:31 +010034 // CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect
David Brazdilc57397b2015-05-15 16:01:59 +010035 // CHECK-DAG: Return [<<Invoke>>]
Nicolas Geoffray79041292015-03-26 10:05:54 +000036
37 // CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after)
38 // CHECK-NOT: InvokeStaticOrDirect
39
40 // CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after)
David Brazdilc2c48ff2015-05-15 14:24:31 +010041 // CHECK-DAG: <<Field:i\d+>> InstanceFieldGet
David Brazdilc57397b2015-05-15 16:01:59 +010042 // CHECK-DAG: Return [<<Field>>]
Nicolas Geoffray79041292015-03-26 10:05:54 +000043
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}