2626 * @test
2727 * @bug 8193518 8249608
2828 * @summary C2: Vector registers are sometimes corrupted at safepoint
29- * @run main/othervm -XX:-BackgroundCompilation -XX:+UseCountedLoopSafepoints -XX:LoopStripMiningIter=1000 TestVectorsNotSavedAtSafepoint test1
29+ * @run main/othervm -XX:-BackgroundCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+ UseCountedLoopSafepoints -XX:LoopStripMiningIter=2 -XX:-TieredCompilation TestVectorsNotSavedAtSafepoint test1
3030 * @run main/othervm -XX:-BackgroundCompilation TestVectorsNotSavedAtSafepoint test2
3131 */
3232
@@ -58,10 +58,13 @@ public static void test2(int[] iArr, long[] lArr) {
5858 static class GarbageProducerThread extends Thread {
5959 public void run () {
6060 for (;;) {
61+ // Produce some garbage and then let the GC do its work which will
62+ // corrupt vector registers if they are not saved at safepoints.
6163 Object [] arrays = new Object [1024 ];
6264 for (int i = 0 ; i < arrays .length ; i ++) {
6365 arrays [i ] = new int [1024 ];
6466 }
67+ System .gc ();
6568 }
6669 }
6770 }
@@ -72,23 +75,20 @@ public static void main(String[] args) {
7275 garbage_producer .start ();
7376
7477 if (args [0 ].equals ("test1" )) {
75- byte [] barray = new byte [10 ];
76- long [] larray1 = new long [1000 ];
77- long [] larray2 = new long [100_000_000 ];
78- for (int i = 0 ; i < 20_000 ; i ++) {
79- test1 (barray , barray , barray , larray1 , -1 );
80- }
81- for (int i = 0 ; i < 100 ; i ++) {
82- test1 (barray , barray , barray , larray2 , -1 );
83- if (larray2 [larray2 .length -1 ] != -1 ) {
84- System .out .println ("Iter " + i + " Failed with " + Long .toHexString (larray2 [larray2 .length -1 ]));
85- throw new RuntimeException ("Test1 failed" );
78+ byte [] bArr = new byte [10 ];
79+ long [] lArr = new long [1000 ];
80+ for (int i = 0 ; i < 10_000 ; ++i ) {
81+ test1 (bArr , bArr , bArr , lArr , -1 );
82+ for (int j = 0 ; j < lArr .length ; ++j ) {
83+ if (bArr [j % 10 ] != 0 || lArr [j ] != -1 ) {
84+ throw new RuntimeException ("Test1 failed at iteration " + i + ": bArr[" + (j % 10 ) + "] = " + bArr [j % 10 ] + ", lArr[" + j + "] = " + lArr [j ]);
85+ }
8686 }
8787 }
8888 } else {
8989 int iArr [] = new int [100 ];
9090 long lArr [] = new long [100 ];
91- for (int i = 0 ; i < 600_000 ; ++i ) {
91+ for (int i = 0 ; i < 10_000 ; ++i ) {
9292 test2 (iArr , lArr );
9393 for (int j = 0 ; j < lArr .length ; ++j ) {
9494 if (iArr [j ] != 1 || lArr [j ] != 1 ) {
0 commit comments