/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static void main(String args[]) { int[] array = new int[51]; testArrayLengthBoundsCheckX86(array, 10); System.out.println("passed"); } /// CHECK-START-X86: void Main.testArrayLengthBoundsCheckX86(int[], int) x86_memory_operand_generation (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK-DAG: <> NullCheck [<>] /// CHECK-DAG: <> ArrayLength [<>] is_string_length:false loop:none /// CHECK-DAG: <> BoundsCheck [<>,<>] /// CHECK-DAG: <> ArraySet [<>,<>,<>] /// CHECK-START-X86: void Main.testArrayLengthBoundsCheckX86(int[], int) x86_memory_operand_generation (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK-DAG: <> NullCheck [<>] /// CHECK-DAG: <> ArrayLength [<>] is_string_length:false emitted_at_use:true loop:none /// CHECK-DAG: <> BoundsCheck [<>,<>] /// CHECK-DAG: <> ArraySet [<>,<>,<>] /// CHECK-START-X86: void Main.testArrayLengthBoundsCheckX86(int[], int) disassembly (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK: <> NullCheck [<>] /// CHECK-NEXT: <> ArrayLength [<>] is_string_length:false emitted_at_use:true loop:none /// CHECK-NEXT: <> BoundsCheck [<>,<>] /// CHECK-NEXT: cmp [<> + 8], <> /// CHECK: <> ArraySet [<>,<>,<>] /// CHECK-NEXT: mov [<> + <> * 4 + 12], 9 /// CHECK-START-X86_64: void Main.testArrayLengthBoundsCheckX86(int[], int) x86_memory_operand_generation (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK-DAG: <> NullCheck [<>] /// CHECK-DAG: <> ArrayLength [<>] is_string_length:false loop:none /// CHECK-DAG: <> BoundsCheck [<>,<>] /// CHECK-DAG: <> ArraySet [<>,<>,<>] /// CHECK-START-X86_64: void Main.testArrayLengthBoundsCheckX86(int[], int) x86_memory_operand_generation (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK-DAG: <> NullCheck [<>] /// CHECK-DAG: <> ArrayLength [<>] is_string_length:false emitted_at_use:true loop:none /// CHECK-DAG: <> BoundsCheck [<>,<>] /// CHECK-DAG: <> ArraySet [<>,<>,<>] // Test assumes parameter value is in lower 8 registers (it is passed in edx). /// CHECK-START-X86_64: void Main.testArrayLengthBoundsCheckX86(int[], int) disassembly (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK: <> NullCheck [<>] /// CHECK-NEXT: <> ArrayLength [<>] is_string_length:false emitted_at_use:true loop:none /// CHECK-NEXT: <> BoundsCheck [<>,<>] /// CHECK-NEXT: cmp [<> + 8], e<> /// CHECK: <> ArraySet [<>,<>,<>] /// CHECK-NEXT: mov [<> + r<> * 4 + 12], 9 static void testArrayLengthBoundsCheckX86(int[] array, int index) { array[index] = 9; } }