Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java @ 9793:b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 22 May 2013 16:27:25 +0200 |
parents | 06dc2d2324d6 |
children | ae6f0c381087 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes.extended; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
25 import static com.oracle.graal.api.meta.LocationIdentity.*; |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
26 import static com.oracle.graal.graph.UnsafeAccess.*; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
27 |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
28 import java.lang.reflect.*; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
29 |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
30 import sun.misc.*; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
31 |
6498
6bc8aa568cb9
moved MemoryBarriers to com.oracle.graal.api.code
Doug Simon <doug.simon@oracle.com>
parents:
6458
diff
changeset
|
32 import com.oracle.graal.api.code.*; |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
9526
diff
changeset
|
33 import com.oracle.graal.api.meta.*; |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
34 import com.oracle.graal.graph.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.nodes.type.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 /** |
5167
591f8231aa82
removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
40 * Creates a memory barrier. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 */ |
6440
a0193f6d855c
MembarNode does not need state and has no side effects, so it needs not be a StateSplit
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6405
diff
changeset
|
42 public class MembarNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 private final int barriers; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
5167
591f8231aa82
removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
46 /** |
591f8231aa82
removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
47 * @param barriers a mask of the barrier constants defined in {@link MemoryBarriers} |
591f8231aa82
removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
48 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 public MembarNode(int barriers) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5375
diff
changeset
|
50 super(StampFactory.forVoid()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 this.barriers = barriers; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 @Override |
9526
ae5cd887e67c
Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8481
diff
changeset
|
55 public LocationIdentity[] getLocationIdentities() { |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
56 return new LocationIdentity[]{ANY_LOCATION}; |
7864
b66a826acf4b
add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents:
7556
diff
changeset
|
57 } |
b66a826acf4b
add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents:
7556
diff
changeset
|
58 |
b66a826acf4b
add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents:
7556
diff
changeset
|
59 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 public void generate(LIRGeneratorTool generator) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 generator.emitMembar(barriers); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
64 @SuppressWarnings("unused") |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 @NodeIntrinsic |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
66 public static void memoryBarrier(@ConstantNodeParameter int barriers) { |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
67 // Overly conservative but it doesn't matter in the interpreter |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
68 unsafe.putIntVolatile(dummyBase, dummyOffset, 0); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
69 unsafe.getIntVolatile(dummyBase, dummyOffset); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
70 } |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
71 |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
72 /** |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
73 * An unused field that it used to exercise barriers in the interpreter. This can be replaced |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
74 * with direct support for barriers in {@link Unsafe} if/when they become available. |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
75 */ |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
76 @SuppressWarnings("unused") private static int dummy; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
77 private static Object dummyBase; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
78 private static long dummyOffset; |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
79 static { |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
80 try { |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
81 Field dummyField = MembarNode.class.getDeclaredField("dummy"); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
82 dummyBase = unsafe.staticFieldBase(dummyField); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
83 dummyOffset = unsafe.staticFieldOffset(dummyField); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
84 } catch (Exception e) { |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
85 throw new GraalInternalError(e); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
86 } |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8452
diff
changeset
|
87 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 } |