Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java @ 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
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 11:34:38 +0200 |
parents | 5d468add216f |
children | 06c15e88d383 |
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.*; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
27 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
|
28 import com.oracle.graal.nodeinfo.*; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.nodes.extended.*; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.util.*; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
31 |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
32 @NodeInfo |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 public abstract class AbstractFixedGuardNode extends DeoptimizingFixedWithNextNode implements Simplifiable, GuardingNode { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 |
15001 | 35 @Input(InputType.Condition) private LogicNode condition; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 private final DeoptimizationReason reason; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
37 private final DeoptimizationAction action; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
38 private boolean negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
39 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
40 public LogicNode condition() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 return condition; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 public void setCondition(LogicNode x) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 updateUsages(condition, x); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 condition = x; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 protected AbstractFixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { |
15006
e60ea0bf468d
remove StampFactory.dependency/extension/condition
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
50 super(StampFactory.forVoid()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
51 this.action = action; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 this.negated = negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 this.condition = condition; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 this.reason = deoptReason; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
56 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 public DeoptimizationReason getReason() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 return reason; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 public DeoptimizationAction getAction() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 return action; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 public boolean isNegated() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 return negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
67 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
68 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
69 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 public String toString(Verbosity verbosity) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
71 if (verbosity == Verbosity.Name && negated) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 return "!" + super.toString(verbosity); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
73 } else { |
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 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
76 } |
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 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
79 public void simplify(SimplifierTool tool) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
80 while (condition instanceof LogicNegationNode) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
81 LogicNegationNode negation = (LogicNegationNode) condition; |
16220
4182366b8eed
rename getInput() to getValue() in LogicNegationNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
82 setCondition(negation.getValue()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
83 negated = !negated; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
84 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
85 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
86 |
13521
56452e07874f
Change signature of lowerToIf.
Roland Schatz <roland.schatz@oracle.com>
parents:
13505
diff
changeset
|
87 public DeoptimizeNode lowerToIf() { |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
88 FixedNode next = next(); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
89 setNext(null); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
90 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
|
91 deopt.setStateBefore(stateBefore()); |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
92 IfNode ifNode; |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15006
diff
changeset
|
93 BeginNode noDeoptSuccessor; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 if (negated) { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
95 ifNode = graph().add(new IfNode(condition, deopt, next, 0)); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 noDeoptSuccessor = ifNode.falseSuccessor(); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
97 } else { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
98 ifNode = graph().add(new IfNode(condition, next, deopt, 1)); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
99 noDeoptSuccessor = ifNode.trueSuccessor(); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
100 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 ((FixedWithNextNode) predecessor()).setNext(ifNode); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 this.replaceAtUsages(noDeoptSuccessor); |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 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
|
104 |
13521
56452e07874f
Change signature of lowerToIf.
Roland Schatz <roland.schatz@oracle.com>
parents:
13505
diff
changeset
|
105 return deopt; |
13154
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
106 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
107 |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
108 @Override |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
109 public boolean canDeoptimize() { |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
110 return true; |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
111 } |
1e22792abdbc
Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
112 } |