Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codegen/Test6431242.java
41149 views
1
/*
2
* Copyright (c) 2006, 2013, 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 6431242
27
*
28
* @run main compiler.codegen.Test6431242
29
*/
30
31
package compiler.codegen;
32
33
public class Test6431242 {
34
35
int _len = 8;
36
int[] _arr_i = new int[_len];
37
long[] _arr_l = new long[_len];
38
39
int[] _arr_i_cp = new int[_len];
40
long[] _arr_l_cp = new long[_len];
41
42
int _k = 0x12345678;
43
int _j = 0;
44
int _ir = 0x78563412;
45
int _ir1 = 0x78563413;
46
int _ir2 = 0x79563412;
47
48
long _m = 0x123456789abcdef0L;
49
long _l = 0L;
50
long _lr = 0xf0debc9a78563412L;
51
long _lr1 = 0xf0debc9a78563413L;
52
long _lr2 = 0xf1debc9a78563412L;
53
54
void init() {
55
for (int i = 0; i < _arr_i.length; i++) {
56
_arr_i[i] = _k;
57
_arr_l[i] = _m;
58
}
59
}
60
61
public int test_int_reversed(int i) {
62
return Integer.reverseBytes(i);
63
}
64
65
public long test_long_reversed(long i) {
66
return Long.reverseBytes(i);
67
}
68
69
public void test_copy_ints(int[] dst, int[] src) {
70
for (int i = 0; i < src.length; i++) {
71
dst[i] = Integer.reverseBytes(src[i]);
72
}
73
}
74
75
public void test_copy_ints_reversed(int[] dst, int[] src) {
76
for (int i = 0; i < src.length; i++) {
77
dst[i] = 1 + Integer.reverseBytes(src[i]);
78
}
79
}
80
81
public void test_copy_ints_store_reversed(int[] dst, int[] src) {
82
for (int i = 0; i < src.length; i++) {
83
dst[i] = Integer.reverseBytes(1 + src[i]);
84
}
85
}
86
87
public void test_copy_longs(long[] dst, long[] src) {
88
for (int i = 0; i < src.length; i++) {
89
dst[i] = Long.reverseBytes(src[i]);
90
}
91
}
92
93
public void test_copy_longs_reversed(long[] dst, long[] src) {
94
for (int i = 0; i < src.length; i++) {
95
dst[i] = 1 + Long.reverseBytes(src[i]);
96
}
97
}
98
99
public void test_copy_longs_store_reversed(long[] dst, long[] src) {
100
for (int i = 0; i < src.length; i++) {
101
dst[i] = Long.reverseBytes(1 + src[i]);
102
}
103
}
104
105
public void test() throws Exception {
106
int up_limit = 90000;
107
108
109
//test single
110
111
for (int loop = 0; loop < up_limit; loop++) {
112
_j = test_int_reversed(_k);
113
if (_j != _ir) {
114
throw new Exception("Interger.reverseBytes failed " + _j + " iter " + loop);
115
}
116
_l = test_long_reversed(_m);
117
if (_l != _lr) {
118
throw new Exception("Long.reverseBytes failed " + _l + " iter " + loop);
119
}
120
}
121
122
// test scalar load/store
123
for (int loop = 0; loop < up_limit; loop++) {
124
125
test_copy_ints(_arr_i_cp, _arr_i);
126
for (int j = 0; j < _arr_i.length; j++) {
127
if (_arr_i_cp[j] != _ir) {
128
throw new Exception("Interger.reverseBytes failed test_copy_ints iter " + loop);
129
}
130
}
131
132
test_copy_ints_reversed(_arr_i_cp, _arr_i);
133
for (int j = 0; j < _arr_i.length; j++) {
134
if (_arr_i_cp[j] != _ir1) {
135
throw new Exception("Interger.reverseBytes failed test_copy_ints_reversed iter " + loop);
136
}
137
}
138
test_copy_ints_store_reversed(_arr_i_cp, _arr_i);
139
for (int j = 0; j < _arr_i.length; j++) {
140
if (_arr_i_cp[j] != _ir2) {
141
throw new Exception("Interger.reverseBytes failed test_copy_ints_store_reversed iter " + loop);
142
}
143
}
144
145
test_copy_longs(_arr_l_cp, _arr_l);
146
for (int j = 0; j < _arr_i.length; j++) {
147
if (_arr_l_cp[j] != _lr) {
148
throw new Exception("Long.reverseBytes failed test_copy_longs iter " + loop);
149
}
150
}
151
test_copy_longs_reversed(_arr_l_cp, _arr_l);
152
for (int j = 0; j < _arr_i.length; j++) {
153
if (_arr_l_cp[j] != _lr1) {
154
throw new Exception("Long.reverseBytes failed test_copy_longs_reversed iter " + loop);
155
}
156
}
157
test_copy_longs_store_reversed(_arr_l_cp, _arr_l);
158
for (int j = 0; j < _arr_i.length; j++) {
159
if (_arr_l_cp[j] != _lr2) {
160
throw new Exception("Long.reverseBytes failed test_copy_longs_store_reversed iter " + loop);
161
}
162
}
163
164
}
165
}
166
167
public static void main(String args[]) {
168
try {
169
Test6431242 t = new Test6431242();
170
t.init();
171
t.test();
172
System.out.println("Passed");
173
} catch (Exception e) {
174
e.printStackTrace();
175
System.out.println("Failed");
176
}
177
}
178
}
179
180