Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 1 | /* |
Roland Levillain | 6a92a03 | 2015-07-23 12:15:01 +0100 | [diff] [blame] | 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 | */ |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 16 | |
| 17 | public final class Main { |
| 18 | |
| 19 | public void invokeVirtual() { |
| 20 | } |
| 21 | |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame^] | 22 | /// CHECK-START: void Main.inlineSharpenInvokeVirtual(Main) builder (after) |
| 23 | /// CHECK-DAG: <<Invoke:v\d+>> InvokeVirtual |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 24 | /// CHECK-DAG: ReturnVoid |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 25 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 26 | /// CHECK-START: void Main.inlineSharpenInvokeVirtual(Main) inliner (after) |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame^] | 27 | /// CHECK-NOT: InvokeVirtual |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 28 | /// CHECK-NOT: InvokeStaticOrDirect |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 29 | |
| 30 | public static void inlineSharpenInvokeVirtual(Main m) { |
| 31 | m.invokeVirtual(); |
| 32 | } |
| 33 | |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame^] | 34 | /// CHECK-START: int Main.inlineSharpenStringInvoke() ssa_builder (after) |
| 35 | /// CHECK-DAG: <<Invoke:i\d+>> InvokeVirtual |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 36 | /// CHECK-DAG: Return [<<Invoke>>] |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 37 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 38 | /// CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after) |
| 39 | /// CHECK-NOT: InvokeStaticOrDirect |
Nicolas Geoffray | e523423 | 2015-12-02 09:06:11 +0000 | [diff] [blame^] | 40 | /// CHECK-NOT: InvokeVirtual |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 41 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 42 | /// CHECK-START: int Main.inlineSharpenStringInvoke() inliner (after) |
| 43 | /// CHECK-DAG: <<Field:i\d+>> InstanceFieldGet |
| 44 | /// CHECK-DAG: Return [<<Field>>] |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 45 | |
| 46 | public static int inlineSharpenStringInvoke() { |
| 47 | return "Foo".length(); |
| 48 | } |
| 49 | |
| 50 | public static void main(String[] args) { |
| 51 | inlineSharpenInvokeVirtual(new Main()); |
| 52 | if (inlineSharpenStringInvoke() != 3) { |
| 53 | throw new Error("Expected 3"); |
| 54 | } |
| 55 | } |
| 56 | } |