< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/gcl001.java

Print this page

 35  * A) Create N 'JNI CS' threads. Each of them will:
 36  *    1. Create primitive array and string with random data
 37  *    2. Pass it to native method
 38  *    3. Sort/Hash data in JNI CS mixing string and array critical sections
 39  *    4. Return from native
 40  *    5. Check data to be processed correctly
 41  * B) Create M ' Garbage producer/memory allocation' threads. Each of them will:
 42  *    1. Allocate memory blocks and make them garbage.
 43  *    2. Check for OOM errors.
 44  *
 45  * @library /vmTestbase
 46  *          /test/lib
 47  * @run main/othervm/native/timeout=480
 48  *      -XX:-UseGCOverheadLimit
 49  *      nsk.stress.jni.gclocker.gcl001
 50  *      -stressThreadsFactor 8
 51  */
 52 
 53 package nsk.stress.jni.gclocker;
 54 

 55 import nsk.share.gc.GC;
 56 import nsk.share.gc.ThreadedGCTest;
 57 import nsk.share.gc.gp.array.BooleanArrayProducer;
 58 import nsk.share.gc.gp.array.ByteArrayProducer;
 59 import nsk.share.gc.gp.array.CharArrayProducer;
 60 import nsk.share.gc.gp.array.DoubleArrayProducer;
 61 import nsk.share.gc.gp.array.FloatArrayProducer;
 62 import nsk.share.gc.gp.array.IntArrayProducer;
 63 import nsk.share.gc.gp.array.LongArrayProducer;
 64 import nsk.share.gc.gp.array.ShortArrayProducer;
 65 import nsk.share.test.ExecutionController;
 66 import nsk.share.test.LocalRandom;
 67 
 68 public class gcl001 extends ThreadedGCTest {
 69 
 70     static {
 71         System.loadLibrary("gcl001");
 72     }
 73 
 74     int maxBlockSize;

124                 worker = new JNIFloatWorker(size);
125                 break;
126             case 7:
127                 worker = new JNIDoubleWorker(size);
128                 break;
129         }
130         return worker;
131     }
132 
133     int random(int maxSize) {
134         int res = LocalRandom.nextInt(maxSize);
135         return res > 128 ? res : 128;
136     }
137 
138     public static Object tmp;
139 
140     class GarbageProducer implements Runnable {
141 
142         private int maxSize;
143         ExecutionController stresser;
144         ByteArrayProducer bp;
145 
146         GarbageProducer(int size) {
147             this.maxSize = size;
148             bp = new ByteArrayProducer();
149         }
150 
151         public void run() {
152             if (stresser == null) {
153                 stresser = getExecutionController();
154             }
155 
156             while (stresser.continueExecution()) {
157                 try {
158                     byte[] arr = bp.create(random(maxSize));
159                     tmp = arr;
160                 } catch (OutOfMemoryError oome) {
161                     // Do nothing.
162                 }
163             }
164         }
165     }
166 
167     abstract class JNIAbstractWorker extends JNIWorker implements Runnable {
168 
169         ExecutionController stresser;
170         private int maxSize;
171 
172         public JNIAbstractWorker(int maxSize) {
173             this.maxSize = maxSize;
174         }
175 
176         public void check(boolean condition, String message) {
177             if (!condition) {
178                 throw new Error(message);
179             }

 35  * A) Create N 'JNI CS' threads. Each of them will:
 36  *    1. Create primitive array and string with random data
 37  *    2. Pass it to native method
 38  *    3. Sort/Hash data in JNI CS mixing string and array critical sections
 39  *    4. Return from native
 40  *    5. Check data to be processed correctly
 41  * B) Create M ' Garbage producer/memory allocation' threads. Each of them will:
 42  *    1. Allocate memory blocks and make them garbage.
 43  *    2. Check for OOM errors.
 44  *
 45  * @library /vmTestbase
 46  *          /test/lib
 47  * @run main/othervm/native/timeout=480
 48  *      -XX:-UseGCOverheadLimit
 49  *      nsk.stress.jni.gclocker.gcl001
 50  *      -stressThreadsFactor 8
 51  */
 52 
 53 package nsk.stress.jni.gclocker;
 54 
 55 import nsk.share.gc.DefaultProducer;
 56 import nsk.share.gc.GC;
 57 import nsk.share.gc.ThreadedGCTest;
 58 import nsk.share.gc.gp.array.BooleanArrayProducer;
 59 import nsk.share.gc.gp.array.ByteArrayProducer;
 60 import nsk.share.gc.gp.array.CharArrayProducer;
 61 import nsk.share.gc.gp.array.DoubleArrayProducer;
 62 import nsk.share.gc.gp.array.FloatArrayProducer;
 63 import nsk.share.gc.gp.array.IntArrayProducer;
 64 import nsk.share.gc.gp.array.LongArrayProducer;
 65 import nsk.share.gc.gp.array.ShortArrayProducer;
 66 import nsk.share.test.ExecutionController;
 67 import nsk.share.test.LocalRandom;
 68 
 69 public class gcl001 extends ThreadedGCTest {
 70 
 71     static {
 72         System.loadLibrary("gcl001");
 73     }
 74 
 75     int maxBlockSize;

125                 worker = new JNIFloatWorker(size);
126                 break;
127             case 7:
128                 worker = new JNIDoubleWorker(size);
129                 break;
130         }
131         return worker;
132     }
133 
134     int random(int maxSize) {
135         int res = LocalRandom.nextInt(maxSize);
136         return res > 128 ? res : 128;
137     }
138 
139     public static Object tmp;
140 
141     class GarbageProducer implements Runnable {
142 
143         private int maxSize;
144         ExecutionController stresser;
145         DefaultProducer gp;
146 
147         GarbageProducer(int size) {
148             this.maxSize = size;
149             gp = new DefaultProducer();
150         }
151 
152         public void run() {
153             if (stresser == null) {
154                 stresser = getExecutionController();
155             }
156 
157             while (stresser.continueExecution()) {
158                 try {
159                     tmp = gp.create(random(maxSize));

160                 } catch (OutOfMemoryError oome) {
161                     // Do nothing.
162                 }
163             }
164         }
165     }
166 
167     abstract class JNIAbstractWorker extends JNIWorker implements Runnable {
168 
169         ExecutionController stresser;
170         private int maxSize;
171 
172         public JNIAbstractWorker(int maxSize) {
173             this.maxSize = maxSize;
174         }
175 
176         public void check(boolean condition, String message) {
177             if (!condition) {
178                 throw new Error(message);
179             }
< prev index next >