summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2018-04-17 14:56:29 -0700
committerAart Bik <ajcbik@google.com>2018-04-19 09:17:11 -0700
commit240384b7d96c2d579bf58ed7a3e9c9ba1911dae3 (patch)
treed00e99045d9b4fda7a3743577dbddeba0c276a38 /test
parentcb21a56d811e961ad1f2a50ee8bc748bd148885c (diff)
downloadart-240384b7d96c2d579bf58ed7a3e9c9ba1911dae3.tar.gz
art-240384b7d96c2d579bf58ed7a3e9c9ba1911dae3.tar.bz2
art-240384b7d96c2d579bf58ed7a3e9c9ba1911dae3.zip
Revert^2: Deopt does not throw
Rationale: "CanThrow" of deopt was possibly misused to prevents some optimizations. However, the instruction technically cannot throw an exception, and indeed crashed the graph verifier for some corner cases. This Cl sets that right. Bug: 29868356 Test: test-art-host,target (revert^2 of commit 2905de1c0e5b6a0c995be474b3f0efdfdc6a41c4) Change-Id: I4d4e6c00eff52140aa1845332998224ececc92ef
Diffstat (limited to 'test')
-rw-r--r--test/683-deopt-regression/expected.txt1
-rw-r--r--test/683-deopt-regression/info.txt1
-rw-r--r--test/683-deopt-regression/smali/Deopt.smali60
-rw-r--r--test/683-deopt-regression/src/Main.java54
4 files changed, 116 insertions, 0 deletions
diff --git a/test/683-deopt-regression/expected.txt b/test/683-deopt-regression/expected.txt
new file mode 100644
index 0000000000..b0aad4deb5
--- /dev/null
+++ b/test/683-deopt-regression/expected.txt
@@ -0,0 +1 @@
+passed
diff --git a/test/683-deopt-regression/info.txt b/test/683-deopt-regression/info.txt
new file mode 100644
index 0000000000..0c2cb81af7
--- /dev/null
+++ b/test/683-deopt-regression/info.txt
@@ -0,0 +1 @@
+Regression test on deopt from BCE
diff --git a/test/683-deopt-regression/smali/Deopt.smali b/test/683-deopt-regression/smali/Deopt.smali
new file mode 100644
index 0000000000..3bd9f6cf75
--- /dev/null
+++ b/test/683-deopt-regression/smali/Deopt.smali
@@ -0,0 +1,60 @@
+# Copyright (C) 2018 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 LDeopt;
+
+.super Ljava/lang/Object;
+
+.method public constructor <init>()V
+.registers 1
+ invoke-direct {v0}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
+
+.method public static testCase([I)I
+ .registers 8
+
+ const v0, 0x0 # counter
+ const v1, 0xF # loop max
+ const v2, 0x0 # result
+
+ :try_start
+ # Something throwing to start the try block. v6 contains a reference.
+ move-object v6, p0
+ aget v3, p0, v0
+
+ # Invalidate v6 before entering the loop.
+ const-wide v5, 0x0
+
+ :loop_start
+ # Set v6 to a different reference (creates a catch phi).
+ const v6, 0x0
+
+ aget v3, p0, v0
+ add-int/2addr v2, v3
+ add-int/lit8 v0, v0, 0x1
+ if-lt v0, v1, :loop_start
+
+ :try_end
+ .catchall {:try_start .. :try_end} :catch
+
+ :exit
+ return v2
+
+ :catch
+ invoke-virtual {v6}, Ljava/lang/Object;->hashCode()I # use v6 as a reference
+ goto :exit
+
+.end method
+
diff --git a/test/683-deopt-regression/src/Main.java b/test/683-deopt-regression/src/Main.java
new file mode 100644
index 0000000000..326fe47c89
--- /dev/null
+++ b/test/683-deopt-regression/src/Main.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 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 {
+ if (System.getProperty("java.vm.name").equals("Dalvik")) {
+ Class<?> c = Class.forName("Deopt");
+ Method m = c.getMethod("testCase", int[].class);
+ int[] p = null;
+ try {
+ m.invoke(null, p);
+ System.out.println("should not reach");
+ } catch (Exception e) {
+ // Tried to invoke hashCode on incoming null.
+ }
+ int result;
+ int[] q = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ result = ((Integer) m.invoke(null, q));
+ expectEquals(120, result);
+ int[] r = { };
+ result = ((Integer) m.invoke(null, r));
+ expectEquals(0, result);
+ int[] s = { 1 };
+ try {
+ m.invoke(null, s);
+ System.out.println("should not reach");
+ } catch (Exception e) {
+ // Tried to invoke hashCode on generated null.
+ }
+ }
+ System.out.println("passed");
+ }
+
+ private static void expectEquals(int expected, int result) {
+ if (expected != result) {
+ throw new Error("Expected: " + expected + ", found: " + result);
+ }
+ }
+}