1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /** 26 * @test 27 * @bug 6982370 28 * @summary SIGBUS in jbyte_fill 29 * 30 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill -Xbatch 31 * compiler.intrinsics.Test6982370 32 */ 33 34 package compiler.intrinsics; 35 36 import java.util.Arrays; 37 38 /** 39 * Exercise the fill routine for various short alignments and sizes 40 */ 41 42 public class Test6982370 { 43 public static void main(String[] args) { 44 test_byte(); 45 test_char(); 46 test_short(); 47 test_int(); 48 test_float(); 49 } 50 51 public static void test_int() { 52 int[] a = new int[16]; 53 for (int i = 0; i < 200000; i++) { 54 int start = i & 7; 55 int end = start + ((i >> 4) & 7); 56 int value = i; 57 if ((i & 1) == 1) value = -value; 58 Arrays.fill(a, start, end, value); 59 boolean error = false; 60 for (int j = start; j < end; j++) { 61 if (a[j] != value) { 62 System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length); 63 error = true; 64 } 65 } 66 if (error) throw new InternalError(); 67 } 68 } 69 70 public static void test_float() { 71 float[] a = new float[16]; 72 for (int i = 0; i < 200000; i++) { 73 int start = i & 7; 74 int end = start + ((i >> 4) & 7); 75 float value = (float)i; 76 if ((i & 1) == 1) value = -value; 77 Arrays.fill(a, start, end, value); 78 boolean error = false; 79 for (int j = start; j < end; j++) { 80 if (a[j] != value) { 81 System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length); 82 error = true; 83 } 84 } 85 if (error) throw new InternalError(); 86 } 87 } 88 public static void test_char() { 89 char[] a = new char[16]; 90 for (int i = 0; i < 200000; i++) { 91 int start = i & 7; 92 int end = start + ((i >> 4) & 7); 93 char value = (char)i; 94 Arrays.fill(a, start, end, value); 95 boolean error = false; 96 for (int j = start; j < end; j++) { 97 if (a[j] != value) { 98 System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length); 99 error = true; 100 } 101 } 102 if (error) throw new InternalError(); 103 } 104 } 105 public static void test_short() { 106 short[] a = new short[16]; 107 for (int i = 0; i < 200000; i++) { 108 int start = i & 7; 109 int end = start + ((i >> 4) & 7); 110 short value = (short)i; 111 if ((i & 1) == 1) value = (short)-value; 112 Arrays.fill(a, start, end, value); 113 boolean error = false; 114 for (int j = start; j < end; j++) { 115 if (a[j] != value) { 116 System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length); 117 error = true; 118 } 119 } 120 if (error) throw new InternalError(); 121 } 122 } 123 124 public static void test_byte() { 125 for (int i = 0; i < 200000; i++) { 126 byte[] a = new byte[16]; 127 int start = i & 7; 128 int end = start + ((i >> 4) & 7); 129 byte value = (byte)i; 130 if ((i & 1) == 1) value = (byte)-value; 131 Arrays.fill(a, start, end, value); 132 boolean error = false; 133 for (int j = start; j < end; j++) { 134 if (a[j] != value) { 135 System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length); 136 error = true; 137 } 138 } 139 if (error) throw new InternalError(); 140 } 141 } 142 }