author | stsmirno |
Mon, 17 Oct 2016 18:54:12 -0400 | |
changeset 41705 | 332239c052cc |
parent 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
10736
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
10736
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
4 |
* |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
8 |
* |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
13 |
* accompanied this code). |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
14 |
* |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
18 |
* |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
21 |
* questions. |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
22 |
*/ |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
23 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
24 |
/** |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
25 |
* @test |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
26 |
* @bug 7100757 |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
27 |
* @summary The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27699
diff
changeset
|
30 |
* java.management |
40059 | 31 |
* |
32 |
* @run main/timeout=300 compiler.codegen.Test7100757 |
|
10736
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
33 |
*/ |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
34 |
|
40059 | 35 |
package compiler.codegen; |
36 |
||
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
37 |
import jdk.test.lib.Utils; |
40059 | 38 |
|
27453
9aeb9b97bef6
8044186: Introduce a reproducible random generator
iignatyev
parents:
10736
diff
changeset
|
39 |
import java.util.BitSet; |
9aeb9b97bef6
8044186: Introduce a reproducible random generator
iignatyev
parents:
10736
diff
changeset
|
40 |
import java.util.Random; |
10736
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
41 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
42 |
public class Test7100757 { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
43 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
44 |
public static final int NBITS = 256; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
45 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
46 |
public static void main(String[] args) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
47 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
48 |
BitSet bs = new BitSet(NBITS); |
27453
9aeb9b97bef6
8044186: Introduce a reproducible random generator
iignatyev
parents:
10736
diff
changeset
|
49 |
Random rnd = Utils.getRandomInstance(); |
10736
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
50 |
long[] ra = new long[(NBITS+63)/64]; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
51 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
52 |
for(int l=0; l < 5000000; l++) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
53 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
54 |
for(int r = 0; r < ra.length; r++) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
55 |
ra[r] = rnd.nextLong(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
56 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
57 |
test(ra, bs); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
58 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
59 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
60 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
61 |
static void test(long[] ra, BitSet bs) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
62 |
bs.clear(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
63 |
int bits_set = 0; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
64 |
for(int i = 0, t = 0, b = 0; i < NBITS; i++) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
65 |
long bit = 1L << b++; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
66 |
if((ra[t]&bit) != 0) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
67 |
bs.set(i); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
68 |
bits_set++; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
69 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
70 |
if(b == 64) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
71 |
t++; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
72 |
b = 0; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
73 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
74 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
75 |
// Test Long.bitCount() |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
76 |
int check_bits = bs.cardinality(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
77 |
if (check_bits != bits_set) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
78 |
String bs_str = bs.toString(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
79 |
System.err.printf("cardinality bits: %d != %d bs: %s\n", check_bits, bits_set, bs_str); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
80 |
System.exit(97); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
81 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
82 |
// Test Long.numberOfTrailingZeros() |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
83 |
check_bits = 0; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
84 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
85 |
check_bits++; |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
86 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
87 |
if (check_bits != bits_set) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
88 |
String bs_str = bs.toString(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
89 |
System.err.printf("nextSetBit bits: %d != %d bs: %s\n", check_bits, bits_set, bs_str); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
90 |
System.exit(97); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
91 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
92 |
// Test Long.numberOfLeadingZeros() |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
93 |
for(int i = bs.length(); i > 0; i = bs.length()) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
94 |
bs.clear(i-1); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
95 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
96 |
// Test Long.bitCount() |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
97 |
check_bits = bs.cardinality(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
98 |
if (check_bits != 0) { |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
99 |
String bs_str = bs.toString(); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
100 |
System.err.printf("after clear bits: %d != 0 bs: %s\n", check_bits, bs_str); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
101 |
System.exit(97); |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
102 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
103 |
} |
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
104 |
|
1a11ec86574e
7100757: The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
kvn
parents:
diff
changeset
|
105 |
}; |