< prev index next >

test/hotspot/jtreg/gc/shenandoah/compiler/TestClone.java

Print this page

 62  *                   -XX:+ShenandoahVerify
 63  *                   -Xint
 64  *                   TestClone
 65  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 66  *                   -XX:+UseShenandoahGC
 67  *                   -XX:+ShenandoahVerify
 68  *                   -XX:-TieredCompilation
 69  *                   TestClone
 70  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 71  *                   -XX:+UseShenandoahGC
 72  *                   -XX:+ShenandoahVerify
 73  *                   -XX:TieredStopAtLevel=1
 74  *                   TestClone
 75  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 76  *                   -XX:+UseShenandoahGC
 77  *                   -XX:+ShenandoahVerify
 78  *                   -XX:TieredStopAtLevel=4
 79  *                   TestClone
 80  */
 81 




































































 82 /*
 83  * @test id=aggressive
 84  * @summary Test clone barriers work correctly
 85  * @requires vm.gc.Shenandoah
 86  *
 87  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 88  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 89  *                   TestClone
 90  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 91  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 92  *                   -Xint
 93  *                   TestClone
 94  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 95  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 96  *                   -XX:-TieredCompilation
 97  *                   TestClone
 98  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 99  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
100  *                   -XX:TieredStopAtLevel=1
101  *                   TestClone

350   *                   -XX:+ShenandoahVerify
351   *                   -XX:TieredStopAtLevel=1
352   *                   TestClone
353   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
354   *                   -XX:-UseCompressedOops
355   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
356   *                   -XX:+ShenandoahVerify
357   *                   -XX:TieredStopAtLevel=4
358   *                   TestClone
359   */
360 
361 public class TestClone {
362 
363     public static void main(String[] args) throws Exception {
364         for (int i = 0; i < 10000; i++) {
365             Object[] src = new Object[i];
366             for (int c = 0; c < src.length; c++) {
367                 src[c] = new Object();
368             }
369             testWith(src);



370         }
371     }
372 
373     static void testWith(Object[] src) {
374         Object[] dst = src.clone();
375         int srcLen = src.length;
376         int dstLen = dst.length;
377         if (srcLen != dstLen) {
378             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
379         }
380         for (int c = 0; c < src.length; c++) {
381             Object s = src[c];
382             Object d = dst[c];
383             if (s != d) {
384                 throw new IllegalStateException("Elements do not match at " + c + ": " + s + " vs " + d);












































































385             }
386         }
387     }
388 }


 62  *                   -XX:+ShenandoahVerify
 63  *                   -Xint
 64  *                   TestClone
 65  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 66  *                   -XX:+UseShenandoahGC
 67  *                   -XX:+ShenandoahVerify
 68  *                   -XX:-TieredCompilation
 69  *                   TestClone
 70  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 71  *                   -XX:+UseShenandoahGC
 72  *                   -XX:+ShenandoahVerify
 73  *                   -XX:TieredStopAtLevel=1
 74  *                   TestClone
 75  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 76  *                   -XX:+UseShenandoahGC
 77  *                   -XX:+ShenandoahVerify
 78  *                   -XX:TieredStopAtLevel=4
 79  *                   TestClone
 80  */
 81 
 82 
 83 /*
 84  * @test id=passive
 85  * @summary Test clone barriers work correctly
 86  * @requires vm.gc.Shenandoah
 87  *
 88  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 89  *                   -XX:+UseShenandoahGC
 90  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
 91  *                   TestClone
 92  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 93  *                   -XX:+UseShenandoahGC
 94  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
 95  *                   -Xint
 96  *                   TestClone
 97  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 98  *                   -XX:+UseShenandoahGC
 99  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
100  *                   -XX:-TieredCompilation
101  *                   TestClone
102  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
103  *                   -XX:+UseShenandoahGC
104  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
105  *                   -XX:TieredStopAtLevel=1
106  *                   TestClone
107  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
108  *                   -XX:+UseShenandoahGC
109  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
110  *                   -XX:TieredStopAtLevel=4
111  *                   TestClone
112  */
113 
114 /*
115  * @test id=passive-verify
116  * @summary Test clone barriers work correctly
117  * @requires vm.gc.Shenandoah
118  *
119  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
120  *                   -XX:+UseShenandoahGC
121  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
122  *                   -XX:+ShenandoahVerify
123  *                   TestClone
124  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
125  *                   -XX:+UseShenandoahGC
126  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
127  *                   -XX:+ShenandoahVerify
128  *                   -Xint
129  *                   TestClone
130  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
131  *                   -XX:+UseShenandoahGC
132  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
133  *                   -XX:+ShenandoahVerify
134  *                   -XX:-TieredCompilation
135  *                   TestClone
136  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
137  *                   -XX:+UseShenandoahGC
138  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
139  *                   -XX:+ShenandoahVerify
140  *                   -XX:TieredStopAtLevel=1
141  *                   TestClone
142  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
143  *                   -XX:+UseShenandoahGC
144  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
145  *                   -XX:+ShenandoahVerify
146  *                   -XX:TieredStopAtLevel=4
147  *                   TestClone
148  */
149 
150 /*
151  * @test id=aggressive
152  * @summary Test clone barriers work correctly
153  * @requires vm.gc.Shenandoah
154  *
155  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
156  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
157  *                   TestClone
158  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
159  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
160  *                   -Xint
161  *                   TestClone
162  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
163  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
164  *                   -XX:-TieredCompilation
165  *                   TestClone
166  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
167  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
168  *                   -XX:TieredStopAtLevel=1
169  *                   TestClone

418   *                   -XX:+ShenandoahVerify
419   *                   -XX:TieredStopAtLevel=1
420   *                   TestClone
421   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
422   *                   -XX:-UseCompressedOops
423   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
424   *                   -XX:+ShenandoahVerify
425   *                   -XX:TieredStopAtLevel=4
426   *                   TestClone
427   */
428 
429 public class TestClone {
430 
431     public static void main(String[] args) throws Exception {
432         for (int i = 0; i < 10000; i++) {
433             Object[] src = new Object[i];
434             for (int c = 0; c < src.length; c++) {
435                 src[c] = new Object();
436             }
437             testWith(src);
438 
439             testWithObject(new SmallObject());
440             testWithObject(new LargeObject());
441         }
442     }
443 
444     static void testWith(Object[] src) {
445         Object[] dst = src.clone();
446         int srcLen = src.length;
447         int dstLen = dst.length;
448         if (srcLen != dstLen) {
449             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
450         }
451         for (int c = 0; c < src.length; c++) {
452             Object s = src[c];
453             Object d = dst[c];
454             if (s != d) {
455                 throw new IllegalStateException("Elements do not match at " + c + ": " + s + " vs " + d + ", len = " + srcLen);
456             }
457         }
458     }
459 
460     static void testWithObject(SmallObject src) {
461         SmallObject dst = src.clone();
462         if (dst.x1 != src.x1 ||
463             dst.x2 != src.x2 ||
464             dst.x3 != src.x3 ||
465             dst.x4 != src.x4) {
466             throw new IllegalStateException("Contents do not match");
467         }
468     }
469 
470     static void testWithObject(LargeObject src) {
471         LargeObject dst = src.clone();
472         if (dst.x01 != src.x01 ||
473             dst.x02 != src.x02 ||
474             dst.x03 != src.x03 ||
475             dst.x04 != src.x04 ||
476             dst.x05 != src.x05 ||
477             dst.x06 != src.x06 ||
478             dst.x07 != src.x07 ||
479             dst.x08 != src.x08 ||
480             dst.x09 != src.x09 ||
481             dst.x10 != src.x10 ||
482             dst.x11 != src.x11 ||
483             dst.x12 != src.x12 ||
484             dst.x13 != src.x13 ||
485             dst.x14 != src.x14 ||
486             dst.x15 != src.x15 ||
487             dst.x16 != src.x16) {
488             throw new IllegalStateException("Contents do not match");
489         }
490     }
491 
492     static class SmallObject implements Cloneable {
493         Object x1 = new Object();
494         Object x2 = new Object();
495         Object x3 = new Object();
496         Object x4 = new Object();
497 
498         @Override
499         public SmallObject clone() {
500             try {
501                 return (SmallObject) super.clone();
502             } catch (CloneNotSupportedException e) {
503                 throw new AssertionError();
504             }
505         }
506     }
507 
508     static class LargeObject implements Cloneable {
509         Object x01 = new Object();
510         Object x02 = new Object();
511         Object x03 = new Object();
512         Object x04 = new Object();
513         Object x05 = new Object();
514         Object x06 = new Object();
515         Object x07 = new Object();
516         Object x08 = new Object();
517         Object x09 = new Object();
518         Object x10 = new Object();
519         Object x11 = new Object();
520         Object x12 = new Object();
521         Object x13 = new Object();
522         Object x14 = new Object();
523         Object x15 = new Object();
524         Object x16 = new Object();
525 
526         @Override
527         public LargeObject clone() {
528             try {
529                 return (LargeObject) super.clone();
530             } catch (CloneNotSupportedException e) {
531                 throw new AssertionError();
532             }
533         }
534     }
535 }
536 
< prev index next >