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