annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java @ 19526:8fc336a04d77

Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 22:22:55 +0100
parents 61d3cb8e1280
children cba35d171cd1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
1 /*
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
4 *
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
8 *
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
13 * accompanied this code).
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
14 *
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
18 *
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
21 * questions.
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
22 */
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.nodes.java;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
24
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15132
diff changeset
26 import com.oracle.graal.compiler.common.type.*;
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
27 import com.oracle.graal.graph.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16438
diff changeset
28 import com.oracle.graal.nodeinfo.*;
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.nodes.*;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.nodes.extended.*;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.nodes.spi.*;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
32
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
33 /**
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
34 * Represents the lowered version of an atomic compare-and-swap operation{@code CompareAndSwapNode}.
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
35 */
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
36 @NodeInfo(allowedUsageTypes = {InputType.Value, InputType.Memory})
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
37 public final class LoweredCompareAndSwapNode extends FixedAccessNode implements StateSplit, LIRLowerable, MemoryCheckpoint.Single {
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
38
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
39 public static final NodeClass<LoweredCompareAndSwapNode> TYPE = NodeClass.create(LoweredCompareAndSwapNode.class);
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
40 @Input ValueNode expectedValue;
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
41 @Input ValueNode newValue;
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
42 @OptionalInput(InputType.State) FrameState stateAfter;
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
43
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
44 public FrameState stateAfter() {
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
45 return stateAfter;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
46 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
47
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
48 public void setStateAfter(FrameState x) {
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
49 assert x == null || x.isAlive() : "frame state must be in a graph";
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
50 updateUsages(stateAfter, x);
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
51 stateAfter = x;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
52 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
53
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
54 public boolean hasSideEffect() {
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
55 return true;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
56 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
57
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
58 public ValueNode getExpectedValue() {
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
59 return expectedValue;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
60 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
61
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
62 public ValueNode getNewValue() {
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
63 return newValue;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
64 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
65
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
66 public LoweredCompareAndSwapNode(ValueNode object, LocationNode location, ValueNode expectedValue, ValueNode newValue, BarrierType barrierType) {
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
67 super(TYPE, object, location, StampFactory.forKind(Kind.Boolean.getStackKind()), barrierType);
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 13289
diff changeset
68 assert expectedValue.getKind() == newValue.getKind();
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
69 this.expectedValue = expectedValue;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
70 this.newValue = newValue;
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
71 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
72
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
73 @Override
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
74 public LocationIdentity getLocationIdentity() {
11214
2eb2f1ae8180 Remove duplicate fields from LoweredCompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10849
diff changeset
75 return location().getLocationIdentity();
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
76 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
77
14976
82399ac30721 make implicit null checking optional for Access nodes (fixes CAS crash)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14950
diff changeset
78 public boolean canNullCheck() {
82399ac30721 make implicit null checking optional for Access nodes (fixes CAS crash)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14950
diff changeset
79 return false;
82399ac30721 make implicit null checking optional for Access nodes (fixes CAS crash)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14950
diff changeset
80 }
82399ac30721 make implicit null checking optional for Access nodes (fixes CAS crash)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14950
diff changeset
81
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
82 @Override
14950
d5a1206e1923 NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
83 public void generate(NodeLIRBuilderTool gen) {
15024
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15002
diff changeset
84 assert getNewValue().stamp().isCompatible(getExpectedValue().stamp());
15132
Roland Schatz <roland.schatz@oracle.com>
parents: 15024 15130
diff changeset
85 Value address = location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object()));
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17450
diff changeset
86 Value result = gen.getLIRGeneratorTool().emitCompareAndSwap(address, gen.operand(getExpectedValue()), gen.operand(getNewValue()), JavaConstant.INT_1, JavaConstant.INT_0);
15024
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15002
diff changeset
87 gen.setResult(this, result);
10849
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
88 }
23a7cbee48d0 Add LoweredCompareAndSwapNode
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
diff changeset
89 }