• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 
17 public class Main {
main(String[] args)18     public static void main(String[] args) {}
19 
20     /// CHECK-START: java.lang.Object[] Main.testNoRTILoopNoIterations() builder (after)
21     /// CHECK-DAG:     <<Null:l\d+>> NullConstant
22     /// CHECK-DAG:     <<Phi:l\d+>> Phi [<<Null>>,<<PhiBoundType:l\d+>>] klass:invalid
23     /// CHECK-DAG:     <<Check:l\d+>> NullCheck [<<Phi>>] klass:invalid
24     /// CHECK-DAG:     <<ArrayGet:l\d+>> ArrayGet [<<Check>>,<<BoundsCheck:i\d+>>] klass:invalid
25     /// CHECK-DAG:     <<BoundType:l\d+>> BoundType [<<ArrayGet>>] klass:invalid
26     // Due to the circular uses, this is how we check that the BoundType is a use of the Phi.
27     /// CHECK-EVAL:    "<<PhiBoundType>>" == "<<BoundType>>"
testNoRTILoopNoIterations()28     private static Object[] testNoRTILoopNoIterations() {
29         Object[] h = null;
30         for (int j = 0; j < 0; j++) {
31             h = (Object[]) h[0];
32         }
33         return h;
34     }
35 
$inline$doNothing(Object[] obj)36     private static void $inline$doNothing(Object[] obj) {}
37 
38     // This test also has no iterations, but we won't know until LSE. We inline the doNothing
39     // method, try to apply the invalid RTI and crash.
40 
41     /// CHECK-START: java.lang.Object[] Main.testNoRTILoopNoIterationsWithInlining() builder (after)
42     /// CHECK-DAG:     <<Null:l\d+>> NullConstant
43     /// CHECK-DAG:     <<Phi:l\d+>> Phi [<<Null>>,<<PhiBoundType:l\d+>>] klass:invalid
44     /// CHECK-DAG:     InvokeStaticOrDirect [<<Phi>>] method_name:Main.$inline$doNothing
45     /// CHECK-DAG:     <<Check:l\d+>> NullCheck [<<Phi>>] klass:invalid
46     /// CHECK-DAG:     <<ArrayGet:l\d+>> ArrayGet [<<Check>>,<<BoundsCheck:i\d+>>] klass:invalid
47     /// CHECK-DAG:     <<BoundType:l\d+>> BoundType [<<ArrayGet>>] klass:invalid
48     // Due to the circular uses, this is how we check that the BoundType is a use of the Phi.
49     /// CHECK-EVAL:    "<<PhiBoundType>>" == "<<BoundType>>"
testNoRTILoopNoIterationsWithInlining()50     public static Object[] testNoRTILoopNoIterationsWithInlining() {
51         Object[] h = null;
52         int iterations = 0;
53         int other_iterations = iterations;
54         for (int j = 0; j < other_iterations; j++) {
55             $inline$doNothing(h);
56             h = (Object[]) h[0];
57         }
58         return h;
59     }
60 
61 }
62