summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBen Cheng <bccheng@android.com>2011-03-22 14:09:09 -0700
committerBen Cheng <bccheng@android.com>2011-03-31 13:19:19 -0700
commit32115a971ea00ab2421fab4e4a3afa6c50c82173 (patch)
tree46a022082ba16b413c4978d2d1014b0623a82492 /tests
parent9220113edce56372d613f7aba006513ae85a99bc (diff)
downloadandroid_dalvik-32115a971ea00ab2421fab4e4a3afa6c50c82173.tar.gz
android_dalvik-32115a971ea00ab2421fab4e4a3afa6c50c82173.tar.bz2
android_dalvik-32115a971ea00ab2421fab4e4a3afa6c50c82173.zip
Generate code for loops formed with the new builder
Adapt the existing counted loop analysis and range/null check elimination code to work with the new loop building heuristics. Cleaned up the old ad-hoc loop builder. Suspend polling is enabled by default for loops. The backward chaining cell will be used in self-verification and profiling mode. If the loop includes accesses to resolved fields/classes, abort code generation for now and revert to the basic acyclic trace. Added tests/090-loop-formation to make sure the JIT won't choke on such instructions. Change-Id: Idbc57df0a745be3b692f68c1acb6d4861c537f75
Diffstat (limited to 'tests')
-rw-r--r--tests/090-loop-formation/expected.txt5
-rw-r--r--tests/090-loop-formation/info.txt3
-rw-r--r--tests/090-loop-formation/src/Main.java56
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/090-loop-formation/expected.txt b/tests/090-loop-formation/expected.txt
new file mode 100644
index 000000000..b7e0bb3d1
--- /dev/null
+++ b/tests/090-loop-formation/expected.txt
@@ -0,0 +1,5 @@
+counter1 is 0
+counter2 is 32767
+counter3 is 32767
+counter4 is 0
+counter5 is 65534
diff --git a/tests/090-loop-formation/info.txt b/tests/090-loop-formation/info.txt
new file mode 100644
index 000000000..98d1d4bef
--- /dev/null
+++ b/tests/090-loop-formation/info.txt
@@ -0,0 +1,3 @@
+Test loop formation heuristics and code generation. Basically the problem to
+catch here is to make sure that some never-exercised code blocks are included
+in the loop region, and the JIT compiler won't choke on unresolved fields.
diff --git a/tests/090-loop-formation/src/Main.java b/tests/090-loop-formation/src/Main.java
new file mode 100644
index 000000000..7c16667ff
--- /dev/null
+++ b/tests/090-loop-formation/src/Main.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+/*
+ * Create two versions of loops where the unresolved field is on either the
+ * taken or the non-taken path to make sure that the loop detection code bails
+ * on unresolved fields.
+ */
+public class Main {
+ static int counter1;
+ static int counter2;
+ static int counter3;
+ static int counter4;
+ static int counter5;
+
+ public static void main(String[] args) {
+ /* counter1 is not resolved */
+ for (int i = 0; i < 32767; i++) {
+ if (i < 0) {
+ counter1++;
+ } else {
+ counter2++;
+ }
+ counter5++;
+ }
+
+ /* counter4 is not resolved */
+ for (int i = 0; i < 32767; i++) {
+ if (i >= 0) {
+ counter3++;
+ } else {
+ counter4++;
+ }
+ counter5++;
+ }
+
+ System.out.println("counter1 is " + counter1);
+ System.out.println("counter2 is " + counter2);
+ System.out.println("counter3 is " + counter3);
+ System.out.println("counter4 is " + counter4);
+ System.out.println("counter5 is " + counter5);
+ }
+}