summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-06-22 09:25:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-22 09:25:57 +0000
commit096f357c5dda663c6fbb58bd0154c091aec51f63 (patch)
tree887318a4f18475f4df57f7d0ac84d95c1818bb40 /test
parentc9345cc258d6a4e164b7e64ee1e67e69a180b972 (diff)
parent753f1fb083d5221f51b1d60d4089a33527ae5bc9 (diff)
downloadart-096f357c5dda663c6fbb58bd0154c091aec51f63.zip
art-096f357c5dda663c6fbb58bd0154c091aec51f63.tar.gz
art-096f357c5dda663c6fbb58bd0154c091aec51f63.tar.bz2
Merge "Bailout from compilation if an invoke is malformed." into mnc-dev
Diffstat (limited to 'test')
-rw-r--r--test/503-dead-instructions/expected.txt1
-rw-r--r--test/503-dead-instructions/info.txt2
-rw-r--r--test/503-dead-instructions/smali/DeadInstructions.smali63
-rw-r--r--test/503-dead-instructions/src/Main.java40
4 files changed, 106 insertions, 0 deletions
diff --git a/test/503-dead-instructions/expected.txt b/test/503-dead-instructions/expected.txt
new file mode 100644
index 0000000..ccaf6f8
--- /dev/null
+++ b/test/503-dead-instructions/expected.txt
@@ -0,0 +1 @@
+Enter
diff --git a/test/503-dead-instructions/info.txt b/test/503-dead-instructions/info.txt
new file mode 100644
index 0000000..7e3f1ab
--- /dev/null
+++ b/test/503-dead-instructions/info.txt
@@ -0,0 +1,2 @@
+Regression test for the building phase of the optimizing
+compiler. See comment in smali file.
diff --git a/test/503-dead-instructions/smali/DeadInstructions.smali b/test/503-dead-instructions/smali/DeadInstructions.smali
new file mode 100644
index 0000000..9f6c565
--- /dev/null
+++ b/test/503-dead-instructions/smali/DeadInstructions.smali
@@ -0,0 +1,63 @@
+# 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 LDeadInstructions;
+
+.super Ljava/lang/Object;
+
+.method public static method1()V
+ .registers 2
+ return-void
+ # Create a label and a branch to that label to trick the
+ # optimizing compiler into thinking the invoke is live.
+ :start
+ const/4 v0, 0
+ const/4 v1, 0
+ # Provide more arguments than we should. Because this is dead
+ # code, the verifier will not check the argument count. So
+ # the compilers must do the same.
+ invoke-static {v0, v1}, LDeadInstructions;->method1()V
+ goto :start
+.end method
+
+.method public static method2(J)V
+ .registers 3
+ return-void
+ :start
+ const/4 v0, 0
+ const/4 v1, 0
+ const/4 v2, 0
+ # Give a non-sequential pair for the long argument.
+ invoke-static {v0, v2}, LDeadInstructions;->method2(J)V
+ goto :start
+.end method
+
+.method public static method3()V
+ .registers 1
+ return-void
+ :start
+ const/4 v0, 0
+ # Give one half of a pair.
+ invoke-static {v0}, LDeadInstructions;->method2(J)V
+ goto :start
+.end method
+
+.method public static method4()V
+ .registers 2
+ return-void
+ :start
+ # Provide less arguments than we should.
+ invoke-static {}, LDeadInstructions;->method3(J)V
+ goto :start
+.end method
diff --git a/test/503-dead-instructions/src/Main.java b/test/503-dead-instructions/src/Main.java
new file mode 100644
index 0000000..6249dc7
--- /dev/null
+++ b/test/503-dead-instructions/src/Main.java
@@ -0,0 +1,40 @@
+/*
+ * 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.Method;
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ // Workaround for b/18051191.
+ System.out.println("Enter");
+ Class<?> c = Class.forName("DeadInstructions");
+ Method m = c.getMethod("method1");
+ Object[] arguments1 = { };
+ m.invoke(null, arguments1);
+
+ Object[] arguments2 = { (long)4 };
+ m = c.getMethod("method2", long.class);
+ m.invoke(null, arguments2);
+
+ Object[] arguments3 = { };
+ m = c.getMethod("method3");
+ m.invoke(null, arguments3);
+
+ Object[] arguments4 = { };
+ m = c.getMethod("method4");
+ m.invoke(null, arguments4);
+ }
+}