diff options
| author | Bill Buzbee <buzbee@google.com> | 2009-12-03 15:09:32 -0800 |
|---|---|---|
| committer | Bill Buzbee <buzbee@google.com> | 2009-12-03 19:17:55 -0800 |
| commit | 2ce8a6c8c11432338cf0cbca8f462e2cf7da1843 (patch) | |
| tree | d998a43edcfe2d7522fe03643c22bedfdc700f2f /tests | |
| parent | a2500b80e565777e62f63a49acceac895f811ada (diff) | |
| download | android_dalvik-2ce8a6c8c11432338cf0cbca8f462e2cf7da1843.tar.gz android_dalvik-2ce8a6c8c11432338cf0cbca8f462e2cf7da1843.tar.bz2 android_dalvik-2ce8a6c8c11432338cf0cbca8f462e2cf7da1843.zip | |
Jit: Fix for [Issue 2302318] Crash during spin-on-suspend testing
This was an amusing bug: the test case simulated a daemon by falling
into an empty loop-forever. The trace selector treats unconditional
branches as NOPs, and proceeded to repeatedly add the same "branch to self"
instruction to the trace until it reached max trace size. The compiler
got confused, and died.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/083-jit-regressions/expected.txt | 4 | ||||
| -rw-r--r-- | tests/083-jit-regressions/src/Main.java | 45 |
2 files changed, 46 insertions, 3 deletions
diff --git a/tests/083-jit-regressions/expected.txt b/tests/083-jit-regressions/expected.txt index 780f71b15..e1db13413 100644 --- a/tests/083-jit-regressions/expected.txt +++ b/tests/083-jit-regressions/expected.txt @@ -1 +1,5 @@ b2296099 Passes +Spinning away at priority 10 +Spinning away at priority 5 +Spinning away at priority 1 +done diff --git a/tests/083-jit-regressions/src/Main.java b/tests/083-jit-regressions/src/Main.java index e6a18ba8f..24f073e81 100644 --- a/tests/083-jit-regressions/src/Main.java +++ b/tests/083-jit-regressions/src/Main.java @@ -20,6 +20,7 @@ public class Main { public static void main(String args[]) throws Exception { b2296099Test(); + b2302318Test(); } static void b2296099Test() throws Exception { @@ -43,7 +44,45 @@ public class Main { System.out.println("b2296099 Passes"); } - static int rotateLeft(int i, int distance) { - return ((i << distance) | (i >>> (-distance))); - } + static int rotateLeft(int i, int distance) { + return ((i << distance) | (i >>> (-distance))); + } + + static void b2302318Test() { + System.gc(); + + SpinThread slow = new SpinThread(Thread.MIN_PRIORITY); + SpinThread fast1 = new SpinThread(Thread.NORM_PRIORITY); + SpinThread fast2 = new SpinThread(Thread.MAX_PRIORITY); + + slow.setDaemon(true); + fast1.setDaemon(true); + fast2.setDaemon(true); + + fast2.start(); + slow.start(); + fast1.start(); + try { + Thread.sleep(3000); + } catch (InterruptedException ie) {/*ignore */} + System.gc(); + + System.out.println("done"); + } +} + +class SpinThread extends Thread { + int mPriority; + + SpinThread(int prio) { + super("Spin prio=" + prio); + mPriority = prio; + } + + public void run() { + setPriority(mPriority); + System.out.println("Spinning away at priority " + mPriority); + + while (true) {} + } } |
