author | vlivanov |
Fri, 26 Feb 2016 01:58:26 +0300 | |
changeset 36330 | 37a0f096251b |
child 36337 | d4b2f60ff5a9 |
permissions | -rw-r--r-- |
36330
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
1 |
/* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
4 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
10 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
15 |
* accompanied this code). |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
16 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
20 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
23 |
* questions. |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
24 |
*/ |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
25 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
26 |
/* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
27 |
* @test |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
28 |
* @summary tests on constant folding of unsafe get operations |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
29 |
* @library /testlibrary /test/lib |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
30 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
31 |
* @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
32 |
* -Xbatch -XX:-TieredCompilation |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
33 |
* -XX:+FoldStableValues |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
34 |
* UnsafeGetStableArrayElement |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
35 |
* |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
36 |
* @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
37 |
* -Xbatch -XX:+TieredCompilation -XX:TieredStopAtLevel=1 |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
38 |
* -XX:+FoldStableValues |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
39 |
* UnsafeGetStableArrayElement |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
40 |
*/ |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
41 |
import jdk.internal.misc.Unsafe; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
42 |
import jdk.internal.vm.annotation.Stable; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
43 |
import java.util.concurrent.Callable; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
44 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
45 |
import static jdk.internal.misc.Unsafe.*; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
46 |
import static jdk.test.lib.Asserts.*; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
47 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
48 |
public class UnsafeGetStableArrayElement { |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
49 |
@Stable static final byte[] STABLE_BYTE_ARRAY = new byte[] { 0, 1, -128, 127}; |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
50 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
51 |
static final Unsafe U = Unsafe.getUnsafe(); |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
52 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
53 |
static int testChar() { |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
54 |
return U.getChar(STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET + 0 * ARRAY_CHAR_INDEX_SCALE) + |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
55 |
U.getChar(STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET + 1 * ARRAY_CHAR_INDEX_SCALE); |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
56 |
} |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
57 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
58 |
static void run(Callable c) throws Exception { |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
59 |
Object first = c.call(); |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
60 |
for (int i = 0; i < 20_000; i++) { |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
61 |
assertEQ(first, c.call()); |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
62 |
} |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
63 |
} |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
64 |
|
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
65 |
public static void main(String[] args) throws Exception { |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
66 |
run(UnsafeGetStableArrayElement::testChar); |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
67 |
} |
37a0f096251b
8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff
changeset
|
68 |
} |