summaryrefslogtreecommitdiffstats
path: root/test/018-stack-overflow
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2014-03-13 18:10:08 -0700
committerMathieu Chartier <mathieuc@google.com>2014-03-18 13:44:59 -0700
commit60d7a65f7fb60f502160a2e479e86014c7787553 (patch)
treef8f0a11b95528d90e393a30851e9e4adb8d21f88 /test/018-stack-overflow
parent0f7e3e73229812d303f3621fad59ca76a50ebd07 (diff)
downloadart-60d7a65f7fb60f502160a2e479e86014c7787553.tar.gz
art-60d7a65f7fb60f502160a2e479e86014c7787553.tar.bz2
art-60d7a65f7fb60f502160a2e479e86014c7787553.zip
Fix stack overflow for mutual recursion.
There was an error where we would have a pc that was in the method which generated the stack overflow. This didn't work however because the stack overflow check was before we stored the method in the stack. The result was that the stack overflow handler had a PC which wasnt necessarily in the method at the top of the stack. This is now fixed by always restoring the link register before branching to the throw entrypoint. Slight code size regression on ARM/Mips (unmeasured). Regression on ARM is 4 bytes of code per stack overflow check. Some of this regression is mitigated by having one less GC safepoint. Also adds test case for StackOverflowError issue (from bdc). Tests passing: ARM, X86, Mips Phone booting: ARM Bug: https://code.google.com/p/android/issues/detail?id=66411 Bug: 12967914 Change-Id: I96fe667799458b58d1f86671e051968f7be78d5d (cherry-picked from c0f96d03a1855fda7d94332331b94860404874dd)
Diffstat (limited to 'test/018-stack-overflow')
-rw-r--r--test/018-stack-overflow/expected.txt3
-rw-r--r--test/018-stack-overflow/src/Main.java37
2 files changed, 35 insertions, 5 deletions
diff --git a/test/018-stack-overflow/expected.txt b/test/018-stack-overflow/expected.txt
index 7797816785..98b45b7b21 100644
--- a/test/018-stack-overflow/expected.txt
+++ b/test/018-stack-overflow/expected.txt
@@ -1,2 +1,3 @@
-caught SOE
+caught SOE in testSelfRecursion
+caught SOE in testMutualRecursion
SOE test done
diff --git a/test/018-stack-overflow/src/Main.java b/test/018-stack-overflow/src/Main.java
index f79c269c85..41adabc9ff 100644
--- a/test/018-stack-overflow/src/Main.java
+++ b/test/018-stack-overflow/src/Main.java
@@ -19,17 +19,46 @@
*/
public class Main {
public static void main(String args[]) {
+ testSelfRecursion();
+ testMutualRecursion();
+ System.out.println("SOE test done");
+ }
+
+ private static void testSelfRecursion() {
try {
stackOverflowTestSub(0.0, 0.0, 0.0);
}
catch (StackOverflowError soe) {
- System.out.println("caught SOE");
+ System.out.println("caught SOE in testSelfRecursion");
}
- System.out.println("SOE test done");
}
- private static void stackOverflowTestSub(double pad1, double pad2,
- double pad3) {
+ private static void stackOverflowTestSub(double pad1, double pad2, double pad3) {
stackOverflowTestSub(pad1, pad2, pad3);
}
+
+ private static void testMutualRecursion() {
+ try {
+ foo(0.0, 0.0, 0.0);
+ }
+ catch (StackOverflowError soe) {
+ System.out.println("caught SOE in testMutualRecursion");
+ }
+ }
+
+ private static void foo(double pad1, double pad2, double pad3) {
+ bar(pad1, pad2, pad3);
+ }
+
+ private static void bar(double pad1, double pad2, double pad3) {
+ baz(pad1, pad2, pad3);
+ }
+
+ private static void baz(double pad1, double pad2, double pad3) {
+ qux(pad1, pad2, pad3);
+ }
+
+ private static void qux(double pad1, double pad2, double pad3) {
+ foo(pad1, pad2, pad3);
+ }
}