jdk

Форк
0
141 строка · 4.8 Кб
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

24
/**
25
 * @test
26
 * @bug 6982370
27
 * @summary SIGBUS in jbyte_fill
28
 *
29
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill -Xbatch
30
 *      compiler.intrinsics.Test6982370
31
 */
32

33
package compiler.intrinsics;
34

35
import java.util.Arrays;
36

37
/**
38
 * Exercise the fill routine for various short alignments and sizes
39
 */
40

41
public class Test6982370 {
42
    public static void main(String[] args) {
43
        test_byte();
44
        test_char();
45
        test_short();
46
        test_int();
47
        test_float();
48
    }
49

50
    public static void test_int() {
51
        int[] a = new int[16];
52
        for (int i = 0; i < 200000; i++) {
53
            int start = i & 7;
54
            int end = start + ((i >> 4) & 7);
55
            int value = i;
56
            if ((i & 1) == 1) value = -value;
57
            Arrays.fill(a, start, end, value);
58
            boolean error = false;
59
            for (int j = start; j < end; j++) {
60
                if (a[j] != value) {
61
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
62
                    error = true;
63
                }
64
            }
65
            if (error) throw new InternalError();
66
        }
67
    }
68

69
    public static void test_float() {
70
        float[] a = new float[16];
71
        for (int i = 0; i < 200000; i++) {
72
            int start = i & 7;
73
            int end = start + ((i >> 4) & 7);
74
            float value = (float)i;
75
            if ((i & 1) == 1) value = -value;
76
            Arrays.fill(a, start, end, value);
77
            boolean error = false;
78
            for (int j = start; j < end; j++) {
79
                if (a[j] != value) {
80
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
81
                    error = true;
82
                }
83
            }
84
            if (error) throw new InternalError();
85
        }
86
    }
87
    public static void test_char() {
88
        char[] a = new char[16];
89
        for (int i = 0; i < 200000; i++) {
90
            int start = i & 7;
91
            int end = start + ((i >> 4) & 7);
92
            char value = (char)i;
93
            Arrays.fill(a, start, end, value);
94
            boolean error = false;
95
            for (int j = start; j < end; j++) {
96
                if (a[j] != value) {
97
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
98
                    error = true;
99
                }
100
            }
101
            if (error) throw new InternalError();
102
        }
103
    }
104
    public static void test_short() {
105
        short[] a = new short[16];
106
        for (int i = 0; i < 200000; i++) {
107
            int start = i & 7;
108
            int end = start + ((i >> 4) & 7);
109
            short value = (short)i;
110
            if ((i & 1) == 1) value = (short)-value;
111
            Arrays.fill(a, start, end, value);
112
            boolean error = false;
113
            for (int j = start; j < end; j++) {
114
                if (a[j] != value) {
115
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
116
                    error = true;
117
                }
118
            }
119
            if (error) throw new InternalError();
120
        }
121
    }
122

123
    public static void test_byte() {
124
        for (int i = 0; i < 200000; i++) {
125
            byte[] a = new byte[16];
126
            int start = i & 7;
127
            int end = start + ((i >> 4) & 7);
128
            byte value = (byte)i;
129
            if ((i & 1) == 1) value = (byte)-value;
130
            Arrays.fill(a, start, end, value);
131
            boolean error = false;
132
            for (int j = start; j < end; j++) {
133
                if (a[j] != value) {
134
                    System.err.println("a[" + j + "] = " + a[j] + " != " + value + " for " + a.length);
135
                    error = true;
136
                }
137
            }
138
            if (error) throw new InternalError();
139
        }
140
    }
141
}
142

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.