hotspot/test/compiler/intrinsics/Test6982370.java
author hseigel
Wed, 01 Mar 2017 08:00:02 -0500
changeset 46194 5596e6f63072
parent 41705 332239c052cc
permissions -rw-r--r--
8172307: Remove ununsed JVM API JVM_GetModuleByPackageName() Summary: Remove get_module_by_package_name() etc., and unneeded test. Reviewed-by: sspitsyn, gtriantafill
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
 * @test
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    26
 * @bug 6982370
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    27
 * @summary SIGBUS in jbyte_fill
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    29
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill -Xbatch
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    30
 *      compiler.intrinsics.Test6982370
6464
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    31
 */
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    32
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    33
package compiler.intrinsics;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    34
6464
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    35
import java.util.Arrays;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    36
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    37
/**
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    38
 * Exercise the fill routine for various short alignments and sizes
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    39
 */
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    40
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    41
public class Test6982370 {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    42
    public static void main(String[] args) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    43
        test_byte();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    44
        test_char();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    45
        test_short();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    46
        test_int();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    47
        test_float();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    48
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    49
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    50
    public static void test_int() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    51
        int[] a = new int[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    52
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    53
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    54
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    55
            int value = i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    56
            if ((i & 1) == 1) value = -value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    57
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    58
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    59
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    60
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    61
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    62
                    error = true;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    63
                }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    64
            }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    65
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    66
        }
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
    public static void test_float() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    70
        float[] a = new float[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    71
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    72
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    73
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    74
            float value = (float)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    75
            if ((i & 1) == 1) value = -value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    76
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    77
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    78
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    79
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    80
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    81
                    error = true;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    82
                }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    83
            }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    84
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    85
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    86
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    87
    public static void test_char() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    88
        char[] a = new char[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    89
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    90
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    91
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    92
            char value = (char)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    93
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    94
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    95
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    96
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    97
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    98
                    error = true;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
    99
                }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   100
            }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   101
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   102
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   103
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   104
    public static void test_short() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   105
        short[] a = new short[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   106
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   107
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   108
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   109
            short value = (short)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   110
            if ((i & 1) == 1) value = (short)-value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   111
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   112
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   113
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   114
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   115
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   116
                    error = true;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   117
                }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   118
            }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   119
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   120
        }
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
    public static void test_byte() {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   124
        for (int i = 0; i < 200000; i++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   125
            byte[] a = new byte[16];
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   126
            int start = i & 7;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   127
            int end = start + ((i >> 4) & 7);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   128
            byte value = (byte)i;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   129
            if ((i & 1) == 1) value = (byte)-value;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   130
            Arrays.fill(a, start, end, value);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   131
            boolean error = false;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   132
            for (int j = start; j < end; j++) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   133
                if (a[j] != value) {
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   134
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   135
                    error = true;
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   136
                }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   137
            }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   138
            if (error) throw new InternalError();
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   139
        }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   140
    }
cd40daf5b832 6982370: SIGBUS in jbyte_fill
never
parents:
diff changeset
   141
}