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