Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java @ 19471:880717e44675
Use typed NodeClass in node constructors.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 18 Feb 2015 12:12:26 +0100 |
parents | 61d3cb8e1280 |
children | 8fc336a04d77 |
rev | line source |
---|---|
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@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:
15145
diff
changeset
|
26 import com.oracle.graal.compiler.common.type.*; |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
27 import com.oracle.graal.graph.*; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 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
|
29 import com.oracle.graal.nodeinfo.*; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.extended.*; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.util.*; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
33 @NodeInfo |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 public abstract class AbstractFixedGuardNode extends DeoptimizingFixedWithNextNode implements Simplifiable, GuardingNode { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19403
diff
changeset
|
36 public static final NodeClass<AbstractFixedGuardNode> TYPE = NodeClass.get(AbstractFixedGuardNode.class); |
16957
27b40d2f8f8a
relaxed access control from package to protected for elements that need to be accessed in generated subclasses in disjoint packages
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
37 @Input(InputType.Condition) protected LogicNode condition; |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
38 protected final DeoptimizationReason reason; |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
39 protected final DeoptimizationAction action; |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16957
diff
changeset
|
40 protected boolean negated; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 public LogicNode condition() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 return condition; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 public void setCondition(LogicNode x) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 updateUsages(condition, x); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 condition = x; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19410
diff
changeset
|
51 protected AbstractFixedGuardNode(NodeClass<? extends AbstractFixedGuardNode> c, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
52 super(c, StampFactory.forVoid()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 this.action = action; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 this.negated = negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 this.condition = condition; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
56 this.reason = deoptReason; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 public DeoptimizationReason getReason() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 return reason; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 public DeoptimizationAction getAction() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 return action; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
67 public boolean isNegated() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
68 return negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
69 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
71 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 public String toString(Verbosity verbosity) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
73 if (verbosity == Verbosity.Name && negated) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
74 return "!" + super.toString(verbosity); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
75 } else { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
76 return super.toString(verbosity); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
77 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
78 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
79 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
80 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
81 public void simplify(SimplifierTool tool) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
82 while (condition instanceof LogicNegationNode) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
83 LogicNegationNode negation = (LogicNegationNode) condition; |
16220
4182366b8eed
rename getInput() to getValue() in LogicNegationNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
84 setCondition(negation.getValue()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
85 negated = !negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
86 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
87 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
88 |
13521
56452e07874f
Change signature of lowerToIf.
Roland Schatz <roland.schatz@oracle.com>
parents:
13505
diff
changeset
|
89 public DeoptimizeNode lowerToIf() { |
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
|
90 FixedNode currentNext = next(); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
91 setNext(null); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
92 DeoptimizeNode deopt = graph().add(new DeoptimizeNode(action, reason)); |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
13521
diff
changeset
|
93 deopt.setStateBefore(stateBefore()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 IfNode ifNode; |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
95 AbstractBeginNode noDeoptSuccessor; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 if (negated) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
97 ifNode = graph().add(new IfNode(condition, deopt, currentNext, 0)); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
98 noDeoptSuccessor = ifNode.falseSuccessor(); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
99 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
100 ifNode = graph().add(new IfNode(condition, currentNext, deopt, 1)); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 noDeoptSuccessor = ifNode.trueSuccessor(); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 ((FixedWithNextNode) predecessor()).setNext(ifNode); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 this.replaceAtUsages(noDeoptSuccessor); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
105 GraphUtil.killWithUnusedFloatingInputs(this); |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13154
diff
changeset
|
106 |
13521
56452e07874f
Change signature of lowerToIf.
Roland Schatz <roland.schatz@oracle.com>
parents:
13505
diff
changeset
|
107 return deopt; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
108 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
109 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
110 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
111 public boolean canDeoptimize() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
112 return true; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
113 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
114 } |