diff options
Diffstat (limited to 'test')
20 files changed, 511 insertions, 280 deletions
diff --git a/test/518-null-array-get/expected.txt b/test/518-null-array-get/expected.txt index e69de29bb2..ae5318e53d 100644 --- a/test/518-null-array-get/expected.txt +++ b/test/518-null-array-get/expected.txt @@ -0,0 +1,6 @@ +NullArrayFailInt2Object +NullArrayFailObject2Int +NullArraySuccessInt +NullArraySuccessInt2Float +NullArraySuccessShort +NullArraySuccessRef diff --git a/test/518-null-array-get/info.txt b/test/518-null-array-get/info.txt index 407f590b2b..71e0332e62 100644 --- a/test/518-null-array-get/info.txt +++ b/test/518-null-array-get/info.txt @@ -1,3 +1,9 @@ -Regression test for Quick and Optimizing that used -to crash on an aget-object + int-to-byte sequence -(accepted by the verifier in the case the array was null). +Codifies that the verifier should reject type-unsafe +instructions in dead code after aget on null, but pass +type-safe dead code. + +Previously verification stopped after aget on null and +punted the method to the interpreter in an effort to avoid +compiler crashes. As broken code appears very uncommon, +ensure verifier strictness and help the compilers see more +code. diff --git a/test/706-jit-skip-compilation/run b/test/518-null-array-get/smali/NullArrayFailInt2Object.smali index 6c5720a099..ca4ed10660 100644 --- a/test/706-jit-skip-compilation/run +++ b/test/518-null-array-get/smali/NullArrayFailInt2Object.smali @@ -1,12 +1,10 @@ -#!/bin/bash -# -# Copyright (C) 2016 The Android Open Source Project +# 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 +# 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, @@ -14,6 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Run without the app image, otherwise the verification results will be cached -# in the ArtMethod of the image and the test will be skewed. -exec ${RUN} "${@}" --no-app-image +# Check that the result of aget on null cannot be used as a reference. + +.class public LNullArrayFailInt2Object; + +.super Ljava/lang/Object; + +.method public static method()V + .registers 2 + const/4 v0, 0 + const/4 v1, 0 + aget v0, v0, v1 + invoke-virtual { v0 }, Ljava/lang/Object;->toString()Ljava/lang/String; + return-void +.end method diff --git a/test/518-null-array-get/smali/NullArray.smali b/test/518-null-array-get/smali/NullArrayFailObject2Int.smali index 52abc38473..83823a24e5 100644 --- a/test/518-null-array-get/smali/NullArray.smali +++ b/test/518-null-array-get/smali/NullArrayFailObject2Int.smali @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -.class public LNullArray; +# Check that the result of aget-object on null cannot be used as an integral. + +.class public LNullArrayFailObject2Int; .super Ljava/lang/Object; diff --git a/test/518-null-array-get/smali/NullArraySuccessInt.smali b/test/518-null-array-get/smali/NullArraySuccessInt.smali new file mode 100644 index 0000000000..01cf1c92ab --- /dev/null +++ b/test/518-null-array-get/smali/NullArraySuccessInt.smali @@ -0,0 +1,33 @@ +# 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. + +# Check that the result of aget on null can be used as an int. + +.class public LNullArraySuccessInt; + +.super Ljava/lang/Object; + +.method public static intMethod(I)V + .registers 1 + return-void +.end method + +.method public static method()V + .registers 2 + const/4 v0, 0 + const/4 v1, 0 + aget v0, v0, v1 + invoke-static { v0 }, LNullArraySuccessInt;->intMethod(I)V + return-void +.end method diff --git a/test/518-null-array-get/smali/NullArraySuccessInt2Float.smali b/test/518-null-array-get/smali/NullArraySuccessInt2Float.smali new file mode 100644 index 0000000000..bd59d5f68e --- /dev/null +++ b/test/518-null-array-get/smali/NullArraySuccessInt2Float.smali @@ -0,0 +1,33 @@ +# 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. + +# Check that the result of aget on null can be used as a float. + +.class public LNullArraySuccessInt2Float; + +.super Ljava/lang/Object; + +.method public static floatMethod(F)V + .registers 1 + return-void +.end method + +.method public static method()V + .registers 2 + const/4 v0, 0 + const/4 v1, 0 + aget v0, v0, v1 + invoke-static { v0 }, LNullArraySuccessInt2Float;->floatMethod(F)V + return-void +.end method diff --git a/test/518-null-array-get/smali/NullArraySuccessRef.smali b/test/518-null-array-get/smali/NullArraySuccessRef.smali new file mode 100644 index 0000000000..2f512d4089 --- /dev/null +++ b/test/518-null-array-get/smali/NullArraySuccessRef.smali @@ -0,0 +1,33 @@ +# 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. + +# Check that the result of aget-object on null can be used as a reference. + +.class public LNullArraySuccessRef; + +.super Ljava/lang/Object; + +.method public voidMethod()V + .registers 1 + return-void +.end method + +.method public static method()V + .registers 2 + const/4 v0, 0 + const/4 v1, 0 + aget-object v0, v0, v1 + invoke-virtual { v0 }, LNullArraySuccessRef;->voidMethod()V + return-void +.end method diff --git a/test/518-null-array-get/smali/NullArraySuccessShort.smali b/test/518-null-array-get/smali/NullArraySuccessShort.smali new file mode 100644 index 0000000000..d332e51f52 --- /dev/null +++ b/test/518-null-array-get/smali/NullArraySuccessShort.smali @@ -0,0 +1,33 @@ +# 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. + +# Check that the result of aget-short on null can be used as a short. + +.class public LNullArraySuccessShort; + +.super Ljava/lang/Object; + +.method public static shortMethod(S)V + .registers 1 + return-void +.end method + +.method public static method()V + .registers 2 + const/4 v0, 0 + const/4 v1, 0 + aget-short v0, v0, v1 + invoke-static { v0 }, LNullArraySuccessShort;->shortMethod(S)V + return-void +.end method diff --git a/test/518-null-array-get/src/Main.java b/test/518-null-array-get/src/Main.java index 66e50aacd7..678aef1f43 100644 --- a/test/518-null-array-get/src/Main.java +++ b/test/518-null-array-get/src/Main.java @@ -22,16 +22,36 @@ public class Main { class InnerClass {} public static void main(String[] args) throws Exception { - Class<?> c = Class.forName("NullArray"); - Method m = c.getMethod("method"); - Object[] arguments = { }; + checkLoad("NullArrayFailInt2Object", true); + checkLoad("NullArrayFailObject2Int", true); + checkLoad("NullArraySuccessInt", false); + checkLoad("NullArraySuccessInt2Float", false); + checkLoad("NullArraySuccessShort", false); + checkLoad("NullArraySuccessRef", false); + } + + private static void checkLoad(String className, boolean expectError) throws Exception { + Class<?> c; try { - m.invoke(null, arguments); - throw new Error("Expected an InvocationTargetException"); - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof NullPointerException)) { - throw new Error("Expected a NullPointerException"); + c = Class.forName(className); + if (expectError) { + throw new RuntimeException("Expected error for " + className); + } + Method m = c.getMethod("method"); + try { + m.invoke(null); + throw new RuntimeException("Expected an InvocationTargetException"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof NullPointerException)) { + throw new RuntimeException("Expected a NullPointerException"); + } + System.out.println(className); + } + } catch (VerifyError e) { + if (!expectError) { + throw new RuntimeException(e); } + System.out.println(className); } } } diff --git a/test/530-checker-lse3/expected.txt b/test/530-checker-lse3/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/530-checker-lse3/expected.txt diff --git a/test/530-checker-lse3/info.txt b/test/530-checker-lse3/info.txt new file mode 100644 index 0000000000..29b4cb82ab --- /dev/null +++ b/test/530-checker-lse3/info.txt @@ -0,0 +1,4 @@ +Regression test for load store elimination not respecting the loaded type. When +a wider value is stored in a narrower field and then loaded from that field, +LSE needs to replace the value to be stored with a type conversion to the +narrower type. diff --git a/test/530-checker-lse3/smali/StoreLoad.smali b/test/530-checker-lse3/smali/StoreLoad.smali new file mode 100644 index 0000000000..7fb582c8d1 --- /dev/null +++ b/test/530-checker-lse3/smali/StoreLoad.smali @@ -0,0 +1,62 @@ +# Copyright (C) 2017 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. + +.class public LStoreLoad; + +.super Ljava/lang/Object; + +## CHECK-START: int StoreLoad.test(int) load_store_elimination (before) +## CHECK-DAG: <<Arg:i\d+>> ParameterValue +## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField +## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField2 +## CHECK-DAG: <<Val:b\d+>> StaticFieldGet [{{l\d+}}] field_name:StoreLoad.byteField +## CHECK-DAG: <<Val2:b\d+>> StaticFieldGet [{{l\d+}}] field_name:StoreLoad.byteField2 +## CHECK-DAG: <<Val3:i\d+>> Add [<<Val>>,<<Val2>>] +## CHECK-DAG: Return [<<Val3>>] + +## CHECK-START: int StoreLoad.test(int) load_store_elimination (after) +## CHECK-NOT: StaticFieldGet + +## CHECK-START: int StoreLoad.test(int) load_store_elimination (after) +## CHECK-DAG: <<Arg:i\d+>> ParameterValue +## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField +## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField2 +## CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Arg>>] +## CHECK-DAG: <<Val3:i\d+>> Add [<<Conv>>,<<Conv>>] +## CHECK-DAG: Return [<<Val3>>] +.method public static test(I)I + .registers 2 + sput-byte v1, LStoreLoad;->byteField:B + sput-byte v1, LStoreLoad;->byteField2:B + sget-byte v0, LStoreLoad;->byteField:B + sget-byte v1, LStoreLoad;->byteField2:B + add-int/2addr v0, v1 + return v0 +.end method + +## CHECK-START: int StoreLoad.test2(int) load_store_elimination (before) +## CHECK-DAG: <<Arg:i\d+>> ParameterValue +## CHECK-DAG: StaticFieldSet [{{l\d+}},<<Arg>>] field_name:StoreLoad.byteField +## CHECK-DAG: Return [<<Arg>>] + +## CHECK-START: int StoreLoad.test2(int) load_store_elimination (after) +## CHECK-NOT: TypeConversion +.method public static test2(I)I + .registers 1 + sput-byte v0, LStoreLoad;->byteField:B + return v0 +.end method + +.field public static byteField:B +.field public static byteField2:B diff --git a/test/530-checker-lse3/src/Main.java b/test/530-checker-lse3/src/Main.java new file mode 100644 index 0000000000..caef0b33cc --- /dev/null +++ b/test/530-checker-lse3/src/Main.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 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. + */ + +import java.lang.reflect.Method; +import java.lang.reflect.Field; + +public class Main { + + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("StoreLoad"); + Method m = c.getMethod("test", int.class); + int result = (Integer)m.invoke(null, 0x12345678); + if (result != (0x78 + 0x78)) { + throw new Error("Expected 240, got " + result); + } + m = c.getMethod("test2", int.class); + result = (Integer)m.invoke(null, 0xdeadbeef); + if (result != 0xdeadbeef) { + throw new Error("Expected 0xdeadbeef, got " + result); + } + Field f = c.getDeclaredField("byteField"); + byte b = f.getByte(null); + if (b != (byte)0xef) { + throw new Error("Expected 0xef, got " + b); + } + f = c.getDeclaredField("byteField2"); + b = f.getByte(null); + if (b != (byte)0x78) { + throw new Error("Expected 0xef, got " + b); + } + } +} diff --git a/test/660-checker-simd-sad-short2/src/Main.java b/test/660-checker-simd-sad-short2/src/Main.java index 331f5ce690..274892d001 100644 --- a/test/660-checker-simd-sad-short2/src/Main.java +++ b/test/660-checker-simd-sad-short2/src/Main.java @@ -84,18 +84,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadCastedChar2Int(char[], char[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load1:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load2:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load1>>,<<Load2>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadCastedChar2Int(char[], char[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadCastedChar2Int(char[], char[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none @@ -145,18 +134,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadCastedChar2IntAlt(char[], char[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load1:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load2:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load2>>,<<Load1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadCastedChar2IntAlt(char[], char[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadCastedChar2IntAlt(char[], char[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none @@ -208,18 +186,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadCastedChar2IntAlt2(char[], char[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load1:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load2:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load1>>,<<Load2>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadCastedChar2IntAlt2(char[], char[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadCastedChar2IntAlt2(char[], char[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none @@ -276,19 +243,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: long Main.sadCastedChar2Long(char[], char[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsL:j\d+>> LongConstant 0 loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<ConsL>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load1:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load2:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load1>>,<<Load2>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: long Main.sadCastedChar2Long(char[], char[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: long Main.sadCastedChar2Long(char[], char[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsL:j\d+>> LongConstant 0 loop:none @@ -344,19 +299,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: long Main.sadCastedChar2LongAt1(char[], char[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsL:j\d+>> LongConstant 1 loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<ConsL>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load1:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load2:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load1>>,<<Load2>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: long Main.sadCastedChar2LongAt1(char[], char[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: long Main.sadCastedChar2LongAt1(char[], char[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsL:j\d+>> LongConstant 1 loop:none diff --git a/test/660-checker-simd-sad-short3/src/Main.java b/test/660-checker-simd-sad-short3/src/Main.java index ecda8848c3..5016b658e5 100644 --- a/test/660-checker-simd-sad-short3/src/Main.java +++ b/test/660-checker-simd-sad-short3/src/Main.java @@ -33,19 +33,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntParamRight(short[], short) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Param:s\d+>> ParameterValue loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<Param>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntParamRight(short[], short) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntParamRight(short[], short) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Param:s\d+>> ParameterValue loop:none @@ -76,19 +64,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntParamLeft(short[], short) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Param:s\d+>> ParameterValue loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<Param>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Rep>>,<<Load>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntParamLeft(short[], short) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntParamLeft(short[], short) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Param:s\d+>> ParameterValue loop:none @@ -119,19 +95,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntConstRight(short[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 32767 loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<ConsI>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntConstRight(short[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntConstRight(short[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 32767 loop:none @@ -162,19 +126,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntConstLeft(short[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 32767 loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<ConsI>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Rep>>,<<Load>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntConstLeft(short[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntConstLeft(short[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 32767 loop:none @@ -205,19 +157,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntInvariantRight(short[], int) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [{{i\d+}}] loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<Conv>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntInvariantRight(short[], int) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntInvariantRight(short[], int) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [{{i\d+}}] loop:none @@ -249,18 +189,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntInvariantLeft(short[], int) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [{{i\d+}}] loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<Conv>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Rep>>,<<Load>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntInvariantLeft(short[], int) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntInvariantLeft(short[], int) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [{{i\d+}}] loop:none @@ -270,6 +199,7 @@ public class Main { /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Rep>>,<<Load>>] loop:<<Loop>> outer_loop:none + /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none private static int sadShort2IntInvariantLeft(short[] s, int val) { int sad = 0; short x = (short) (val + 1); @@ -293,19 +223,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntCastedExprRight(short[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 110 loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<ConsI>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Add:d\d+>> VecAdd [<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load>>,<<Add>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntCastedExprRight(short[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntCastedExprRight(short[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 110 loop:none @@ -316,6 +234,7 @@ public class Main { /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<Add:d\d+>> VecAdd [<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Load>>,<<Add>>] loop:<<Loop>> outer_loop:none + /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none private static int sadShort2IntCastedExprRight(short[] s) { int sad = 0; for (int i = 0; i < s.length; i++) { @@ -339,19 +258,7 @@ public class Main { /// CHECK-DAG: Add [<<Phi2>>,<<Intrin>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: Add [<<Phi1>>,<<Cons1>>] loop:<<Loop>> outer_loop:none // - /// CHECK-START-ARM64: int Main.sadShort2IntCastedExprLeft(short[]) loop_optimization (after) - /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none - /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none - /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 110 loop:none - /// CHECK-DAG: <<Rep:d\d+>> VecReplicateScalar [<<ConsI>>] loop:none - /// CHECK-DAG: <<Set:d\d+>> VecSetScalars [<<Cons0>>] loop:none - /// CHECK-DAG: <<Phi1:i\d+>> Phi [<<Cons0>>,{{i\d+}}] loop:<<Loop:B\d+>> outer_loop:none - /// CHECK-DAG: <<Phi2:d\d+>> Phi [<<Set>>,{{d\d+}}] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<Add:d\d+>> VecAdd [<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none - /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Add>>,<<Load>>] loop:<<Loop>> outer_loop:none - // - /// CHECK-START-MIPS64: int Main.sadShort2IntCastedExprLeft(short[]) loop_optimization (after) + /// CHECK-START-{ARM64,MIPS64}: int Main.sadShort2IntCastedExprLeft(short[]) loop_optimization (after) /// CHECK-DAG: <<Cons0:i\d+>> IntConstant 0 loop:none /// CHECK-DAG: <<Cons8:i\d+>> IntConstant 8 loop:none /// CHECK-DAG: <<ConsI:i\d+>> IntConstant 110 loop:none @@ -362,6 +269,7 @@ public class Main { /// CHECK-DAG: <<Load:d\d+>> VecLoad [{{l\d+}},<<Phi1>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<Add:d\d+>> VecAdd [<<Load>>,<<Rep>>] loop:<<Loop>> outer_loop:none /// CHECK-DAG: <<SAD:d\d+>> VecSADAccumulate [<<Phi2>>,<<Add>>,<<Load>>] loop:<<Loop>> outer_loop:none + /// CHECK-DAG: Add [<<Phi1>>,<<Cons8>>] loop:<<Loop>> outer_loop:none private static int sadShort2IntCastedExprLeft(short[] s) { int sad = 0; for (int i = 0; i < s.length; i++) { diff --git a/test/706-jit-skip-compilation/expected.txt b/test/706-jit-skip-compilation/expected.txt deleted file mode 100644 index 6a5618ebc6..0000000000 --- a/test/706-jit-skip-compilation/expected.txt +++ /dev/null @@ -1 +0,0 @@ -JNI_OnLoad called diff --git a/test/706-jit-skip-compilation/info.txt b/test/706-jit-skip-compilation/info.txt deleted file mode 100644 index e9ef86bfb3..0000000000 --- a/test/706-jit-skip-compilation/info.txt +++ /dev/null @@ -1,4 +0,0 @@ -Regression test for the JIT crashing when compiling a method with invalid -dead dex code. For not compilable methods we don't gather samples and we don't -trigger JIT compilation. However kAccDontBotherCompile is not persisted in the -oat file and so we may end up compiling a method which we shouldn't. diff --git a/test/706-jit-skip-compilation/smali/errclass.smali b/test/706-jit-skip-compilation/smali/errclass.smali deleted file mode 100644 index 410504cb2f..0000000000 --- a/test/706-jit-skip-compilation/smali/errclass.smali +++ /dev/null @@ -1,34 +0,0 @@ -# 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. - - -.class public LErrClass; - -.super Ljava/lang/Object; - -.method public static errMethod()J - .registers 8 - const/4 v0, 0x0 - const/4 v3, 0x0 - aget v1, v0, v3 # v0 is null, this will alays throw and the invalid code - # below will not be verified. - move v3, v4 - move-wide/from16 v6, v2 # should trigger a verification error if verified as - # v3 is a single register but used as a pair here. - return v6 -.end method - -# Add a field to work around demerger bug b/18051191. -# Failure to verify dex file '...': Offset(552) should be zero when size is zero for field-ids. -.field private a:I diff --git a/test/706-jit-skip-compilation/src/Main.java b/test/706-jit-skip-compilation/src/Main.java deleted file mode 100644 index aa847248d6..0000000000 --- a/test/706-jit-skip-compilation/src/Main.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class Main { - public static void main(String[] args) throws Exception { - System.loadLibrary(args[0]); - Class<?> c = Class.forName("ErrClass"); - Method m = c.getMethod("errMethod"); - - // Print the counter before invokes. The golden file expects this to be 0. - int hotnessCounter = getHotnessCounter(c, "errMethod"); - if (hotnessCounter != 0) { - throw new RuntimeException("Unexpected hotnessCounter: " + hotnessCounter); - } - - // Loop enough to make sure the interpreter reports invocations count. - long result = 0; - for (int i = 0; i < 10000; i++) { - try { - result += (Long)m.invoke(null); - hotnessCounter = getHotnessCounter(c, "errMethod"); - if (hotnessCounter != 0) { - throw new RuntimeException( - "Unexpected hotnessCounter: " + hotnessCounter); - } - - } catch (InvocationTargetException e) { - if (!(e.getCause() instanceof NullPointerException)) { - throw e; - } - } - } - - // Not compilable methods should not increase their hotness counter. - if (hotnessCounter != 0) { - throw new RuntimeException("Unexpected hotnessCounter: " + hotnessCounter); - } - } - - public static native int getHotnessCounter(Class cls, String method_name); -} diff --git a/test/711-checker-type-conversion/src/Main.java b/test/711-checker-type-conversion/src/Main.java index 2c9c3a157e..ae58200b1b 100644 --- a/test/711-checker-type-conversion/src/Main.java +++ b/test/711-checker-type-conversion/src/Main.java @@ -22,6 +22,32 @@ public class Main { } } + public static void assertShortEquals(short expected, short result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void assertIntEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void assertLongEquals(long expected, long result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void assertCharEquals(char expected, char result) { + if (expected != result) { + // Values are cast to int to display numeric values instead of + // (UTF-16 encoded) characters. + throw new Error("Expected: " + (int)expected + ", found: " + (int)result); + } + } + /// CHECK-START: byte Main.getByte1() constant_folding (before) /// CHECK: TypeConversion /// CHECK: TypeConversion @@ -69,9 +95,170 @@ public class Main { return (byte)((byte)i + (byte)i); } + static byte byteVal = -1; + static short shortVal = -1; + static char charVal = 0xffff; + static int intVal = -1; + + static byte[] byteArr = { 0 }; + static short[] shortArr = { 0 }; + static char[] charArr = { 0 }; + static int[] intArr = { 0 }; + + static byte $noinline$getByte() { + return byteVal; + } + + static short $noinline$getShort() { + return shortVal; + } + + static char $noinline$getChar() { + return charVal; + } + + static int $noinline$getInt() { + return intVal; + } + + static boolean sFlag = true; + + /// CHECK-START: void Main.byteToShort() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void byteToShort() { + shortArr[0] = 0; + if (sFlag) { + shortArr[0] = $noinline$getByte(); + } + } + + /// CHECK-START: void Main.byteToChar() instruction_simplifier$before_codegen (after) + /// CHECK: TypeConversion + private static void byteToChar() { + charArr[0] = 0; + if (sFlag) { + charArr[0] = (char)$noinline$getByte(); + } + } + + /// CHECK-START: void Main.byteToInt() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void byteToInt() { + intArr[0] = 0; + if (sFlag) { + intArr[0] = $noinline$getByte(); + } + } + + /// CHECK-START: void Main.charToByte() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void charToByte() { + byteArr[0] = 0; + if (sFlag) { + byteArr[0] = (byte)$noinline$getChar(); + } + } + + /// CHECK-START: void Main.charToShort() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void charToShort() { + shortArr[0] = 0; + if (sFlag) { + shortArr[0] = (short)$noinline$getChar(); + } + } + + /// CHECK-START: void Main.charToInt() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void charToInt() { + intArr[0] = 0; + if (sFlag) { + intArr[0] = $noinline$getChar(); + } + } + + /// CHECK-START: void Main.shortToByte() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void shortToByte() { + byteArr[0] = 0; + if (sFlag) { + byteArr[0] = (byte)$noinline$getShort(); + } + } + + /// CHECK-START: void Main.shortToChar() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void shortToChar() { + charArr[0] = 0; + if (sFlag) { + charArr[0] = (char)$noinline$getShort(); + } + } + + /// CHECK-START: void Main.shortToInt() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void shortToInt() { + intArr[0] = 0; + if (sFlag) { + intArr[0] = $noinline$getShort(); + } + } + + /// CHECK-START: void Main.intToByte() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void intToByte() { + byteArr[0] = 0; + if (sFlag) { + byteArr[0] = (byte)$noinline$getInt(); + } + } + + /// CHECK-START: void Main.intToShort() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void intToShort() { + shortArr[0] = 0; + if (sFlag) { + shortArr[0] = (short)$noinline$getInt(); + } + } + + /// CHECK-START: void Main.intToChar() instruction_simplifier$before_codegen (after) + /// CHECK-NOT: TypeConversion + private static void intToChar() { + charArr[0] = 0; + if (sFlag) { + charArr[0] = (char)$noinline$getInt(); + } + } + public static void main(String[] args) { assertByteEquals(getByte1(), (byte)-5); assertByteEquals(getByte2(), (byte)(-201)); assertByteEquals(getByte3(), (byte)(0xcd + 0xcd)); + + byteToShort(); + assertShortEquals(shortArr[0], (short)-1); + byteToChar(); + assertCharEquals(charArr[0], (char)-1); + byteToInt(); + assertIntEquals(intArr[0], -1); + charToByte(); + assertByteEquals(byteArr[0], (byte)-1); + charToShort(); + assertShortEquals(shortArr[0], (short)-1); + charToInt(); + assertIntEquals(intArr[0], 0xffff); + shortToByte(); + assertByteEquals(byteArr[0], (byte)-1); + shortToChar(); + assertCharEquals(charArr[0], (char)-1); + shortToInt(); + assertIntEquals(intArr[0], -1); + intToByte(); + assertByteEquals(byteArr[0], (byte)-1); + intToShort(); + assertShortEquals(shortArr[0], (short)-1); + intToChar(); + assertCharEquals(charArr[0], (char)-1); } } |