author | chegar |
Tue, 22 Mar 2016 15:26:07 +0000 | |
changeset 36694 | 182a5e7a519e |
parent 36209 | 8db2a78cbc29 |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
33449
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
1 |
/* |
36209
8db2a78cbc29
8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents:
34187
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33449
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
4 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
8 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
14 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
18 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
21 |
* questions. |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
22 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
23 |
*/ |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
24 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
25 |
/** |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
26 |
* @test |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
27 |
* @bug 8136473 |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
28 |
* @summary Mismatched stores on same slice possible with Unsafe.Put*Unaligned methods |
36209
8db2a78cbc29
8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents:
34187
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
33449
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
30 |
* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation TestUnsafeUnalignedMismatchedAccesses |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
31 |
* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses TestUnsafeUnalignedMismatchedAccesses |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
32 |
* |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
33 |
*/ |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
34 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
35 |
import java.lang.reflect.*; |
34187
eb97306813b5
8143059: TestUnsafeUnalignedMismatchedAccesses doens't build after 8139891
neliasso
parents:
33449
diff
changeset
|
36 |
import jdk.internal.misc.Unsafe; |
33449
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
37 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
38 |
public class TestUnsafeUnalignedMismatchedAccesses { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
39 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
40 |
private static final Unsafe UNSAFE; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
41 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
42 |
static { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
43 |
try { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
44 |
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
45 |
unsafeField.setAccessible(true); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
46 |
UNSAFE = (Unsafe) unsafeField.get(null); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
47 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
48 |
catch (Exception e) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
49 |
throw new AssertionError(e); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
50 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
51 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
52 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
53 |
static void test1(byte[] array) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
54 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
55 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET, 0); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
56 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
57 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
58 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
59 |
static void test2(byte[] array) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
60 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
61 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET+1, 0); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
62 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
63 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
64 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
65 |
static void test3(byte[] array) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
66 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
67 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET+2, 0); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
68 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
69 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
70 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
71 |
static void test4(byte[] array) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
72 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
73 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET+3, 0); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
74 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
75 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
76 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
77 |
static void test5(byte[] array) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
78 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
79 |
UNSAFE.putInt(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET, 0); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
80 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
81 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
82 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
83 |
// unaligned access and non escaping allocation |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
84 |
static void test6() { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
85 |
byte[] array = new byte[10]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
86 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET+1, -1); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
87 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
88 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
89 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
90 |
// unaligned access and non escaping allocation |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
91 |
static int test7() { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
92 |
byte[] array = new byte[10]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
93 |
UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET+1, -1); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
94 |
array[0] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
95 |
array[2] = 0; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
96 |
return array[0] + array[1] + array[2] + array[3] + array[4]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
97 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
98 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
99 |
// unaligned access with vectorization |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
100 |
static void test8(int[] src1, int[] src2, int[] dst) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
101 |
for (int i = 0; i < dst.length-1; i++) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
102 |
int res = src1[i] + src2[i]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
103 |
UNSAFE.putIntUnaligned(dst, UNSAFE.ARRAY_INT_BASE_OFFSET + i*4+1, res); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
104 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
105 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
106 |
|
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
107 |
static public void main(String[] args) throws Exception { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
108 |
byte[] byte_array = new byte[100]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
109 |
int[] int_array = new int[100]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
110 |
Object[] obj_array = new Object[100]; |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
111 |
TestUnsafeUnalignedMismatchedAccesses test = new TestUnsafeUnalignedMismatchedAccesses(); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
112 |
for (int i = 0; i < 20000; i++) { |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
113 |
test1(byte_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
114 |
test2(byte_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
115 |
test3(byte_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
116 |
test4(byte_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
117 |
test5(byte_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
118 |
test6(); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
119 |
test7(); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
120 |
test8(int_array, int_array, int_array); |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
121 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
122 |
} |
8aca535611b8
8136473: failed: no mismatched stores, except on raw memory: StoreB StoreI
roland
parents:
diff
changeset
|
123 |
} |