blob: 139221555a9f72182b88ea49dd399732c7f5c293 [file] [log] [blame]
Roland Levillainca0bf032016-02-09 12:49:18 +00001/*
2 * Copyright (C) 2016 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
19 public static void main(String[] args) {
20 System.out.println(test().intValue());
21 }
22
23 /// CHECK-START: java.lang.Integer Main.test() ssa_builder (after)
Roland Levillain821e66b2016-02-10 12:33:29 +000024 /// CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod
Roland Levillainca0bf032016-02-09 12:49:18 +000025 /// CHECK-DAG: <<Const2P20:i\d+>> IntConstant 1048576
26 /// CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1
27 /// CHECK-DAG: <<Array:l\d+>> NewArray [<<Const2P20>>,<<Method>>]
28 /// CHECK-DAG: <<NullCheck1:l\d+>> NullCheck [<<Array>>]
29 /// CHECK-DAG: <<Length1:i\d+>> ArrayLength [<<NullCheck1>>]
30 /// CHECK-DAG: <<Index:i\d+>> Add [<<Length1>>,<<ConstM1>>]
31 /// CHECK-DAG: <<NullCheck2:l\d+>> NullCheck [<<Array>>]
32 /// CHECK-DAG: <<Length2:i\d+>> ArrayLength [<<NullCheck2>>]
33 /// CHECK-DAG: <<BoundsCheck:i\d+>> BoundsCheck [<<Index>>,<<Length2>>]
34 /// CHECK-DAG: <<LastElement:l\d+>> ArrayGet [<<NullCheck2>>,<<BoundsCheck>>]
35 /// CHECK-DAG: Return [<<LastElement>>]
36
37 /// CHECK-START: java.lang.Integer Main.test() register (before)
Roland Levillain821e66b2016-02-10 12:33:29 +000038 /// CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod
Roland Levillainca0bf032016-02-09 12:49:18 +000039 /// CHECK-DAG: <<Const2P20:i\d+>> IntConstant 1048576
40 /// CHECK-DAG: <<Const2P20M1:i\d+>> IntConstant 1048575
41 /// CHECK-DAG: <<Array:l\d+>> NewArray [<<Const2P20>>,<<Method>>]
42 /// CHECK-DAG: <<LastElement:l\d+>> ArrayGet [<<Array>>,<<Const2P20M1>>]
43 /// CHECK-DAG: Return [<<LastElement>>]
44
45 public static Integer test() {
46 Integer[] integers = new Integer[1024 * 1024];
47 initIntegerArray(integers);
48 // Array load with a large constant index (after constant folding
49 // and bounds check elimination).
50 Integer last_integer = integers[integers.length - 1];
51 return last_integer;
52 }
53
54 public static void initIntegerArray(Integer[] integers) {
55 for (int i = 0; i < integers.length; ++i) {
56 integers[i] = new Integer(i);
57 }
58 }
59
60}