2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import java.util.concurrent.*;
20 * Test for Jit regressions.
23 public static void main(String args[]) throws Exception {
30 static void b2296099Test() throws Exception {
34 int distl = 360530809;
36 for (int i = 0; i < 100000; i++) {
37 int b = rotateLeft(x, dist);
39 throw new RuntimeException("Unexpected value: " + b
40 + " after " + i + " iterations");
42 for (int i = 0; i < 100000; i++) {
43 long bl = rotateLeft(xl, distl);
45 throw new RuntimeException("Unexpected value: " + bl
46 + " after " + i + " iterations");
48 System.out.println("b2296099 passes");
51 static int rotateLeft(int i, int distance) {
52 return ((i << distance) | (i >>> (-distance)));
55 static void b2302318Test() {
58 SpinThread slow = new SpinThread(Thread.MIN_PRIORITY);
59 SpinThread fast1 = new SpinThread(Thread.NORM_PRIORITY);
60 SpinThread fast2 = new SpinThread(Thread.MAX_PRIORITY);
63 fast1.setDaemon(true);
64 fast2.setDaemon(true);
71 } catch (InterruptedException ie) {/*ignore */}
74 System.out.println("b2302318 passes");
77 static void b2487514Test() {
78 PriorityBlockingQueue q = new PriorityBlockingQueue(10);
81 q.offer(new Integer(0));
83 * Warm up the code cache to have toArray() compiled. The key here is
84 * to pass a compatible type so that there are no exceptions when
85 * executing the method body (ie the APUT_OBJECT bytecode).
87 for (int i = 0; i < 1000; i++) {
88 Integer[] ints = (Integer[]) q.toArray(new Integer[5]);
91 /* Now pass an incompatible type which is guaranteed to throw */
92 for (int i = 0; i < 1000; i++) {
94 Object[] obj = q.toArray(new String[5]);
96 catch (ArrayStoreException success) {
101 if (catchCount == 1000) {
102 System.out.println("b2487514 passes");
105 System.out.println("b2487514 fails: catchCount is " + catchCount +
106 " (expecting 1000)");
110 static void b5884080Test() {
122 System.out.println("b5884080 passes");
125 System.out.println("b5884080 fails: vA is " + vA +
126 " (expecting 100001)");
131 class SpinThread extends Thread {
134 SpinThread(int prio) {
135 super("Spin prio=" + prio);
140 setPriority(mPriority);