author | chegar |
Tue, 22 Mar 2016 15:26:07 +0000 | |
changeset 36694 | 182a5e7a519e |
parent 33627 | c5b7455f846e |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
1 |
// |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
30218
diff
changeset
|
2 |
// Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
3 |
// Copyright (c) 2015, Red Hat Inc. All rights reserved. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
4 |
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
5 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
6 |
// This code is free software; you can redistribute it and/or modify it |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
7 |
// under the terms of the GNU General Public License version 2 only, as |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
8 |
// published by the Free Software Foundation. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
9 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
10 |
// This code is distributed in the hope that it will be useful, but WITHOUT |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
11 |
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
12 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
13 |
// version 2 for more details (a copy is included in the LICENSE file that |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
14 |
// accompanied this code). |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
15 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
16 |
// You should have received a copy of the GNU General Public License version |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
17 |
// 2 along with this work; if not, write to the Free Software Foundation, |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
18 |
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
19 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
20 |
// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
21 |
// or visit www.oracle.com if you need additional information or have any |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
22 |
// questions. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
23 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
24 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
25 |
|
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
26 |
import java.nio.BufferOverflowException; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
27 |
import java.nio.BufferUnderflowException; |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
28 |
import java.nio.ByteBuffer; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
29 |
import static java.nio.ByteOrder.BIG_ENDIAN; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
30 |
import static java.nio.ByteOrder.LITTLE_ENDIAN; |
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
31 |
import java.nio.ByteOrder; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
32 |
import java.util.Arrays; |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
33 |
import java.util.Random; |
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
34 |
import jdk.test.lib.Utils; |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
35 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
36 |
/** |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
37 |
* @test |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
38 |
* @bug 8026049 |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
39 |
* @library /testlibrary |
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
40 |
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses -Djdk.test.lib.random.seed=0 HeapByteBufferTest |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
41 |
* @run main/othervm -Djdk.test.lib.random.seed=0 HeapByteBufferTest |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
42 |
* @summary Verify that byte buffers are correctly accessed. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
43 |
*/ |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
44 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
45 |
// A wrapper for a ByteBuffer which maintains a backing array and a |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
46 |
// position. Whenever this wrapper is written the backing array and |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
47 |
// the wrapped byte buffer are updated together, and whenever it is |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
48 |
// read we check that the ByteBuffer and the backing array are identical. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
49 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
50 |
class MyByteBuffer { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
51 |
final ByteBuffer buf; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
52 |
final byte[] bytes; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
53 |
int pos; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
54 |
ByteOrder byteOrder = BIG_ENDIAN; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
55 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
56 |
MyByteBuffer(ByteBuffer buf, byte[] bytes) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
57 |
this.buf = buf; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
58 |
this.bytes = Arrays.copyOf(bytes, bytes.length); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
59 |
pos = 0; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
60 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
61 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
62 |
public final MyByteBuffer order(ByteOrder bo) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
63 |
byteOrder = bo; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
64 |
buf.order(bo); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
65 |
return this; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
66 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
67 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
68 |
static MyByteBuffer wrap(byte[] bytes) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
69 |
return new MyByteBuffer(ByteBuffer.wrap(bytes), bytes); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
70 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
71 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
72 |
int capacity() { return bytes.length; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
73 |
int position() { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
74 |
if (buf.position() != pos) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
75 |
throw new RuntimeException(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
76 |
return buf.position(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
77 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
78 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
79 |
byte[] array() { return buf.array(); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
80 |
byte[] backingArray() { return bytes; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
81 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
82 |
private static byte long7(long x) { return (byte)(x >> 56); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
83 |
private static byte long6(long x) { return (byte)(x >> 48); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
84 |
private static byte long5(long x) { return (byte)(x >> 40); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
85 |
private static byte long4(long x) { return (byte)(x >> 32); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
86 |
private static byte long3(long x) { return (byte)(x >> 24); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
87 |
private static byte long2(long x) { return (byte)(x >> 16); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
88 |
private static byte long1(long x) { return (byte)(x >> 8); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
89 |
private static byte long0(long x) { return (byte)(x ); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
90 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
91 |
private static byte int3(int x) { return (byte)(x >> 24); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
92 |
private static byte int2(int x) { return (byte)(x >> 16); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
93 |
private static byte int1(int x) { return (byte)(x >> 8); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
94 |
private static byte int0(int x) { return (byte)(x ); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
95 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
96 |
private static byte short1(short x) { return (byte)(x >> 8); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
97 |
private static byte short0(short x) { return (byte)(x ); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
98 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
99 |
byte _get(long i) { return bytes[(int)i]; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
100 |
void _put(long i, byte x) { bytes[(int)i] = x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
101 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
102 |
private void putLongX(long a, long x) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
103 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
104 |
x = Long.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
105 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
106 |
_put(a + 7, long7(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
107 |
_put(a + 6, long6(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
108 |
_put(a + 5, long5(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
109 |
_put(a + 4, long4(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
110 |
_put(a + 3, long3(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
111 |
_put(a + 2, long2(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
112 |
_put(a + 1, long1(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
113 |
_put(a , long0(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
114 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
115 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
116 |
private void putIntX(long a, int x) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
117 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
118 |
x = Integer.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
119 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
120 |
_put(a + 3, int3(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
121 |
_put(a + 2, int2(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
122 |
_put(a + 1, int1(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
123 |
_put(a , int0(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
124 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
125 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
126 |
private void putShortX(int bi, short x) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
127 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
128 |
x = Short.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
129 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
130 |
_put(bi , short0(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
131 |
_put(bi + 1, short1(x)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
132 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
133 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
134 |
static private int makeInt(byte b3, byte b2, byte b1, byte b0) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
135 |
return (((b3 ) << 24) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
136 |
((b2 & 0xff) << 16) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
137 |
((b1 & 0xff) << 8) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
138 |
((b0 & 0xff) )); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
139 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
140 |
int getIntX(long a) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
141 |
int x = makeInt(_get(a + 3), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
142 |
_get(a + 2), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
143 |
_get(a + 1), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
144 |
_get(a)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
145 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
146 |
x = Integer.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
147 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
148 |
return x; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
149 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
150 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
151 |
static private long makeLong(byte b7, byte b6, byte b5, byte b4, |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
152 |
byte b3, byte b2, byte b1, byte b0) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
153 |
{ |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
154 |
return ((((long)b7 ) << 56) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
155 |
(((long)b6 & 0xff) << 48) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
156 |
(((long)b5 & 0xff) << 40) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
157 |
(((long)b4 & 0xff) << 32) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
158 |
(((long)b3 & 0xff) << 24) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
159 |
(((long)b2 & 0xff) << 16) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
160 |
(((long)b1 & 0xff) << 8) | |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
161 |
(((long)b0 & 0xff) )); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
162 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
163 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
164 |
long getLongX(long a) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
165 |
long x = makeLong(_get(a + 7), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
166 |
_get(a + 6), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
167 |
_get(a + 5), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
168 |
_get(a + 4), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
169 |
_get(a + 3), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
170 |
_get(a + 2), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
171 |
_get(a + 1), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
172 |
_get(a)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
173 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
174 |
x = Long.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
175 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
176 |
return x; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
177 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
178 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
179 |
static private short makeShort(byte b1, byte b0) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
180 |
return (short)((b1 << 8) | (b0 & 0xff)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
181 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
182 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
183 |
short getShortX(long a) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
184 |
short x = makeShort(_get(a + 1), |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
185 |
_get(a )); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
186 |
if (byteOrder == BIG_ENDIAN) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
187 |
x = Short.reverseBytes(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
188 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
189 |
return x; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
190 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
191 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
192 |
double getDoubleX(long a) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
193 |
long x = getLongX(a); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
194 |
return Double.longBitsToDouble(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
195 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
196 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
197 |
double getFloatX(long a) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
198 |
int x = getIntX(a); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
199 |
return Float.intBitsToFloat(x); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
200 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
201 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
202 |
void ck(long x, long y) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
203 |
if (x != y) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
204 |
throw new RuntimeException(" x = " + Long.toHexString(x) + ", y = " + Long.toHexString(y)); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
205 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
206 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
207 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
208 |
void ck(double x, double y) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
209 |
if (x == x && y == y && x != y) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
210 |
ck(x, y); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
211 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
212 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
213 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
214 |
long getLong(int i) { ck(buf.getLong(i), getLongX(i)); return buf.getLong(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
215 |
int getInt(int i) { ck(buf.getInt(i), getIntX(i)); return buf.getInt(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
216 |
short getShort(int i) { ck(buf.getShort(i), getShortX(i)); return buf.getShort(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
217 |
char getChar(int i) { ck(buf.getChar(i), (char)getShortX(i)); return buf.getChar(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
218 |
double getDouble(int i) { ck(buf.getDouble(i), getDoubleX(i)); return buf.getDouble(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
219 |
float getFloat(int i) { ck(buf.getFloat(i), getFloatX(i)); return buf.getFloat(i); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
220 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
221 |
void putLong(int i, long x) { buf.putLong(i, x); putLongX(i, x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
222 |
void putInt(int i, int x) { buf.putInt(i, x); putIntX(i, x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
223 |
void putShort(int i, short x) { buf.putShort(i, x); putShortX(i, x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
224 |
void putChar(int i, char x) { buf.putChar(i, x); putShortX(i, (short)x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
225 |
void putDouble(int i, double x) { buf.putDouble(i, x); putLongX(i, Double.doubleToRawLongBits(x)); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
226 |
void putFloat(int i, float x) { buf.putFloat(i, x); putIntX(i, Float.floatToRawIntBits(x)); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
227 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
228 |
long getLong() { ck(buf.getLong(buf.position()), getLongX(pos)); long x = buf.getLong(); pos += 8; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
229 |
int getInt() { ck(buf.getInt(buf.position()), getIntX(pos)); int x = buf.getInt(); pos += 4; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
230 |
short getShort() { ck(buf.getShort(buf.position()), getShortX(pos)); short x = buf.getShort(); pos += 2; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
231 |
char getChar() { ck(buf.getChar(buf.position()), (char)getShortX(pos)); char x = buf.getChar(); pos += 2; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
232 |
double getDouble() { ck(buf.getDouble(buf.position()), getDoubleX(pos)); double x = buf.getDouble(); pos += 8; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
233 |
float getFloat() { ck(buf.getFloat(buf.position()), getFloatX(pos)); float x = buf.getFloat(); pos += 4; return x; } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
234 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
235 |
void putLong(long x) { putLongX(pos, x); pos += 8; buf.putLong(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
236 |
void putInt(int x) { putIntX(pos, x); pos += 4; buf.putInt(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
237 |
void putShort(short x) { putShortX(pos, x); pos += 2; buf.putShort(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
238 |
void putChar(char x) { putShortX(pos, (short)x); pos += 2; buf.putChar(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
239 |
void putDouble(double x) { putLongX(pos, Double.doubleToRawLongBits(x)); pos += 8; buf.putDouble(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
240 |
void putFloat(float x) { putIntX(pos, Float.floatToRawIntBits(x)); pos += 4; buf.putFloat(x); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
241 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
242 |
void rewind() { pos = 0; buf.rewind(); } |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
243 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
244 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
245 |
public class HeapByteBufferTest implements Runnable { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
246 |
|
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
247 |
Random random = Utils.getRandomInstance(); |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
248 |
MyByteBuffer data = MyByteBuffer.wrap(new byte[1024]); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
249 |
|
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
250 |
int randomOffset(Random r, MyByteBuffer buf, int size) { |
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
251 |
return r.nextInt(buf.capacity() - size); |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
252 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
253 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
254 |
long iterations; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
255 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
256 |
HeapByteBufferTest(long iterations) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
257 |
this.iterations = iterations; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
258 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
259 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
260 |
// The core of the test. Walk over the buffer reading and writing |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
261 |
// random data, XORing it as we go. We can detect writes in the |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
262 |
// wrong place, writes which are too long or too short, and reads |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
263 |
// or writes of the wrong data, |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
264 |
void step(Random r) { |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
265 |
data.order((r.nextInt() & 1) != 0 ? BIG_ENDIAN : LITTLE_ENDIAN); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
266 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
267 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
268 |
while (data.position() < data.capacity()) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
269 |
data.putLong(data.getLong() ^ random.nextLong()); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
270 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
271 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
272 |
while (data.position() < data.capacity()) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
273 |
data.putInt(data.getInt() ^ random.nextInt()); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
274 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
275 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
276 |
while (data.position() < data.capacity()) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
277 |
data.putShort((short)(data.getShort() ^ random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
278 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
279 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
280 |
while (data.position() < data.capacity()) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
281 |
data.putChar((char)(data.getChar() ^ random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
282 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
283 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
284 |
while (data.position() < data.capacity()) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
285 |
data.putDouble(combine(data.getDouble(), random.nextLong())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
286 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
287 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
288 |
data.rewind(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
289 |
while (data.position() < data.capacity()) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
290 |
data.putFloat(combine(data.getFloat(), random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
291 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
292 |
for (int i = 0; i < 100; i++) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
293 |
int offset = randomOffset(r, data, 8); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
294 |
data.putLong(offset, data.getLong(offset) ^ random.nextLong()); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
295 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
296 |
for (int i = 0; i < 100; i++) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
297 |
int offset = randomOffset(r, data, 4); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
298 |
data.putInt(offset, data.getInt(offset) ^ random.nextInt()); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
299 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
300 |
for (int i = 0; i < 100; i++) { |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
301 |
int offset = randomOffset(r, data, 2); |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
302 |
data.putShort(offset, (short)(data.getShort(offset) ^ random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
303 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
304 |
for (int i = 0; i < 100; i++) { |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
305 |
int offset = randomOffset(r, data, 2); |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
306 |
data.putChar(offset, (char)(data.getChar(offset) ^ random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
307 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
308 |
for (int i = 0; i < 100; i++) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
309 |
int offset = randomOffset(r, data, 8); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
310 |
data.putDouble(offset, combine(data.getDouble(offset), random.nextLong())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
311 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
312 |
for (int i = 0; i < 100; i++) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
313 |
int offset = randomOffset(r, data, 4); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
314 |
data.putFloat(offset, combine(data.getFloat(offset), random.nextInt())); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
315 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
316 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
317 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
318 |
// XOR the bit pattern of a double and a long, returning the |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
319 |
// result as a double. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
320 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
321 |
// We convert signalling NaNs to quiet NaNs. We need to do this |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
322 |
// because some platforms (in particular legacy 80x87) do not |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
323 |
// provide transparent conversions between integer and |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
324 |
// floating-point types even when using raw conversions but |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
325 |
// quietly convert sNaN to qNaN. This causes spurious test |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
326 |
// failures when the template interpreter uses 80x87 and the JITs |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
327 |
// use XMM registers. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
328 |
// |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
329 |
public double combine(double prev, long bits) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
330 |
bits ^= Double.doubleToRawLongBits(prev); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
331 |
double result = Double.longBitsToDouble(bits); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
332 |
if (Double.isNaN(result)) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
333 |
result = Double.longBitsToDouble(bits | 0x8000000000000l); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
334 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
335 |
return result; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
336 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
337 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
338 |
// XOR the bit pattern of a float and an int, returning the result |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
339 |
// as a float. Convert sNaNs to qNaNs. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
340 |
public Float combine(float prev, int bits) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
341 |
bits ^= Float.floatToRawIntBits(prev); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
342 |
Float result = Float.intBitsToFloat(bits); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
343 |
if (Float.isNaN(result)) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
344 |
result = Float.intBitsToFloat(bits | 0x400000); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
345 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
346 |
return result; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
347 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
348 |
|
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
349 |
enum PrimitiveType { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
350 |
BYTE(1), CHAR(2), SHORT(2), INT(4), LONG(8), FLOAT(4), DOUBLE(8); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
351 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
352 |
public final int size; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
353 |
PrimitiveType(int size) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
354 |
this.size = size; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
355 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
356 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
357 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
358 |
void getOne(ByteBuffer b, PrimitiveType t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
359 |
switch (t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
360 |
case BYTE: b.get(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
361 |
case CHAR: b.getChar(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
362 |
case SHORT: b.getShort(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
363 |
case INT: b.getInt(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
364 |
case LONG: b.getLong(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
365 |
case FLOAT: b.getFloat(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
366 |
case DOUBLE: b.getDouble(); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
367 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
368 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
369 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
370 |
void putOne(ByteBuffer b, PrimitiveType t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
371 |
switch (t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
372 |
case BYTE: b.put((byte)0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
373 |
case CHAR: b.putChar('0'); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
374 |
case SHORT: b.putShort((short)0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
375 |
case INT: b.putInt(0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
376 |
case LONG: b.putLong(0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
377 |
case FLOAT: b.putFloat(0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
378 |
case DOUBLE: b.putDouble(0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
379 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
380 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
381 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
382 |
void getOne(ByteBuffer b, PrimitiveType t, int index) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
383 |
switch (t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
384 |
case BYTE: b.get(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
385 |
case CHAR: b.getChar(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
386 |
case SHORT: b.getShort(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
387 |
case INT: b.getInt(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
388 |
case LONG: b.getLong(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
389 |
case FLOAT: b.getFloat(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
390 |
case DOUBLE: b.getDouble(index); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
391 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
392 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
393 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
394 |
void putOne(ByteBuffer b, PrimitiveType t, int index) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
395 |
switch (t) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
396 |
case BYTE: b.put(index, (byte)0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
397 |
case CHAR: b.putChar(index, '0'); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
398 |
case SHORT: b.putShort(index, (short)0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
399 |
case INT: b.putInt(index, 0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
400 |
case LONG: b.putLong(index, 0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
401 |
case FLOAT: b.putFloat(index, 0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
402 |
case DOUBLE: b.putDouble(index, 0); break; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
403 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
404 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
405 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
406 |
void checkBoundaryConditions() { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
407 |
for (int i = 0; i < 100; i++) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
408 |
int bufSize = random.nextInt(16); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
409 |
byte[] bytes = new byte[bufSize]; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
410 |
ByteBuffer buf = ByteBuffer.wrap(bytes); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
411 |
for (int j = 0; j < 100; j++) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
412 |
int offset = random.nextInt(32) - 8; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
413 |
for (PrimitiveType t : PrimitiveType.values()) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
414 |
int threw = 0; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
415 |
try { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
416 |
try { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
417 |
buf.position(offset); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
418 |
getOne(buf, t); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
419 |
} catch (BufferUnderflowException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
420 |
if (offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
421 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
422 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
423 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
424 |
} catch (IllegalArgumentException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
425 |
if (offset >= 0 && offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
426 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
427 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
428 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
429 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
430 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
431 |
try { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
432 |
buf.position(offset); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
433 |
putOne(buf, t); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
434 |
} catch (BufferOverflowException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
435 |
if (offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
436 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
437 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
438 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
439 |
} catch (IllegalArgumentException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
440 |
if (offset >= 0 && offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
441 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
442 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
443 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
444 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
445 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
446 |
try { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
447 |
putOne(buf, t, offset); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
448 |
} catch (IndexOutOfBoundsException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
449 |
if (offset >= 0 && offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
450 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
451 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
452 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
453 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
454 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
455 |
try { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
456 |
getOne(buf, t, offset); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
457 |
} catch (IndexOutOfBoundsException e) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
458 |
if (offset >= 0 && offset + t.size < bufSize) |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
459 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
460 |
("type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, e); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
461 |
threw++; |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
462 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
463 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
464 |
if (threw == 0) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
465 |
// Make sure that we should not have thrown. |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
466 |
if (offset < 0 || offset + t.size > bufSize) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
467 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
468 |
("should have thrown but did not, type = " + t |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
469 |
+ ", offset = " + offset + ", bufSize = " + bufSize); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
470 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
471 |
} else if (threw != 4) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
472 |
// If one of the {get,put} operations threw |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
473 |
// due to an invalid offset then all four of |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
474 |
// them should have thrown. |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
475 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
476 |
("should have thrown but at least one did not, type = " + t |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
477 |
+ ", offset = " + offset + ", bufSize = " + bufSize); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
478 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
479 |
} catch (Throwable th) { |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
480 |
throw new RuntimeException |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
481 |
("unexpected throw: type = " + t + ", offset = " + offset + ", bufSize = " + bufSize, th); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
482 |
|
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
483 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
484 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
485 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
486 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
487 |
} |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
488 |
|
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
489 |
public void run() { |
33627
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
490 |
checkBoundaryConditions(); |
c5b7455f846e
8079459: JCK test api/java_nio/ByteBuffer/index.html#GetPutXXX start failing after JDK-8026049
aph
parents:
30604
diff
changeset
|
491 |
|
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
492 |
for (int i = 0; i < data.capacity(); i += 8) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
493 |
data.putLong(i, random.nextLong()); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
494 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
495 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
496 |
for (int i = 0; i < iterations; i++) { |
30218
53a798b8b063
8076625: IndexOutOfBoundsException in HeapByteBufferTest.java
thartmann
parents:
30209
diff
changeset
|
497 |
step(random); |
30209
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
498 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
499 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
500 |
if (!Arrays.equals(data.array(), data.backingArray())) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
501 |
throw new RuntimeException(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
502 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
503 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
504 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
505 |
public static void main(String[] args) { |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
506 |
// The number of iterations is high to ensure that tiered |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
507 |
// compilation kicks in all the way up to C2. |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
508 |
long iterations = 100000; |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
509 |
if (args.length > 0) |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
510 |
iterations = Long.parseLong(args[0]); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
511 |
|
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
512 |
new HeapByteBufferTest(iterations).run(); |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
513 |
} |
8ea30dc99369
8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents:
diff
changeset
|
514 |
} |