annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.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 48c1ebd24120
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 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
25 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
26 import com.oracle.graal.graph.*;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11839
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: 16822
diff changeset
28 import com.oracle.graal.nodeinfo.*;
9859
30cab249529e When lowering a fixed guard, the usages should be forwarded to the floating guard instead of the value anchor.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
29 import com.oracle.graal.nodes.extended.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.spi.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14734
diff changeset
32 @NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}", allowedUsageTypes = {InputType.Guard})
18998
ec0733b5a90a Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18970
diff changeset
33 public final class FixedGuardNode extends AbstractFixedGuardNode implements Lowerable, IterableNodeType {
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
34 public static final NodeClass<FixedGuardNode> TYPE = NodeClass.create(FixedGuardNode.class);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
35
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18768
diff changeset
36 public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action) {
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7130
diff changeset
37 this(condition, deoptReason, action, false);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
38 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
39
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18768
diff changeset
40 public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) {
19396
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19100
diff changeset
41 super(TYPE, condition, deoptReason, action, negated);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
42 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
43
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
44 @Override
4310
72d099e5be61 more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents: 4309
diff changeset
45 public void simplify(SimplifierTool tool) {
13154
1e22792abdbc Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 13134
diff changeset
46 super.simplify(tool);
11409
1f302b6e16b0 Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 11398
diff changeset
47
13154
1e22792abdbc Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 13134
diff changeset
48 if (condition() instanceof LogicConstantNode) {
1e22792abdbc Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 13134
diff changeset
49 LogicConstantNode c = (LogicConstantNode) condition();
1e22792abdbc Make GuardNode extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 13134
diff changeset
50 if (c.getValue() == isNegated()) {
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
51 FixedNode currentNext = this.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
52 if (currentNext != null) {
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
53 tool.deleteBranch(currentNext);
10938
4c648c43150c Fix bug in FixedGuardNode simplification.
Roland Schatz <roland.schatz@oracle.com>
parents: 10722
diff changeset
54 }
4c648c43150c Fix bug in FixedGuardNode simplification.
Roland Schatz <roland.schatz@oracle.com>
parents: 10722
diff changeset
55
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18768
diff changeset
56 DeoptimizeNode deopt = graph().add(new DeoptimizeNode(getAction(), getReason()));
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: 13799
diff changeset
57 deopt.setStateBefore(stateBefore());
10938
4c648c43150c Fix bug in FixedGuardNode simplification.
Roland Schatz <roland.schatz@oracle.com>
parents: 10722
diff changeset
58 setNext(deopt);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 }
12543
37207d7e9056 Fix exception during canonicalization (GRAAL-554): when killing the branch following a FixedGuard, we can not count on this removing all of our usages because some of them may already be dead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12422
diff changeset
60 this.replaceAtUsages(null);
10938
4c648c43150c Fix bug in FixedGuardNode simplification.
Roland Schatz <roland.schatz@oracle.com>
parents: 10722
diff changeset
61 graph().removeFixed(this);
18768
c16786645355 Split negated short-circuit-or guard into two guards
Andreas Woess <andreas.woess@jku.at>
parents: 17450
diff changeset
62 } else if (condition() instanceof ShortCircuitOrNode) {
c16786645355 Split negated short-circuit-or guard into two guards
Andreas Woess <andreas.woess@jku.at>
parents: 17450
diff changeset
63 ShortCircuitOrNode shortCircuitOr = (ShortCircuitOrNode) condition();
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18902
diff changeset
64 if (isNegated() && hasNoUsages()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18768
diff changeset
65 graph().addAfterFixed(this, graph().add(new FixedGuardNode(shortCircuitOr.getY(), getReason(), getAction(), !shortCircuitOr.isYNegated())));
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18768
diff changeset
66 graph().replaceFixedWithFixed(this, graph().add(new FixedGuardNode(shortCircuitOr.getX(), getReason(), getAction(), !shortCircuitOr.isXNegated())));
18768
c16786645355 Split negated short-circuit-or guard into two guards
Andreas Woess <andreas.woess@jku.at>
parents: 17450
diff changeset
67 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 @Override
11579
ae619d70bf4b Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11578
diff changeset
72 public void lower(LoweringTool tool) {
19100
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
73 if (graph().getGuardsStage().allowsFloatingGuards()) {
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
74 /*
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
75 * Don't allow guards with action None and reason RuntimeConstraint to float. In cases
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
76 * where 2 guards are testing equivalent conditions they might be lowered at the same
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
77 * location. If the guard with the None action is lowered before the the other guard
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
78 * then the code will be stuck repeatedly deoptimizing without invalidating the code.
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
79 * Conditional elimination will eliminate the guard if it's truly redundant in this
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
80 * case.
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
81 */
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
82 if (getAction() != DeoptimizationAction.None || getReason() != DeoptimizationReason.RuntimeConstraint) {
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
83 ValueNode guard = tool.createGuard(this, condition(), getReason(), getAction(), isNegated()).asNode();
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
84 this.replaceAtUsages(guard);
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
85 ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode()));
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
86 graph().replaceFixedWithFixed(this, newAnchor);
d2ec5e56ed31 Only lowerToIf, when stage does not allow FloatingGuards
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19014
diff changeset
87 }
9498
d0b3fa50e306 lower FixedGuardNode to if-condition-deopt in after-guard lowering
Lukas Stadler <lukas.stadler@jku.at>
parents: 9440
diff changeset
88 } else {
13521
56452e07874f Change signature of lowerToIf.
Roland Schatz <roland.schatz@oracle.com>
parents: 13505
diff changeset
89 lowerToIf().lower(tool);
9498
d0b3fa50e306 lower FixedGuardNode to if-condition-deopt in after-guard lowering
Lukas Stadler <lukas.stadler@jku.at>
parents: 9440
diff changeset
90 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 }
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
92
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5387
diff changeset
93 @Override
10668
110444cbf1eb Make FixedGuardNode a DeoptimizingNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9859
diff changeset
94 public boolean canDeoptimize() {
110444cbf1eb Make FixedGuardNode a DeoptimizingNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9859
diff changeset
95 return true;
110444cbf1eb Make FixedGuardNode a DeoptimizingNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 9859
diff changeset
96 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }