annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java @ 16897:f90dcdbbb75e

switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors changed Node fields to be protected or package-private (they can no longer be private) generate isLeafNode() and isOptionalInput()
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 Aug 2014 15:56:51 +0200
parents 06c15e88d383
children 0fe4732e5181
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
15316
Roland Schatz <roland.schatz@oracle.com>
parents: 15261 15314
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3733
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
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15145
diff changeset
25 import com.oracle.graal.compiler.common.type.*;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11880
diff changeset
26 import com.oracle.graal.graph.spi.*;
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: 16811
diff changeset
27 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.nodes.*;
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
29 import com.oracle.graal.nodes.calc.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.spi.*;
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
31 import com.oracle.graal.nodes.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 * The ValueAnchor instruction keeps non-CFG (floating) nodes above a certain point in the graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 */
15016
62e9e9c6ac38 fix floating unsafe load regression
Andreas Woess <andreas.woess@jku.at>
parents: 15006
diff changeset
36 @NodeInfo(allowedUsageTypes = {InputType.Anchor, InputType.Guard})
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16332
diff changeset
37 public class ValueAnchorNode extends FixedWithNextNode implements LIRLowerable, Simplifiable, Virtualizable, AnchoringNode, GuardingNode {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
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
39 @OptionalInput(InputType.Guard) ValueNode anchored;
9644
a230bfbd9497 Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
40
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
41 public static ValueAnchorNode create(ValueNode value) {
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
42 return new ValueAnchorNodeGen(value);
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
43 }
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
44
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
45 ValueAnchorNode(ValueNode value) {
15006
e60ea0bf468d remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15002
diff changeset
46 super(StampFactory.forVoid());
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
47 this.anchored = value;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 @Override
14950
d5a1206e1923 NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
51 public void generate(NodeLIRBuilderTool gen) {
5079
f8fe72ce4adc fix typos and remove unused parameters
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
52 // Nothing to emit, since this node is used for structural purposes only.
3733
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
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
55 public ValueNode getAnchoredNode() {
10807
d3a677910eea new ValueAnchorCleanupPhase to make lock elimination work again, tests for lock elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 10804
diff changeset
56 return anchored;
d3a677910eea new ValueAnchorCleanupPhase to make lock elimination work again, tests for lock elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 10804
diff changeset
57 }
d3a677910eea new ValueAnchorCleanupPhase to make lock elimination work again, tests for lock elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 10804
diff changeset
58
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 @Override
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
60 public void simplify(SimplifierTool tool) {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
61 while (next() instanceof ValueAnchorNode) {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
62 ValueAnchorNode nextAnchor = (ValueAnchorNode) next();
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
63 if (nextAnchor.anchored == anchored || nextAnchor.anchored == null) {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
64 // two anchors for the same anchored -> coalesce
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
65 // nothing anchored on the next anchor -> coalesce
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
66 nextAnchor.replaceAtUsages(this);
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
67 GraphUtil.removeFixedWithUnusedInputs(nextAnchor);
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
68 } else {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
69 break;
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
70 }
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
71 }
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
72 if (usages().isEmpty() && next() instanceof FixedAccessNode) {
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
73 FixedAccessNode currentNext = (FixedAccessNode) next();
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
74 if (currentNext.getGuard() == anchored) {
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
75 GraphUtil.removeFixedWithUnusedInputs(this);
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
76 return;
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
77 } else if (currentNext.getGuard() == null && anchored instanceof GuardNode && ((GuardNode) anchored).condition() instanceof IsNullNode) {
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
78 // coalesce null check guards into subsequent read/write
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
79 currentNext.setGuard((GuardingNode) anchored);
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
80 tool.addToWorkList(next());
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
81 return;
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
82 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 }
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
84
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
85 if (anchored != null && (anchored.isConstant() || anchored instanceof FixedNode)) {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
86 // anchoring fixed nodes and constants is useless
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
87 removeAnchoredNode();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 }
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
89
14714
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
90 if (anchored == null && usages().isEmpty()) {
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
91 // anchor is not necessary any more => remove.
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
92 GraphUtil.removeFixedWithUnusedInputs(this);
b602356a9cfc additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 11915
diff changeset
93 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
95
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
96 @Override
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
97 public void virtualize(VirtualizerTool tool) {
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15016
diff changeset
98 if (anchored != null && !(anchored instanceof BeginNode)) {
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
99 State state = tool.getObjectState(anchored);
7394
94f032472c28 changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents: 6710
diff changeset
100 if (state == null || state.getState() != EscapeState.Virtual) {
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
101 return;
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
102 }
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
103 }
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
104 tool.delete();
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 6329
diff changeset
105 }
11711
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
106
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
107 public void removeAnchoredNode() {
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
108 this.updateUsages(anchored, null);
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
109 this.anchored = null;
f12b418ebc74 Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11710
diff changeset
110 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 }