diff options
Diffstat (limited to 'test')
27 files changed, 608 insertions, 15 deletions
diff --git a/test/080-oom-throw-with-finalizer/expected.txt b/test/080-oom-throw-with-finalizer/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/080-oom-throw-with-finalizer/expected.txt diff --git a/test/080-oom-throw-with-finalizer/info.txt b/test/080-oom-throw-with-finalizer/info.txt new file mode 100644 index 0000000000..37091ef935 --- /dev/null +++ b/test/080-oom-throw-with-finalizer/info.txt @@ -0,0 +1 @@ +Regression test on correct processing of OOM thrown while adding a finalizer reference. diff --git a/test/080-oom-throw-with-finalizer/src/Main.java b/test/080-oom-throw-with-finalizer/src/Main.java new file mode 100644 index 0000000000..57e972139d --- /dev/null +++ b/test/080-oom-throw-with-finalizer/src/Main.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2014 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.util.Vector; + +public class Main { + static char [][] holder; + + static class ArrayMemEater { + static boolean sawOome; + + static void blowup(char[][] holder) { + try { + for (int i = 0; i < holder.length; ++i) { + holder[i] = new char[1024 * 1024]; + } + } catch (OutOfMemoryError oome) { + ArrayMemEater.sawOome = true; + } + } + } + + static class InstanceFinalizerMemEater { + public void finalize() {} + } + + static boolean triggerArrayOOM(char[][] holder) { + ArrayMemEater.blowup(holder); + return ArrayMemEater.sawOome; + } + + static boolean triggerInstanceFinalizerOOM() { + boolean sawOome = false; + try { + Vector v = new Vector(); + while (true) { + v.add(new InstanceFinalizerMemEater()); + } + } catch (OutOfMemoryError e) { + sawOome = true; + } + return sawOome; + } + + public static void main(String[] args) { + // Keep holder alive to make instance OOM happen faster. + holder = new char[128 * 1024][]; + if (!triggerArrayOOM(holder)) { + System.out.println("NEW_ARRAY did not throw OOME"); + } + + if (!triggerInstanceFinalizerOOM()) { + System.out.println("NEW_INSTANCE (finalize) did not throw OOME"); + } + + System.runFinalization(); + } +} diff --git a/test/415-optimizing-arith-neg/src/Main.java b/test/415-optimizing-arith-neg/src/Main.java index d9f8bcf0c2..bd8a1583d5 100644 --- a/test/415-optimizing-arith-neg/src/Main.java +++ b/test/415-optimizing-arith-neg/src/Main.java @@ -36,12 +36,24 @@ public class Main { } } + public static void assertEquals(String expected, float result) { + if (!expected.equals(new Float(result).toString())) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + public static void assertEquals(double expected, double result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } + public static void assertEquals(String expected, double result) { + if (!expected.equals(new Double(result).toString())) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + public static void assertIsNaN(float result) { if (!Float.isNaN(result)) { throw new Error("Expected NaN: " + result); @@ -116,9 +128,10 @@ public class Main { } private static void negFloat() { + assertEquals("-0.0", $opt$NegFloat(0F)); + assertEquals("0.0", $opt$NegFloat(-0F)); assertEquals(-1F, $opt$NegFloat(1F)); assertEquals(1F, $opt$NegFloat(-1F)); - assertEquals(0F, $opt$NegFloat(0F)); assertEquals(51F, $opt$NegFloat(-51F)); assertEquals(-51F, $opt$NegFloat(51F)); @@ -140,9 +153,10 @@ public class Main { } private static void negDouble() { + assertEquals("-0.0", $opt$NegDouble(0D)); + assertEquals("0.0", $opt$NegDouble(-0D)); assertEquals(-1D, $opt$NegDouble(1D)); assertEquals(1D, $opt$NegDouble(-1D)); - assertEquals(0D, $opt$NegDouble(0D)); assertEquals(51D, $opt$NegDouble(-51D)); assertEquals(-51D, $opt$NegDouble(51D)); diff --git a/test/421-large-frame/src/Main.java b/test/421-large-frame/src/Main.java index 01b89bab8e..dae72fbddc 100644 --- a/test/421-large-frame/src/Main.java +++ b/test/421-large-frame/src/Main.java @@ -2029,6 +2029,11 @@ public class Main { l997 += l996; l998 += l997; l999 += l998; - return l999; + // Create a branch to beat the large method check. + if (l998 == l999) { + return l998; + } else { + return l999; + } } } diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java index 37bc7779bd..c434db37c9 100644 --- a/test/422-type-conversion/src/Main.java +++ b/test/422-type-conversion/src/Main.java @@ -85,6 +85,12 @@ public class Main { // Generate, compile and check long-to-int Dex instructions. longToInt(); + // Generate, compile and check long-to-float Dex instructions. + longToFloat(); + + // Generate, compile and check long-to-double Dex instructions. + longToDouble(); + // Generate, compile and check int-to-byte Dex instructions. shortToByte(); intToByte(); @@ -267,6 +273,46 @@ public class Main { assertLongEquals(-1, $opt$IntToLong($opt$LongToInt(-4294967297L))); // -(2^32 + 1) } + private static void longToFloat() { + assertFloatEquals(1F, $opt$LongToFloat(1L)); + assertFloatEquals(0F, $opt$LongToFloat(0L)); + assertFloatEquals(-1F, $opt$LongToFloat(-1L)); + assertFloatEquals(51F, $opt$LongToFloat(51L)); + assertFloatEquals(-51F, $opt$LongToFloat(-51L)); + assertFloatEquals(2147483647F, $opt$LongToFloat(2147483647L)); // 2^31 - 1 + assertFloatEquals(-2147483647F, $opt$LongToFloat(-2147483647L)); // -(2^31 - 1) + assertFloatEquals(-2147483648F, $opt$LongToFloat(-2147483648L)); // -(2^31) + assertFloatEquals(2147483648F, $opt$LongToFloat(2147483648L)); // (2^31) + assertFloatEquals(-2147483649F, $opt$LongToFloat(-2147483649L)); // -(2^31 + 1) + assertFloatEquals(4294967296F, $opt$LongToFloat(4294967296L)); // (2^32) + assertFloatEquals(-4294967296F, $opt$LongToFloat(-4294967296L)); // -(2^32) + assertFloatEquals(140739635871745F, $opt$LongToFloat(140739635871745L)); // 1 + 2^15 + 2^31 + 2^47 + assertFloatEquals(-140739635871745F, $opt$LongToFloat(-140739635871745L)); // -(1 + 2^15 + 2^31 + 2^47) + assertFloatEquals(9223372036854775807F, $opt$LongToFloat(9223372036854775807L)); // 2^63 - 1 + assertFloatEquals(-9223372036854775807F, $opt$LongToFloat(-9223372036854775807L)); // -(2^63 - 1) + assertFloatEquals(-9223372036854775808F, $opt$LongToFloat(-9223372036854775808L)); // -(2^63) + } + + private static void longToDouble() { + assertDoubleEquals(1D, $opt$LongToDouble(1L)); + assertDoubleEquals(0D, $opt$LongToDouble(0L)); + assertDoubleEquals(-1D, $opt$LongToDouble(-1L)); + assertDoubleEquals(51D, $opt$LongToDouble(51L)); + assertDoubleEquals(-51D, $opt$LongToDouble(-51L)); + assertDoubleEquals(2147483647D, $opt$LongToDouble(2147483647L)); // 2^31 - 1 + assertDoubleEquals(-2147483647D, $opt$LongToDouble(-2147483647L)); // -(2^31 - 1) + assertDoubleEquals(-2147483648D, $opt$LongToDouble(-2147483648L)); // -(2^31) + assertDoubleEquals(2147483648D, $opt$LongToDouble(2147483648L)); // (2^31) + assertDoubleEquals(-2147483649D, $opt$LongToDouble(-2147483649L)); // -(2^31 + 1) + assertDoubleEquals(4294967296D, $opt$LongToDouble(4294967296L)); // (2^32) + assertDoubleEquals(-4294967296D, $opt$LongToDouble(-4294967296L)); // -(2^32) + assertDoubleEquals(140739635871745D, $opt$LongToDouble(140739635871745L)); // 1 + 2^15 + 2^31 + 2^47 + assertDoubleEquals(-140739635871745D, $opt$LongToDouble(-140739635871745L)); // -(1 + 2^15 + 2^31 + 2^47) + assertDoubleEquals(9223372036854775807D, $opt$LongToDouble(9223372036854775807L)); // 2^63 - 1 + assertDoubleEquals(-9223372036854775807D, $opt$LongToDouble(-9223372036854775807L)); // -(2^63 - 1) + assertDoubleEquals(-9223372036854775808D, $opt$LongToDouble(-9223372036854775808L)); // -(2^63) + } + private static void shortToByte() { assertByteEquals((byte)1, $opt$ShortToByte((short)1)); assertByteEquals((byte)0, $opt$ShortToByte((short)0)); @@ -416,6 +462,12 @@ public class Main { static int $opt$LongToInt(long a){ return (int)a; } static int $opt$LongLiteralToInt(){ return (int)42L; } + // This method produces a long-to-float Dex instruction. + static float $opt$LongToFloat(long a){ return (float)a; } + + // This method produces a long-to-double Dex instruction. + static double $opt$LongToDouble(long a){ return (double)a; } + // These methods produce int-to-byte Dex instructions. static byte $opt$ShortToByte(short a){ return (byte)a; } static byte $opt$IntToByte(int a){ return (byte)a; } diff --git a/test/432-optimizing-cmp/expected.txt b/test/432-optimizing-cmp/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/432-optimizing-cmp/expected.txt diff --git a/test/432-optimizing-cmp/info.txt b/test/432-optimizing-cmp/info.txt new file mode 100644 index 0000000000..fad6cee729 --- /dev/null +++ b/test/432-optimizing-cmp/info.txt @@ -0,0 +1 @@ +Tests for compare operations. diff --git a/test/432-optimizing-cmp/smali/cmp.smali b/test/432-optimizing-cmp/smali/cmp.smali new file mode 100644 index 0000000000..470d940e38 --- /dev/null +++ b/test/432-optimizing-cmp/smali/cmp.smali @@ -0,0 +1,33 @@ +.class public LTestCmp; + +.super Ljava/lang/Object; + +.method public static $opt$CmpLong(JJ)I + .registers 5 + cmp-long v0, v1, v3 + return v0 +.end method + +.method public static $opt$CmpGtFloat(FF)I + .registers 3 + cmpg-float v0, v1, v2 + return v0 +.end method + +.method public static $opt$CmpLtFloat(FF)I + .registers 3 + cmpl-float v0, v1, v2 + return v0 +.end method + +.method public static $opt$CmpGtDouble(DD)I + .registers 5 + cmpg-double v0, v1, v3 + return v0 +.end method + +.method public static $opt$CmpLtDouble(DD)I + .registers 5 + cmpl-double v0, v1, v3 + return v0 +.end method diff --git a/test/432-optimizing-cmp/src/Main.java b/test/432-optimizing-cmp/src/Main.java new file mode 100644 index 0000000000..3c7b13fc64 --- /dev/null +++ b/test/432-optimizing-cmp/src/Main.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2014 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; + +public class Main { + + public static void main(String[] args) throws Exception { + cmpLong(); + cmpFloat(); + cmpDouble(); + } + + private static void cmpLong() throws Exception { + expectLt(3L, 5L); + expectGt(5L, 3L); + expectLt(Long.MIN_VALUE, Long.MAX_VALUE); + expectGt(Long.MAX_VALUE, Long.MIN_VALUE); + + expectEquals(0, smaliCmpLong(0L, 0L)); + expectEquals(0, smaliCmpLong(1L, 1L)); + expectEquals(-1, smaliCmpLong(1L, 2L)); + expectEquals(1, smaliCmpLong(2L, 1L)); + expectEquals(-1, smaliCmpLong(Long.MIN_VALUE, Long.MAX_VALUE)); + expectEquals(1, smaliCmpLong(Long.MAX_VALUE, Long.MIN_VALUE)); + expectEquals(0, smaliCmpLong(Long.MIN_VALUE, Long.MIN_VALUE)); + expectEquals(0, smaliCmpLong(Long.MAX_VALUE, Long.MAX_VALUE)); + } + + private static void cmpFloat() throws Exception { + expectLt(3.1F, 5.1F); + expectGt(5.1F, 3.1F); + expectLt(Float.MIN_VALUE, Float.MAX_VALUE); + expectGt(Float.MAX_VALUE, Float.MIN_VALUE); + expectFalse(3.1F, Float.NaN); + expectFalse(Float.NaN, 3.1F); + + expectEquals(0, smaliCmpGtFloat(0F, 0F)); + expectEquals(0, smaliCmpGtFloat(1F, 1F)); + expectEquals(-1, smaliCmpGtFloat(1.1F, 2.1F)); + expectEquals(1, smaliCmpGtFloat(2.1F, 1.1F)); + expectEquals(-1, smaliCmpGtFloat(Float.MIN_VALUE, Float.MAX_VALUE)); + expectEquals(1, smaliCmpGtFloat(Float.MAX_VALUE, Float.MIN_VALUE)); + expectEquals(0, smaliCmpGtFloat(Float.MIN_VALUE, Float.MIN_VALUE)); + expectEquals(0, smaliCmpGtFloat(Float.MAX_VALUE, Float.MAX_VALUE)); + expectEquals(1, smaliCmpGtFloat(5F, Float.NaN)); + expectEquals(1, smaliCmpGtFloat(Float.NaN, 5F)); + + expectEquals(0, smaliCmpLtFloat(0F, 0F)); + expectEquals(0, smaliCmpLtFloat(1F, 1F)); + expectEquals(-1, smaliCmpLtFloat(1.1F, 2.1F)); + expectEquals(1, smaliCmpLtFloat(2.1F, 1.1F)); + expectEquals(-1, smaliCmpLtFloat(Float.MIN_VALUE, Float.MAX_VALUE)); + expectEquals(1, smaliCmpLtFloat(Float.MAX_VALUE, Float.MIN_VALUE)); + expectEquals(0, smaliCmpLtFloat(Float.MIN_VALUE, Float.MIN_VALUE)); + expectEquals(0, smaliCmpLtFloat(Float.MAX_VALUE, Float.MAX_VALUE)); + expectEquals(-1, smaliCmpLtFloat(5F, Float.NaN)); + expectEquals(-1, smaliCmpLtFloat(Float.NaN, 5F)); + } + + private static void cmpDouble() throws Exception { + expectLt(3.1D, 5.1D); + expectGt(5.1D, 3.1D); + expectLt(Double.MIN_VALUE, Double.MAX_VALUE); + expectGt(Double.MAX_VALUE, Double.MIN_VALUE); + expectFalse(3.1D, Double.NaN); + expectFalse(Double.NaN, 3.1D); + + expectEquals(0, smaliCmpGtDouble(0D, 0D)); + expectEquals(0, smaliCmpGtDouble(1D, 1D)); + expectEquals(-1, smaliCmpGtDouble(1.1D, 2.1D)); + expectEquals(1, smaliCmpGtDouble(2.1D, 1.1D)); + expectEquals(-1, smaliCmpGtDouble(Double.MIN_VALUE, Double.MAX_VALUE)); + expectEquals(1, smaliCmpGtDouble(Double.MAX_VALUE, Double.MIN_VALUE)); + expectEquals(0, smaliCmpGtDouble(Double.MIN_VALUE, Double.MIN_VALUE)); + expectEquals(0, smaliCmpGtDouble(Double.MAX_VALUE, Double.MAX_VALUE)); + expectEquals(1, smaliCmpGtDouble(5D, Double.NaN)); + expectEquals(1, smaliCmpGtDouble(Double.NaN, 5D)); + + expectEquals(0, smaliCmpLtDouble(0D, 0D)); + expectEquals(0, smaliCmpLtDouble(1D, 1D)); + expectEquals(-1, smaliCmpLtDouble(1.1D, 2.1D)); + expectEquals(1, smaliCmpLtDouble(2.1D, 1.1D)); + expectEquals(-1, smaliCmpLtDouble(Double.MIN_VALUE, Double.MAX_VALUE)); + expectEquals(1, smaliCmpLtDouble(Double.MAX_VALUE, Double.MIN_VALUE)); + expectEquals(0, smaliCmpLtDouble(Double.MIN_VALUE, Double.MIN_VALUE)); + expectEquals(0, smaliCmpLtDouble(Double.MAX_VALUE, Double.MAX_VALUE)); + expectEquals(-1, smaliCmpLtDouble(5D, Double.NaN)); + expectEquals(-1, smaliCmpLtDouble(Float.NaN, 5D)); + } + + static boolean $opt$lt(long a, long b) { + return a < b; + } + + static boolean $opt$lt(float a, float b) { + return a < b; + } + + static boolean $opt$lt(double a, double b) { + return a < b; + } + + static boolean $opt$gt(long a, long b) { + return a > b; + } + + static boolean $opt$gt(float a, float b) { + return a > b; + } + + static boolean $opt$gt(double a, double b) { + return a > b; + } + + // Wrappers around methods located in file cmp.smali. + + private static int smaliCmpLong(long a, long b) throws Exception { + Class<?> c = Class.forName("TestCmp"); + Method m = c.getMethod("$opt$CmpLong", long.class, long.class); + int result = (Integer)m.invoke(null, a, b); + return result; + } + + private static int smaliCmpGtFloat(float a, float b) throws Exception { + Class<?> c = Class.forName("TestCmp"); + Method m = c.getMethod("$opt$CmpGtFloat", float.class, float.class); + int result = (Integer)m.invoke(null, a, b); + return result; + } + + private static int smaliCmpLtFloat(float a, float b) throws Exception { + Class<?> c = Class.forName("TestCmp"); + Method m = c.getMethod("$opt$CmpLtFloat", float.class, float.class); + int result = (Integer)m.invoke(null, a, b); + return result; + } + + private static int smaliCmpGtDouble(double a, double b) throws Exception { + Class<?> c = Class.forName("TestCmp"); + Method m = c.getMethod("$opt$CmpGtDouble", double.class, double.class); + int result = (Integer)m.invoke(null, a, b); + return result; + } + + private static int smaliCmpLtDouble(double a, double b) throws Exception { + Class<?> c = Class.forName("TestCmp"); + Method m = c.getMethod("$opt$CmpLtDouble", double.class, double.class); + int result = (Integer)m.invoke(null, a, b); + return result; + } + + public static void expectEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } + + public static void expectLt(long a, long b) { + if (!$opt$lt(a, b)) { + throw new Error("Expected: " + a + " < " + b); + } + } + + public static void expectGt(long a, long b) { + if (!$opt$gt(a, b)) { + throw new Error("Expected: " + a + " > " + b); + } + } + + public static void expectLt(float a, float b) { + if (!$opt$lt(a, b)) { + throw new Error("Expected: " + a + " < " + b); + } + } + + public static void expectGt(float a, float b) { + if (!$opt$gt(a, b)) { + throw new Error("Expected: " + a + " > " + b); + } + } + + public static void expectFalse(float a, float b) { + if ($opt$lt(a, b)) { + throw new Error("Not expecting: " + a + " < " + b); + } + if ($opt$gt(a, b)) { + throw new Error("Not expecting: " + a + " > " + b); + } + } + + public static void expectLt(double a, double b) { + if (!$opt$lt(a, b)) { + throw new Error("Expected: " + a + " < " + b); + } + } + + public static void expectGt(double a, double b) { + if (!$opt$gt(a, b)) { + throw new Error("Expected: " + a + " > " + b); + } + } + + public static void expectFalse(double a, double b) { + if ($opt$lt(a, b)) { + throw new Error("Not expecting: " + a + " < " + b); + } + if ($opt$gt(a, b)) { + throw new Error("Not expecting: " + a + " > " + b); + } + } + +} + diff --git a/test/433-gvn/expected.txt b/test/433-gvn/expected.txt new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/433-gvn/expected.txt @@ -0,0 +1 @@ +42 diff --git a/test/433-gvn/info.txt b/test/433-gvn/info.txt new file mode 100644 index 0000000000..bcdab152d3 --- /dev/null +++ b/test/433-gvn/info.txt @@ -0,0 +1,3 @@ +Regression test for the optimizing compiler's GVN, that +used to not take into account all side effects between +a dominator and its dominated blocks. diff --git a/test/433-gvn/src/Main.java b/test/433-gvn/src/Main.java new file mode 100644 index 0000000000..f9cb59434e --- /dev/null +++ b/test/433-gvn/src/Main.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 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) { + System.out.println(foo()); + } + + public static int foo() { + Main m = new Main(); + int a = m.field; + if (a == 0) { + m.field = 42; + if (m.test) { + a = 3; + } + } + // The compiler used to GVN this field get with the one line 24, + // even though the field is updated in the if. + return m.field; + } + + public int field; + public boolean test = true; +} diff --git a/test/434-invoke-direct/expected.txt b/test/434-invoke-direct/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/434-invoke-direct/expected.txt diff --git a/test/434-invoke-direct/info.txt b/test/434-invoke-direct/info.txt new file mode 100644 index 0000000000..eae1ef03e8 --- /dev/null +++ b/test/434-invoke-direct/info.txt @@ -0,0 +1,2 @@ +Tests that IllegalAccessError is thrown when a subclass invokes-direct a +private method from the super class. diff --git a/test/434-invoke-direct/smali/invoke.smali b/test/434-invoke-direct/smali/invoke.smali new file mode 100644 index 0000000000..b3cdd1e228 --- /dev/null +++ b/test/434-invoke-direct/smali/invoke.smali @@ -0,0 +1,30 @@ +# +# Copyright (C) 2014 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 LInvokeDirect; +.super LInvokeDirectSuper; + +.method public constructor <init>()V + .registers 2 + invoke-direct {v1}, LInvokeDirectSuper;-><init>()V + return-void +.end method + +.method public run()I + .registers 3 + invoke-super {v2}, LInvokeDirectSuper;->privateMethod()I + move-result v0 + return v0 +.end method diff --git a/test/434-invoke-direct/src/InvokeDirectSuper.java b/test/434-invoke-direct/src/InvokeDirectSuper.java new file mode 100644 index 0000000000..c80a18b6e7 --- /dev/null +++ b/test/434-invoke-direct/src/InvokeDirectSuper.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2014 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 InvokeDirectSuper { + public int val; + + private int privateMethod() { + return val; + } +} diff --git a/test/434-invoke-direct/src/Main.java b/test/434-invoke-direct/src/Main.java new file mode 100644 index 0000000000..c363e1a5a2 --- /dev/null +++ b/test/434-invoke-direct/src/Main.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2014 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 Throwable { + $opt$InvokeDirect(); + } + + private static void $opt$InvokeDirect() throws Throwable { + try { + Class<?> c = Class.forName("InvokeDirect"); + Method m = c.getMethod("run"); + m.invoke(c.newInstance()); + throw new RuntimeException("Failed to throw IllegalAccessError"); + } catch (InvocationTargetException e) { + if (!(e.getCause() instanceof IllegalAccessError)) { + throw new RuntimeException("Failed to throw IllegalAccessError"); + } + } + } + +} + diff --git a/test/434-shifter-operand/expected.txt b/test/434-shifter-operand/expected.txt new file mode 100644 index 0000000000..52289c68f9 --- /dev/null +++ b/test/434-shifter-operand/expected.txt @@ -0,0 +1,3 @@ +false +false +true diff --git a/test/434-shifter-operand/info.txt b/test/434-shifter-operand/info.txt new file mode 100644 index 0000000000..1ec9adc5ab --- /dev/null +++ b/test/434-shifter-operand/info.txt @@ -0,0 +1,2 @@ +Regression test for the arm backend of the optimizing +compiler, that used to misuse ShifterOperand::CanHold. diff --git a/test/434-shifter-operand/src/Main.java b/test/434-shifter-operand/src/Main.java new file mode 100644 index 0000000000..4d188eb4f7 --- /dev/null +++ b/test/434-shifter-operand/src/Main.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2014 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) { + System.out.println(foo(42)); + System.out.println(foo(0xffffffff)); + System.out.println(foo(0xf0000000)); + } + + public static boolean foo(int a) { + return a < 0xf000000b; + } +} diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt index 7ec3168822..0f7001fc68 100644 --- a/test/800-smali/expected.txt +++ b/test/800-smali/expected.txt @@ -7,4 +7,5 @@ sameFieldNames b/18380491 invoke-super abstract BadCaseInOpRegRegReg +CmpLong Done! diff --git a/test/800-smali/smali/CmpLong.smali b/test/800-smali/smali/CmpLong.smali new file mode 100644 index 0000000000..d54812f878 --- /dev/null +++ b/test/800-smali/smali/CmpLong.smali @@ -0,0 +1,18 @@ +.class public LCmpLong; +.super Ljava/lang/Object; + + +.method public constructor <init>()V +.registers 1 + invoke-direct {p0}, Ljava/lang/Object;-><init>()V + return-void +.end method + +.method public static run()I +.registers 5000 + const-wide v100, 5678233453L + move-wide/from16 v101, v100 + const-wide v4, 5678233453L + cmp-long v0, v101, v4 + return v0 +.end method diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java index abb53de664..f2c1ab57e7 100644 --- a/test/800-smali/src/Main.java +++ b/test/800-smali/src/Main.java @@ -63,6 +63,7 @@ public class Main { testCases.add(new TestCase("invoke-super abstract", "B18380491ConcreteClass", "foo", new Object[]{0}, new AbstractMethodError(), null)); testCases.add(new TestCase("BadCaseInOpRegRegReg", "BadCaseInOpRegRegReg", "getInt", null, null, 2)); + testCases.add(new TestCase("CmpLong", "CmpLong", "run", null, null, 0)); } public void runTests() { diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index 47d186a479..3c959fbcb3 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -299,15 +299,11 @@ TEST_ART_BROKEN_DEFAULT_RUN_TESTS := # Known broken tests for the arm64 optimizing compiler backend. TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS := \ 003-omnibus-opcodes \ - 004-NativeAllocations \ 004-ReferenceMap \ 005-annotations \ 009-instanceof \ 010-instance \ - 012-math \ 023-many-interfaces \ - 027-arithmetic \ - 037-inherit \ 044-proxy \ 045-reflect-array \ 046-reflect \ @@ -317,21 +313,15 @@ TEST_ART_BROKEN_OPTIMIZING_ARM64_RUN_TESTS := \ 068-classloader \ 069-field-type \ 071-dexfile \ - 083-compiler-regressions \ 106-exceptions2 \ 107-int-math2 \ - 114-ParallelGC \ 201-built-in-exception-detail-messages \ 407-arrays \ 412-new-array \ 422-instanceof \ - 422-type-conversion \ 424-checkcast \ 427-bounds \ - 428-optimizing-arith-rem \ 430-live-register-slow-path \ - 431-optimizing-arith-shifts \ - 701-easy-div-rem \ 800-smali \ ifneq (,$(filter optimizing,$(COMPILER_TYPES))) diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar index d2cd8ab995..5c0f83f70c 100755 --- a/test/etc/run-test-jar +++ b/test/etc/run-test-jar @@ -108,6 +108,11 @@ while true; do DEV_MODE="y" TIME_OUT="n" shift + elif [ "x$1" = "x--gdb-arg" ]; then + shift + gdb_arg="$1" + GDB_ARGS="${GDB_ARGS} $gdb_arg" + shift elif [ "x$1" = "x--zygote" ]; then ZYGOTE="-Xzygote" msg "Spawning from zygote" @@ -229,11 +234,11 @@ if [ "$USE_GDB" = "y" ]; then else if [ `uname` = "Darwin" ]; then GDB=lldb - GDB_ARGS="-- $DALVIKVM" + GDB_ARGS="$GDB_ARGS -- $DALVIKVM" DALVIKVM= else GDB=gdb - GDB_ARGS="--args $DALVIKVM" + GDB_ARGS="$GDB_ARGS --args $DALVIKVM" # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. # gdbargs="--annotate=3 $gdbargs" fi diff --git a/test/run-test b/test/run-test index e9dd86acaa..6b8f00748b 100755 --- a/test/run-test +++ b/test/run-test @@ -171,6 +171,11 @@ while true; do option="$1" run_args="${run_args} --runtime-option $option" shift + elif [ "x$1" = "x--gdb-arg" ]; then + shift + gdb_arg="$1" + run_args="${run_args} --gdb-arg $gdb_arg" + shift elif [ "x$1" = "x--debug" ]; then run_args="${run_args} --debug" shift |