Mercurial > hg > graal-compiler
annotate test/compiler/membars/TestMemBarAcquire.java @ 21133:bbc6a4347faf
Merge with b95deaa6ebf6100bb5a95ab25b2fdc6b9ef5f420
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 27 Apr 2015 20:01:10 -0700 |
parents | 91cb3b8aac2b |
children |
rev | line source |
---|---|
20413
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
1 /* |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
4 * |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
8 * |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
13 * accompanied this code). |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
14 * |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
18 * |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
21 * questions. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
22 */ |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
23 |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
24 /* |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
25 * @test TestMemBarAcquire |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
26 * @bug 8048879 |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
27 * @summary "Tests optimization of MemBarAcquireNodes" |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
28 * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestMemBarAcquire |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
29 */ |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
30 public class TestMemBarAcquire { |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
31 private volatile static Object defaultObj = new Object(); |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
32 private Object obj; |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
33 |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
34 public TestMemBarAcquire(Object param) { |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
35 // Volatile load. MemBarAcquireNode is added after the |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
36 // load to prevent following loads from floating up past. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
37 // StoreNode is added to store result of load in 'obj'. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
38 this.obj = defaultObj; |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
39 // Overrides 'obj' and therefore makes previous StoreNode |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
40 // and the corresponding LoadNode useless. However, the |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
41 // LoadNode is still connected to the MemBarAcquireNode |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
42 // that should now release the reference. |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
43 this.obj = param; |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
44 } |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
45 |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
46 public static void main(String[] args) throws Exception { |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
47 // Make sure TestMemBarAcquire::<init> is compiled |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
48 for (int i = 0; i < 100000; ++i) { |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
49 TestMemBarAcquire p = new TestMemBarAcquire(new Object()); |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
50 } |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
51 } |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
52 } |
91cb3b8aac2b
8048879: "unexpected yanked node" opto/postaloc.cpp:139
thartmann
parents:
diff
changeset
|
53 |