HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
art
test
527-checker-array-access-split
src
Main.java
/* * Copyright (C) 2015 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 assertIntEquals(int expected, int result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } /** * Test that HArrayGet with a constant index is not split. */ /// CHECK-START-ARM64: int Main.constantIndexGet(int[]) instruction_simplifier_arm64 (before) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArrayGet [<
>,<
>] /// CHECK-START-ARM64: int Main.constantIndexGet(int[]) instruction_simplifier_arm64 (after) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArrayGet [<
>,<
>] /// CHECK-START-ARM: int Main.constantIndexGet(int[]) instruction_simplifier_arm (before) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArrayGet [<
>,<
>] /// CHECK-START-ARM: int Main.constantIndexGet(int[]) instruction_simplifier_arm (after) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArrayGet [<
>,<
>] public static int constantIndexGet(int array[]) { return array[1]; } /** * Test that HArraySet with a constant index is not split. */ /// CHECK-START-ARM64: void Main.constantIndexSet(int[]) instruction_simplifier_arm64 (before) /// CHECK: <
> IntConstant 2 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: void Main.constantIndexSet(int[]) instruction_simplifier_arm64 (after) /// CHECK: <
> IntConstant 2 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.constantIndexSet(int[]) instruction_simplifier_arm (before) /// CHECK: <
> IntConstant 2 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.constantIndexSet(int[]) instruction_simplifier_arm (after) /// CHECK: <
> IntConstant 2 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<
>,<
>] public static void constantIndexSet(int array[]) { array[1] = 2; } /** * Test basic splitting of HArrayGet. */ /// CHECK-START-ARM64: int Main.get(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArrayGet [<
>,<
>] /// CHECK-START-ARM64: int Main.get(int[], int) instruction_simplifier_arm64 (after) /// CHECK: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArrayGet [<
>,<
>] /// CHECK-START-ARM: int Main.get(int[], int) instruction_simplifier_arm (before) /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArrayGet [<
>,<
>] /// CHECK-START-ARM: int Main.get(int[], int) instruction_simplifier_arm (after) /// CHECK: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArrayGet [<
>,<
>] public static int get(int array[], int index) { return array[index]; } /** * Test basic splitting of HArraySet. */ /// CHECK-START-ARM64: void Main.set(int[], int, int) instruction_simplifier_arm64 (before) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <
> ParameterValue /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: void Main.set(int[], int, int) instruction_simplifier_arm64 (after) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <
> ParameterValue /// CHECK: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.set(int[], int, int) instruction_simplifier_arm (before) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <
> ParameterValue /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.set(int[], int, int) instruction_simplifier_arm (after) /// CHECK: ParameterValue /// CHECK: ParameterValue /// CHECK: <
> ParameterValue /// CHECK: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArraySet [<
>,<
>,<
>] public static void set(int array[], int index, int value) { array[index] = value; } /** * Check that the intermediate address can be shared after GVN. */ /// CHECK-START-ARM64: void Main.getSet(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <
> IntConstant 1 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: void Main.getSet(int[], int) instruction_simplifier_arm64 (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: void Main.getSet(int[], int) GVN$after_arch (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.getSet(int[], int) instruction_simplifier_arm (before) /// CHECK: <
> IntConstant 1 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.getSet(int[], int) instruction_simplifier_arm (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: void Main.getSet(int[], int) GVN$after_arch (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK-NOT: IntermediateAddress /// CHECK: ArraySet [<
>,<
>,<
>] public static void getSet(int array[], int index) { array[index] = array[index] + 1; } /** * Check that the intermediate address computation is not reordered or merged * across IRs that can trigger GC. */ /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) instruction_simplifier_arm64 (before) /// CHECK: <
> IntConstant 1 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: NewArray /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) instruction_simplifier_arm64 (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: NewArray /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK-NEXT: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM64: int[] Main.accrossGC(int[], int) GVN$after_arch (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <
> IntConstant /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: NewArray /// CHECK: <
> IntermediateAddress [<
>,<
>] /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: int[] Main.accrossGC(int[], int) instruction_simplifier_arm (before) /// CHECK: <
> IntConstant 1 /// CHECK: <
> NullCheck /// CHECK: <
> BoundsCheck /// CHECK: <
> ArrayGet [<
>,<
>] /// CHECK: <
> Add [<
>,<
>] /// CHECK: NewArray /// CHECK: ArraySet [<
>,<
>,<
>] /// CHECK-START-ARM: int[] Main.accrossGC(int[], int) instruction_simplifier_arm (after) /// CHECK-DAG: <
> IntConstant 1 /// CHECK-DAG: <