hotspot/test/compiler/intrinsics/Test6982370.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 27699 hotspot/test/compiler/intrinsics/6982370/Test6982370.java@9913b19c0948
child 41705 332239c052cc
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@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
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    30
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill -Xbatch
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    31
 *      compiler.intrinsics.Test6982370
6464
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    32
 */
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    33
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    34
package compiler.intrinsics;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    35
6464
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    36
import java.util.Arrays;
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
 * Exercise the fill routine for various short alignments and sizes
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    40
 */
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    41
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    42
public class Test6982370 {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    43
    public static void main(String[] args) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    44
        test_byte();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    45
        test_char();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    46
        test_short();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    47
        test_int();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    48
        test_float();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    49
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    50
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    51
    public static void test_int() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    52
        int[] a = new int[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    53
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    54
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    55
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    56
            int value = i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    57
            if ((i & 1) == 1) value = -value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    58
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    59
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    60
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    61
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    62
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    63
                    error = true;
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
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    67
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    68
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    69
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    70
    public static void test_float() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    71
        float[] a = new float[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    72
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    73
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    74
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    75
            float value = (float)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    76
            if ((i & 1) == 1) value = -value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    77
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    78
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    79
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    80
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    81
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    82
                    error = true;
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
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    86
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    87
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    88
    public static void test_char() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    89
        char[] a = new char[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    90
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    91
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    92
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    93
            char value = (char)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    94
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    95
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    96
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    97
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    98
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    99
                    error = true;
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
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   103
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   104
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   105
    public static void test_short() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   106
        short[] a = new short[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   107
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   108
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   109
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   110
            short value = (short)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   111
            if ((i & 1) == 1) value = (short)-value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   112
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   113
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   114
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   115
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   116
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   117
                    error = true;
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
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   121
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   122
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   123
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   124
    public static void test_byte() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   125
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   126
            byte[] a = new byte[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   127
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   128
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   129
            byte value = (byte)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   130
            if ((i & 1) == 1) value = (byte)-value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   131
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   132
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   133
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   134
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   135
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   136
                    error = true;
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
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   140
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   141
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   142
}