Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AtomicReadAndWriteNode.java @ 15291:471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 22 Apr 2014 15:24:14 +0200 |
parents | 882f4cb7cfcf |
children | 5d468add216f |
rev | line source |
---|---|
15251 | 1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.nodes.java; | |
24 | |
15291
471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15261
diff
changeset
|
25 import static com.oracle.graal.compiler.common.UnsafeAccess.*; |
15251 | 26 |
27 import com.oracle.graal.api.meta.*; | |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15251
diff
changeset
|
28 import com.oracle.graal.compiler.common.type.*; |
15251 | 29 import com.oracle.graal.nodes.*; |
30 import com.oracle.graal.nodes.extended.*; | |
31 import com.oracle.graal.nodes.spi.*; | |
15291
471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15261
diff
changeset
|
32 |
15251 | 33 import sun.misc.*; |
34 | |
35 /** | |
36 * Represents an atomic read-and-write operation like {@link Unsafe#getAndSetInt(Object, long, int)} | |
37 * . | |
38 */ | |
39 public class AtomicReadAndWriteNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single { | |
40 | |
41 @Input private ValueNode object; | |
42 @Input private ValueNode offset; | |
43 @Input private ValueNode newValue; | |
44 | |
45 private final Kind valueKind; | |
46 private final LocationIdentity locationIdentity; | |
47 | |
48 public AtomicReadAndWriteNode(ValueNode object, ValueNode offset, ValueNode newValue, Kind valueKind, LocationIdentity locationIdentity) { | |
49 super(StampFactory.forKind(newValue.getKind())); | |
50 this.object = object; | |
51 this.offset = offset; | |
52 this.newValue = newValue; | |
53 this.valueKind = valueKind; | |
54 this.locationIdentity = locationIdentity; | |
55 } | |
56 | |
57 public ValueNode object() { | |
58 return object; | |
59 } | |
60 | |
61 public ValueNode offset() { | |
62 return offset; | |
63 } | |
64 | |
65 public ValueNode newValue() { | |
66 return newValue; | |
67 } | |
68 | |
69 public Kind getValueKind() { | |
70 return valueKind; | |
71 } | |
72 | |
73 public LocationIdentity getLocationIdentity() { | |
74 return locationIdentity; | |
75 } | |
76 | |
77 public void lower(LoweringTool tool) { | |
78 tool.getLowerer().lower(this, tool); | |
79 } | |
80 | |
81 @NodeIntrinsic | |
82 public static int getAndSetInt(Object object, long offset, int newValue, @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind, | |
83 @ConstantNodeParameter @SuppressWarnings("unused") LocationIdentity locationIdentity) { | |
84 return unsafe.getAndSetInt(object, offset, newValue); | |
85 } | |
86 | |
87 @NodeIntrinsic | |
88 public static long getAndSetLong(Object object, long offset, long newValue, @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind, | |
89 @ConstantNodeParameter @SuppressWarnings("unused") LocationIdentity locationIdentity) { | |
90 return unsafe.getAndSetLong(object, offset, newValue); | |
91 } | |
92 | |
93 @NodeIntrinsic | |
94 public static Object getAndSetObject(Object object, long offset, Object newValue, @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind, | |
95 @ConstantNodeParameter @SuppressWarnings("unused") LocationIdentity locationIdentity) { | |
96 return unsafe.getAndSetObject(object, offset, newValue); | |
97 } | |
98 | |
99 } |