annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java @ 19167:ce23018b970a

rename: makeNonNull -> nullCheckedValue
author Doug Simon <doug.simon@oracle.com>
date Fri, 06 Feb 2015 12:11:22 +0100
parents ac9ad302e12f
children 7e2c87dae93e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.nodes;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
27 import static com.oracle.graal.compiler.common.type.StampFactory.*;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
28
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15009
diff changeset
30 import com.oracle.graal.compiler.common.type.*;
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 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: 11880
diff changeset
32 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: 16248
diff changeset
33 import com.oracle.graal.nodeinfo.*;
10652
aca7481e71d1 Create new intrinsic for GuardingPiNode for null check guarding. Fix ArraySubstitutions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10635
diff changeset
34 import com.oracle.graal.nodes.calc.*;
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.nodes.extended.*;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.nodes.spi.*;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.nodes.type.*;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 /**
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 * A node that changes the stamp of its input based on some condition being true.
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 */
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 @NodeInfo(nameTemplate = "GuardingPi(!={p#negated}) {p#reason/s}")
18998
ec0733b5a90a Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
43 public final class GuardingPiNode extends FixedWithNextNode implements Lowerable, Virtualizable, Canonicalizable, ValueProxy {
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44
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
45 @Input ValueNode object;
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
46 @Input(InputType.Condition) LogicNode condition;
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
47 protected final DeoptimizationReason reason;
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
48 protected final DeoptimizationAction action;
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
49 protected final Stamp piStamp;
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
50 protected boolean negated;
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 public ValueNode object() {
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 return object;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55
10818
0a5cfcf27c35 add condition accessor to GuardingPiNode
Mick Jordan <mick.jordan@oracle.com>
parents: 10762
diff changeset
56 public LogicNode condition() {
0a5cfcf27c35 add condition accessor to GuardingPiNode
Mick Jordan <mick.jordan@oracle.com>
parents: 10762
diff changeset
57 return condition;
0a5cfcf27c35 add condition accessor to GuardingPiNode
Mick Jordan <mick.jordan@oracle.com>
parents: 10762
diff changeset
58 }
0a5cfcf27c35 add condition accessor to GuardingPiNode
Mick Jordan <mick.jordan@oracle.com>
parents: 10762
diff changeset
59
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
60 public boolean isNegated() {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
61 return negated;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
62 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
63
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
64 public DeoptimizationReason getReason() {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
65 return reason;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
66 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
67
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
68 public DeoptimizationAction getAction() {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
69 return action;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
70 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15260
diff changeset
71
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
72 /**
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
73 * Returns a node whose stamp is guaranteed to be {@linkplain StampTool#isPointerNonNull(Stamp)
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
74 * non-null}. If {@code value} already has such a stamp, then it is returned. Otherwise a fixed
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
75 * node guarding {@code value} is returned where the guard performs a null check.
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
76 */
19167
ce23018b970a rename: makeNonNull -> nullCheckedValue
Doug Simon <doug.simon@oracle.com>
parents: 19155
diff changeset
77 public static ValueNode nullCheckedValue(ValueNode value) {
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
78 ObjectStamp receiverStamp = (ObjectStamp) value.stamp();
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
79 if (!StampTool.isPointerNonNull(receiverStamp)) {
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
80 IsNullNode condition = value.graph().unique(new IsNullNode(value));
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
81 Stamp stamp = receiverStamp.join(objectNonNull());
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
82 return new GuardingPiNode(value, condition, true, NullCheckException, InvalidateReprofile, stamp);
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
83 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
84 return value;
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
85 }
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 18998
diff changeset
86
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
87 public GuardingPiNode(ValueNode object) {
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
88 this(object, object.graph().unique(new IsNullNode(object)), true, DeoptimizationReason.NullCheckException, DeoptimizationAction.None, object.stamp().join(StampFactory.objectNonNull()));
10652
aca7481e71d1 Create new intrinsic for GuardingPiNode for null check guarding. Fix ArraySubstitutions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10635
diff changeset
89 }
aca7481e71d1 Create new intrinsic for GuardingPiNode for null check guarding. Fix ArraySubstitutions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10635
diff changeset
90
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
91 public GuardingPiNode(ValueNode object, ValueNode condition, boolean negateCondition, DeoptimizationReason reason, DeoptimizationAction action, Stamp stamp) {
10692
bebc9672f45e stamp for GuardingPiNode is determined by caller of constructor, not within constructor
Doug Simon <doug.simon@oracle.com>
parents: 10652
diff changeset
92 super(stamp);
bebc9672f45e stamp for GuardingPiNode is determined by caller of constructor, not within constructor
Doug Simon <doug.simon@oracle.com>
parents: 10652
diff changeset
93 assert stamp != null;
15754
45285c8eccbd Never use the current node's stamp in ValueNode.inferStamp overrides.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15388
diff changeset
94 this.piStamp = stamp;
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 this.object = object;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 this.condition = (LogicNode) condition;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 this.reason = reason;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 this.action = action;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 this.negated = negateCondition;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 @Override
11579
ae619d70bf4b Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11578
diff changeset
103 public void lower(LoweringTool tool) {
13283
17c9afa0bfcb Allow GuardLoweringPhase, FrameStateAssignementPhase and the different lowerings to work with graph at any valid guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13190
diff changeset
104 GuardingNode guard = tool.createGuard(next(), condition, reason, action, negated);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
105 ValueAnchorNode anchor = graph().add(new ValueAnchorNode((ValueNode) guard));
16195
e34d8c5fa927 do not create PiNode when lowering GuardingPiNode if the latter has no usages
Doug Simon <doug.simon@oracle.com>
parents: 15754
diff changeset
106 if (usages().isNotEmpty()) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
107 PiNode pi = graph().unique(new PiNode(object, stamp(), (ValueNode) guard));
16195
e34d8c5fa927 do not create PiNode when lowering GuardingPiNode if the latter has no usages
Doug Simon <doug.simon@oracle.com>
parents: 15754
diff changeset
108 replaceAtUsages(pi);
e34d8c5fa927 do not create PiNode when lowering GuardingPiNode if the latter has no usages
Doug Simon <doug.simon@oracle.com>
parents: 15754
diff changeset
109 }
11696
7f8c80e31750 Fix GuardingPiNode to preserve checkcast semantics also if value of checkcast is unused.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11690
diff changeset
110 graph().replaceFixedWithFixed(this, anchor);
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
114 public void virtualize(VirtualizerTool tool) {
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
115 State state = tool.getObjectState(object);
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
116 if (state != null && state.getState() == EscapeState.Virtual && StampTool.typeOrNull(this) != null && StampTool.typeOrNull(this).isAssignableFrom(state.getVirtualObject().type())) {
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
117 tool.replaceWithVirtual(state.getVirtualObject());
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
118 }
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
119 }
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
120
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12383
diff changeset
121 @Override
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122 public boolean inferStamp() {
15754
45285c8eccbd Never use the current node's stamp in ValueNode.inferStamp overrides.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15388
diff changeset
123 return updateStamp(piStamp.join(object().stamp()));
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 @Override
11880
9a747d8e0d0f broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
127 public Node canonical(CanonicalizerTool tool) {
14633
da2431cc1506 Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents: 13283
diff changeset
128 if (stamp() == StampFactory.illegal(object.getKind())) {
11798
2fbb9fd55dde made lowering recursive instead of iterative
Doug Simon <doug.simon@oracle.com>
parents: 11783
diff changeset
129 // The guard always fails
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
130 return new DeoptimizeNode(action, reason);
11783
9c98944c040b make GuardingPiNode canonicalize to a deopt when the guard is guaranteed to fail
Doug Simon <doug.simon@oracle.com>
parents: 11752
diff changeset
131 }
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 if (condition instanceof LogicConstantNode) {
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 LogicConstantNode c = (LogicConstantNode) condition;
11783
9c98944c040b make GuardingPiNode canonicalize to a deopt when the guard is guaranteed to fail
Doug Simon <doug.simon@oracle.com>
parents: 11752
diff changeset
134 if (c.getValue() == negated) {
11798
2fbb9fd55dde made lowering recursive instead of iterative
Doug Simon <doug.simon@oracle.com>
parents: 11783
diff changeset
135 // The guard always fails
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
136 return new DeoptimizeNode(action, reason);
13124
aa9be8414779 Canonicalize GuardingPiNode to PiNode when guard is unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12405
diff changeset
137 } else if (stamp().equals(object().stamp())) {
aa9be8414779 Canonicalize GuardingPiNode to PiNode when guard is unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12405
diff changeset
138 // The guard always succeeds, and does not provide new type information
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 return object;
13124
aa9be8414779 Canonicalize GuardingPiNode to PiNode when guard is unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12405
diff changeset
140 } else {
aa9be8414779 Canonicalize GuardingPiNode to PiNode when guard is unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12405
diff changeset
141 // The guard always succeeds, and provides new type information
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
142 return new PiNode(object, stamp());
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 return this;
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 }
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 @NodeIntrinsic
11376
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
149 public static <T> T guardingNonNull(T object) {
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
150 if (object == null) {
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
151 throw new NullPointerException();
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
152 }
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
153 return object;
a5429101c6bb added interpretable implementation to node intrinsics (GRAAL-430)
Doug Simon <doug.simon@oracle.com>
parents: 10818
diff changeset
154 }
10652
aca7481e71d1 Create new intrinsic for GuardingPiNode for null check guarding. Fix ArraySubstitutions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10635
diff changeset
155
aca7481e71d1 Create new intrinsic for GuardingPiNode for null check guarding. Fix ArraySubstitutions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10635
diff changeset
156 @NodeIntrinsic
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 public static native Object guardingPi(Object object, LogicNode condition, @ConstantNodeParameter boolean negateCondition, @ConstantNodeParameter DeoptimizationReason reason,
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 @ConstantNodeParameter DeoptimizationAction action, @ConstantNodeParameter Stamp stamp);
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 @Override
15009
e49f62425090 introduce non-ValueNode Proxy interface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
161 public ValueNode getOriginalNode() {
10762
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 10692
diff changeset
162 return object;
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 10692
diff changeset
163 }
10635
1fdcc58bff2a added GuardingPiNode
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 }