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