diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/530-checker-lse/src/Main.java | 85 | ||||
| -rw-r--r-- | test/541-regression-inlined-deopt/expected.txt | 0 | ||||
| -rw-r--r-- | test/541-regression-inlined-deopt/info.txt | 4 | ||||
| -rw-r--r-- | test/541-regression-inlined-deopt/smali/TestCase.smali | 55 | ||||
| -rw-r--r-- | test/541-regression-inlined-deopt/src/Main.java | 36 | ||||
| -rw-r--r-- | test/Lookup/A.java | 17 | ||||
| -rw-r--r-- | test/Lookup/AB.java | 17 | ||||
| -rw-r--r-- | test/Lookup/C.java | 17 |
8 files changed, 157 insertions, 74 deletions
diff --git a/test/530-checker-lse/src/Main.java b/test/530-checker-lse/src/Main.java index 924ff6773f..c766aaa6c9 100644 --- a/test/530-checker-lse/src/Main.java +++ b/test/530-checker-lse/src/Main.java @@ -22,7 +22,7 @@ class Circle { return radius * radius * Math.PI; } private double radius; -} +}; class TestClass { TestClass() { @@ -36,29 +36,16 @@ class TestClass { volatile int k; TestClass next; static int si; -} +}; class SubTestClass extends TestClass { int k; -} +}; class TestClass2 { int i; int j; -} - -class Finalizable { - static boolean sVisited = false; - static final int VALUE = 0xbeef; - int i; - - protected void finalize() { - if (i != VALUE) { - System.out.println("Where is the beef?"); - } - sVisited = true; - } -} +}; public class Main { @@ -69,7 +56,7 @@ public class Main { /// CHECK-START: double Main.calcCircleArea(double) load_store_elimination (after) /// CHECK: NewInstance - /// CHECK-NOT: InstanceFieldSet + /// CHECK: InstanceFieldSet /// CHECK-NOT: InstanceFieldGet static double calcCircleArea(double radius) { @@ -130,7 +117,7 @@ public class Main { /// CHECK: InstanceFieldGet /// CHECK: InstanceFieldSet /// CHECK: NewInstance - /// CHECK-NOT: InstanceFieldSet + /// CHECK: InstanceFieldSet /// CHECK-NOT: InstanceFieldGet // A new allocation shouldn't alias with pre-existing values. @@ -236,7 +223,7 @@ public class Main { /// CHECK-START: int Main.test8() load_store_elimination (after) /// CHECK: NewInstance - /// CHECK-NOT: InstanceFieldSet + /// CHECK: InstanceFieldSet /// CHECK: InvokeVirtual /// CHECK-NOT: NullCheck /// CHECK-NOT: InstanceFieldGet @@ -394,8 +381,8 @@ public class Main { /// CHECK-START: int Main.test16() load_store_elimination (after) /// CHECK: NewInstance - /// CHECK-NOT: InstanceFieldSet - /// CHECK-NOT: InstanceFieldGet + /// CHECK-NOT: StaticFieldSet + /// CHECK-NOT: StaticFieldGet // Test inlined constructor. static int test16() { @@ -411,8 +398,8 @@ public class Main { /// CHECK-START: int Main.test17() load_store_elimination (after) /// CHECK: <<Const0:i\d+>> IntConstant 0 /// CHECK: NewInstance - /// CHECK-NOT: InstanceFieldSet - /// CHECK-NOT: InstanceFieldGet + /// CHECK-NOT: StaticFieldSet + /// CHECK-NOT: StaticFieldGet /// CHECK: Return [<<Const0>>] // Test getting default value. @@ -468,55 +455,6 @@ public class Main { return obj; } - /// CHECK-START: void Main.testFinalizable() load_store_elimination (before) - /// CHECK: NewInstance - /// CHECK: InstanceFieldSet - - /// CHECK-START: void Main.testFinalizable() load_store_elimination (after) - /// CHECK: NewInstance - /// CHECK: InstanceFieldSet - - // Allocations and stores into finalizable objects cannot be eliminated. - static void testFinalizable() { - Finalizable finalizable = new Finalizable(); - finalizable.i = Finalizable.VALUE; - } - - static java.lang.ref.WeakReference<Object> getWeakReference() { - return new java.lang.ref.WeakReference<>(new Object()); - } - - static void testFinalizableByForcingGc() { - testFinalizable(); - java.lang.ref.WeakReference<Object> reference = getWeakReference(); - - Runtime runtime = Runtime.getRuntime(); - for (int i = 0; i < 20; ++i) { - runtime.gc(); - System.runFinalization(); - try { - Thread.sleep(1); - } catch (InterruptedException e) { - throw new AssertionError(e); - } - - // Check to see if the weak reference has been garbage collected. - if (reference.get() == null) { - // A little bit more sleep time to make sure. - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new AssertionError(e); - } - if (!Finalizable.sVisited) { - System.out.println("finalize() not called."); - } - return; - } - } - System.out.println("testFinalizableByForcingGc() failed to force gc."); - } - public static void assertIntEquals(int expected, int result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); @@ -570,6 +508,5 @@ public class Main { float[] fa2 = { 1.8f }; assertFloatEquals(test19(fa1, fa2), 1.8f); assertFloatEquals(test20().i, 0); - testFinalizableByForcingGc(); } } diff --git a/test/541-regression-inlined-deopt/expected.txt b/test/541-regression-inlined-deopt/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/541-regression-inlined-deopt/expected.txt diff --git a/test/541-regression-inlined-deopt/info.txt b/test/541-regression-inlined-deopt/info.txt new file mode 100644 index 0000000000..209588fe05 --- /dev/null +++ b/test/541-regression-inlined-deopt/info.txt @@ -0,0 +1,4 @@ +Regression test for deopt from optimized code which would use the top-level +stack map for deopting inlined frames. Test case is written in smali for full +control over vregs because the previous test 449 would pass because the vreg +maps at the various inlining depths were similar. diff --git a/test/541-regression-inlined-deopt/smali/TestCase.smali b/test/541-regression-inlined-deopt/smali/TestCase.smali new file mode 100644 index 0000000000..a109775dfe --- /dev/null +++ b/test/541-regression-inlined-deopt/smali/TestCase.smali @@ -0,0 +1,55 @@ +# 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. + +.class public LTestCase; +.super Ljava/lang/Object; + +.method private static $inline$depth1([I)V + .registers 3 + + # Expects array in v2. + + const v0, 0x0 + + const v1, 0x3 + aput v0, p0, v1 + + const v1, 0x4 + aput v0, p0, v1 + + return-void +.end method + +.method private static $inline$depth0([I)V + .registers 1 + + # Expects array in v0. + + invoke-static {p0}, LTestCase;->$inline$depth1([I)V + return-void +.end method + +.method public static foo()V + .registers 10 + + # Create a new array short enough to throw AIOOB in $inline$depth1. + # Make sure the reference is not stored in the same vreg as used by + # the inlined methods. + + const v5, 0x3 + new-array v6, v5, [I + + invoke-static {v6}, LTestCase;->$inline$depth0([I)V + return-void +.end method diff --git a/test/541-regression-inlined-deopt/src/Main.java b/test/541-regression-inlined-deopt/src/Main.java new file mode 100644 index 0000000000..fa79590e65 --- /dev/null +++ b/test/541-regression-inlined-deopt/src/Main.java @@ -0,0 +1,36 @@ +/* + * 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. + */ + +import java.lang.reflect.*; + +public class Main { + + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String[] args) throws Throwable { + try { + Class<?> c = Class.forName("TestCase"); + Method m = c.getMethod("foo"); + m.invoke(null, (Object[]) null); + } catch (InvocationTargetException ex) { + // Code should have thrown AIOOB. + if (!(ex.getCause() instanceof ArrayIndexOutOfBoundsException)) { + throw ex; + } + } + } +} diff --git a/test/Lookup/A.java b/test/Lookup/A.java new file mode 100644 index 0000000000..666ba181d9 --- /dev/null +++ b/test/Lookup/A.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2011 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 A {} diff --git a/test/Lookup/AB.java b/test/Lookup/AB.java new file mode 100644 index 0000000000..b231708111 --- /dev/null +++ b/test/Lookup/AB.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2011 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 AB {} diff --git a/test/Lookup/C.java b/test/Lookup/C.java new file mode 100644 index 0000000000..5b90069262 --- /dev/null +++ b/test/Lookup/C.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2011 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 C {} |