test/compiler/6982370/Test6982370.java

Thu, 20 Oct 2011 10:32:37 -0700

author
katleman
date
Thu, 20 Oct 2011 10:32:37 -0700
changeset 3191
3170e4044f2d
parent 0
f90c822e73f8
permissions
-rw-r--r--

Added tag jdk8-b10 for changeset d815de2e85e5

     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  */
    25 /**
    26  * @test
    27  * @bug 6982370
    28  * @summary SIGBUS in jbyte_fill
    29  *
    30  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill -Xbatch Test6982370
    31  */
    33 import java.util.Arrays;
    35 /**
    36  * Exercise the fill routine for various short alignments and sizes
    37  */
    39 public class Test6982370 {
    40     public static void main(String[] args) {
    41         test_byte();
    42         test_char();
    43         test_short();
    44         test_int();
    45         test_float();
    46     }
    48     public static void test_int() {
    49         int[] a = new int[16];
    50         for (int i = 0; i < 200000; i++) {
    51             int start = i & 7;
    52             int end = start + ((i >> 4) & 7);
    53             int value = i;
    54             if ((i & 1) == 1) value = -value;
    55             Arrays.fill(a, start, end, value);
    56             boolean error = false;
    57             for (int j = start; j < end; j++) {
    58                 if (a[j] != value) {
    59                     System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
    60                     error = true;
    61                 }
    62             }
    63             if (error) throw new InternalError();
    64         }
    65     }
    67     public static void test_float() {
    68         float[] a = new float[16];
    69         for (int i = 0; i < 200000; i++) {
    70             int start = i & 7;
    71             int end = start + ((i >> 4) & 7);
    72             float value = (float)i;
    73             if ((i & 1) == 1) value = -value;
    74             Arrays.fill(a, start, end, value);
    75             boolean error = false;
    76             for (int j = start; j < end; j++) {
    77                 if (a[j] != value) {
    78                     System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
    79                     error = true;
    80                 }
    81             }
    82             if (error) throw new InternalError();
    83         }
    84     }
    85     public static void test_char() {
    86         char[] a = new char[16];
    87         for (int i = 0; i < 200000; i++) {
    88             int start = i & 7;
    89             int end = start + ((i >> 4) & 7);
    90             char value = (char)i;
    91             Arrays.fill(a, start, end, value);
    92             boolean error = false;
    93             for (int j = start; j < end; j++) {
    94                 if (a[j] != value) {
    95                     System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
    96                     error = true;
    97                 }
    98             }
    99             if (error) throw new InternalError();
   100         }
   101     }
   102     public static void test_short() {
   103         short[] a = new short[16];
   104         for (int i = 0; i < 200000; i++) {
   105             int start = i & 7;
   106             int end = start + ((i >> 4) & 7);
   107             short value = (short)i;
   108             if ((i & 1) == 1) value = (short)-value;
   109             Arrays.fill(a, start, end, value);
   110             boolean error = false;
   111             for (int j = start; j < end; j++) {
   112                 if (a[j] != value) {
   113                     System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
   114                     error = true;
   115                 }
   116             }
   117             if (error) throw new InternalError();
   118         }
   119     }
   121     public static void test_byte() {
   122         for (int i = 0; i < 200000; i++) {
   123             byte[] a = new byte[16];
   124             int start = i & 7;
   125             int end = start + ((i >> 4) & 7);
   126             byte value = (byte)i;
   127             if ((i & 1) == 1) value = (byte)-value;
   128             Arrays.fill(a, start, end, value);
   129             boolean error = false;
   130             for (int j = start; j < end; j++) {
   131                 if (a[j] != value) {
   132                     System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
   133                     error = true;
   134                 }
   135             }
   136             if (error) throw new InternalError();
   137         }
   138     }
   139 }

mercurial