author | stsmirno |
Mon, 17 Oct 2016 18:54:12 -0400 | |
changeset 41705 | 332239c052cc |
parent 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
5352 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
15864
diff
changeset
|
2 |
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. |
5352 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5352
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5352
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5352
diff
changeset
|
21 |
* questions. |
5352 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6431242 |
|
40059 | 27 |
* |
28 |
* @run main compiler.codegen.Test6431242 |
|
5352 | 29 |
*/ |
30 |
||
40059 | 31 |
package compiler.codegen; |
32 |
||
33 |
public class Test6431242 { |
|
5352 | 34 |
|
40059 | 35 |
int _len = 8; |
36 |
int[] _arr_i = new int[_len]; |
|
37 |
long[] _arr_l = new long[_len]; |
|
5352 | 38 |
|
40059 | 39 |
int[] _arr_i_cp = new int[_len]; |
40 |
long[] _arr_l_cp = new long[_len]; |
|
5352 | 41 |
|
40059 | 42 |
int _k = 0x12345678; |
43 |
int _j = 0; |
|
44 |
int _ir = 0x78563412; |
|
45 |
int _ir1 = 0x78563413; |
|
46 |
int _ir2 = 0x79563412; |
|
5352 | 47 |
|
40059 | 48 |
long _m = 0x123456789abcdef0L; |
49 |
long _l = 0L; |
|
50 |
long _lr = 0xf0debc9a78563412L; |
|
51 |
long _lr1 = 0xf0debc9a78563413L; |
|
52 |
long _lr2 = 0xf1debc9a78563412L; |
|
5352 | 53 |
|
40059 | 54 |
void init() { |
55 |
for (int i = 0; i < _arr_i.length; i++) { |
|
56 |
_arr_i[i] = _k; |
|
57 |
_arr_l[i] = _m; |
|
58 |
} |
|
5352 | 59 |
} |
60 |
||
40059 | 61 |
public int test_int_reversed(int i) { |
62 |
return Integer.reverseBytes(i); |
|
63 |
} |
|
5352 | 64 |
|
40059 | 65 |
public long test_long_reversed(long i) { |
66 |
return Long.reverseBytes(i); |
|
67 |
} |
|
5352 | 68 |
|
40059 | 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 |
} |
|
5352 | 73 |
} |
74 |
||
40059 | 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 |
} |
|
5352 | 79 |
} |
80 |
||
40059 | 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 |
} |
|
5352 | 85 |
} |
86 |
||
40059 | 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 |
} |
|
5352 | 91 |
} |
40059 | 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 |
} |
|
5352 | 98 |
|
40059 | 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 |
} |
|
5352 | 103 |
} |
104 |
||
40059 | 105 |
public void test() throws Exception { |
106 |
int up_limit = 90000; |
|
5352 | 107 |
|
108 |
||
40059 | 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 |
} |
|
5352 | 131 |
|
40059 | 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 |
} |
|
5352 | 165 |
} |
166 |
||
40059 | 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"); |
|
5352 | 176 |
} |
177 |
} |
|
178 |
} |