annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/GuardingPiReduction.java @ 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
author Doug Simon <doug.simon@oracle.com>
date Mon, 18 Aug 2014 14:04:21 +0200
parents cbd42807a31f
children ca81508f2a19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
1 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
4 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
8 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
13 * accompanied this code).
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
14 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
18 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
21 * questions.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
22 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.phases.common.cfs;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
24
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
26 import com.oracle.graal.debug.Debug;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.nodes.*;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.nodes.calc.IsNullNode;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.nodes.extended.GuardingNode;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.nodes.java.*;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.compiler.common.type.ObjectStamp;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.nodes.type.StampTool;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.phases.tiers.PhaseContext;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
34
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
35 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
36 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
37 * This class implements control-flow sensitive reductions for
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
38 * {@link com.oracle.graal.nodes.GuardingPiNode}.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
39 * </p>
15483
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
40 *
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
41 * <p>
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
42 * The laundry-list of all flow-sensitive reductions is summarized in
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
43 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
44 * </p>
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
45 *
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
46 * @see #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
47 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
48 public abstract class GuardingPiReduction extends BaseReduction {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
49
15585
4d5b1e7a4d93 [single-pass-iter] early pruning of state map, visit a whole method
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15483
diff changeset
50 public GuardingPiReduction(StartNode start, State initialState, PhaseContext context) {
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
51 super(start, initialState, context);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
52 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
53
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
54 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
55 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
56 * By the time a {@link com.oracle.graal.nodes.GuardingPiNode GuardingPiNode} is visited, the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
57 * available type refinements may allow reductions similar to those performed for
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
58 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
59 * CheckCastNode}.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
60 * </p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
61 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
62 * <ol>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
63 * <li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
64 * If the condition needs no reduction (ie, it's already a
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
65 * {@link com.oracle.graal.nodes.LogicConstantNode LogicConstantNode}), this method basically
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
66 * gives up (thus letting other phases take care of it).</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
67 * <li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
68 * Otherwise, an attempt is made to find a {@link com.oracle.graal.nodes.extended.GuardingNode}
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
69 * that implies the combination of (negated, condition) of the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
70 * {@link com.oracle.graal.nodes.GuardingPiNode} being visited. Details in
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
71 * {@link #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)}. If found, the node
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
72 * can be removed.</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
73 * <li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
74 * Otherwise, the node is lowered to a {@link com.oracle.graal.nodes.FixedGuardNode} and its
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
75 * usages replaced with {@link com.oracle.graal.nodes.PiNode}. Details in
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
76 * {@link #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)}.</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
77 * </ol>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
78 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
79 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
80 * Precondition: the condition hasn't been deverbosified yet.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
81 * </p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
82 *
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
83 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
84 protected final void visitGuardingPiNode(GuardingPiNode envelope) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
85
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
86 if (!FlowUtil.hasLegalObjectStamp(envelope)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
87 // this situation exercised by com.oracle.graal.jtt.optimize.NCE_FlowSensitive02
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
88 return;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
89 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
90 if (!FlowUtil.hasLegalObjectStamp(envelope.object())) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
91 return;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
92 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
93
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
94 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
95 * (1 of 3) Cover the case of GuardingPiNode(LogicConstantNode, ...)
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
96 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
97
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
98 if (envelope.condition() instanceof LogicConstantNode) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
99 if (FlowUtil.alwaysFails(envelope.isNegated(), envelope.condition())) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
100 state.impossiblePath();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
101 // let GuardingPiNode(false).canonical() prune the dead-code control-path
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
102 return;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
103 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
104 // if not always-fails and condition-constant, then it always-succeeds!
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
105 assert FlowUtil.alwaysSucceeds(envelope.isNegated(), envelope.condition());
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
106 // let GuardingPiNode(true).canonical() replaceAtUsages
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
107 return;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
108 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
109
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
110 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
111 * The trick used in visitFixedGuardNode to look up an equivalent GuardingNode for the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
112 * combination of (negated, condition) at hand doesn't work for GuardingPiNode, because the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
113 * condition showing up here (a ShortCircuitOrNode that can be detected by
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
114 * CastCheckExtractor) doesn't appear as key in trueFacts, falseFacts. Good thing we have
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
115 * CastCheckExtractor!
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
116 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
117
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
118 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
119 * (2 of 3) Cover the case of the condition known-to-be-false or known-to-be-true, but not
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
120 * LogicConstantNode.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
121 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
122 * If deverbosify(condition) == falseConstant, it would be safe to set:
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
123 * `envelope.setCondition(falseConstant)` (only the API won't allow).
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
124 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
125 * On the other hand, it's totally unsafe to do something like that for trueConstant. What
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
126 * we can do about that case is the province of `tryRemoveGuardingPiNode(envelope)`
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
127 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
128
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
129 if (tryRemoveGuardingPiNode(envelope)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
130 return;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
131 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
132
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
133 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
134 * Experience has shown that an attempt to eliminate the current GuardingPiNode by using a
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
135 * GuardingNode already in scope and with equivalent condition (grabbed from `trueFacts`
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
136 * resp. `falseFacts`) proves futile. Therefore we're not even attempting that here.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
137 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
138
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
139 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
140 * (3 of 3) Neither always-succeeds nor always-fails, ie we don't known. Converting to
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
141 * FixedGuardNode allows tracking the condition via a GuardingNode, thus potentially
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
142 * triggering simplifications down the road.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
143 */
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
144 FixedGuardNode fixedGuard = graph.add(FixedGuardNode.create(envelope.condition(), envelope.getReason(), envelope.getAction(), envelope.isNegated()));
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
145 graph.addBeforeFixed(envelope, fixedGuard);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
146
15483
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
147 /*
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
148 *
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
149 * TODO This lowering is currently performed unconditionally: it might occur no
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
150 * flow-sensitive reduction is enabled down the road
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
151 */
01a8820c1228 [flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15429
diff changeset
152
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
153 if (!FlowUtil.lacksUsages(envelope)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
154 // not calling wrapInPiNode() because we don't want to rememberSubstitution()
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
155 PiNode replacement = graph.unique(PiNode.create(envelope.object(), envelope.stamp(), fixedGuard));
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
156 reasoner.added.add(replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
157 // before removing the GuardingPiNode replace its usages
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
158 envelope.replaceAtUsages(replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
159 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
160
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
161 graph.removeFixed(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
162
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
163 state.addFact(!fixedGuard.isNegated(), fixedGuard.condition(), fixedGuard);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
164
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
165 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
166
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
167 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
168 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
169 * Based on flow-sensitive knowledge, two pre-requisites have to be fulfilled in order to remove
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
170 * a {@link com.oracle.graal.nodes.GuardingPiNode}:
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
171 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
172 * <ul>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
173 * <li>the condition must refer only to the payload of the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
174 * {@link com.oracle.graal.nodes.GuardingPiNode}</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
175 * <li>the condition must check properties about which the state tracks not only a true/false
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
176 * answer, but also an anchor witnessing that fact</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
177 * <li>the condition may not check anything else beyond what's stated in the items above.</li>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
178 * </ul>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
179 * </p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
180 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
181 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
182 * Provided a condition as above can be reduced to a constant (and an anchor obtained in the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
183 * process), this method replaces all usages of the
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
184 * {@link com.oracle.graal.nodes.GuardingPiNode} (necessarily of
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: 16207
diff changeset
185 * {@link com.oracle.graal.nodeinfo.InputType#Value}) with a
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: 16207
diff changeset
186 * {@link com.oracle.graal.nodes.PiNode} that wraps the payload and the anchor in question.
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
187 * </p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
188 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
189 * <p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
190 * Precondition: the condition hasn't been deverbosified yet.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
191 * </p>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
192 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
193 * @see #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
194 *
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
195 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
196 private boolean tryRemoveGuardingPiNode(GuardingPiNode envelope) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
197
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
198 LogicNode cond = envelope.condition();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
199 ValueNode payload = envelope.object();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
200
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
201 ObjectStamp outgoingStamp = (ObjectStamp) envelope.stamp();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
202 ObjectStamp payloadStamp = (ObjectStamp) payload.stamp();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
203
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
204 if (isNullCheckOn(cond, payload)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
205 if (envelope.isNegated()) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
206 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
207 * GuardingPiNode succeeds if payload non-null
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
208 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
209 if (!outgoingStamp.equals(FlowUtil.asNonNullStamp(payloadStamp))) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
210 warnAboutOutOfTheBlueGuardingPiNode(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
211 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
212 return tryRemoveGuardingPiNodeNonNullCond(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
213 } else {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
214 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
215 * GuardingPiNode succeeds if payload null
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
216 */
15429
edf0c031da76 [flow-sensitive] renaming: untrivialNull -> nonTrivialNull
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15427
diff changeset
217 ValueNode replacement = StampTool.isObjectAlwaysNull(payload) ? payload : reasoner.nonTrivialNull(payload);
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
218 if (replacement != null) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
219 // replacement == null means !isKnownNull(payload)
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
220 removeGuardingPiNode(envelope, replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
221 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
222 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
223 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
224 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
225 } else if (CastCheckExtractor.isInstanceOfCheckOn(cond, payload)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
226 if (envelope.isNegated()) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
227 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
228 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
229 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
230 * GuardingPiNode succeeds if payload instanceof <something>
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
231 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
232 InstanceOfNode io = (InstanceOfNode) cond;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
233 assert io.type() != null;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
234 Witness w = state.typeInfo(payload);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
235 if (w != null && w.isNonNull() && isEqualOrMorePrecise(w.type(), io.type())) {
15427
3af4870a67e4 [flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15393
diff changeset
236 ValueNode d = reasoner.downcast(payload);
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
237 removeGuardingPiNode(envelope, d);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
238 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
239 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
240 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
241 } else if (cond instanceof ShortCircuitOrNode) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
242 if (envelope.isNegated()) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
243 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
244 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
245 CastCheckExtractor cce = CastCheckExtractor.extract(cond);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
246 if (cce == null || cce.subject != payload) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
247 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
248 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
249 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
250 * GuardingPiNode succeeds if payload check-casts toType
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
251 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
252 return tryRemoveGuardingPiNodeCheckCastCond(envelope, cce.type);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
253 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
254
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
255 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
256 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
257
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
258 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
259 * Porcelain method.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
260 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
261 * This method handles the case where the GuardingPiNode succeeds if payload known to be
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
262 * non-null.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
263 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
264 * @see #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
265 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
266 private boolean tryRemoveGuardingPiNodeNonNullCond(GuardingPiNode envelope) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
267
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
268 ValueNode payload = envelope.object();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
269
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
270 if (state.isNull(payload)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
271 // the GuardingPiNode fails always
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
272 postponedDeopts.addDeoptBefore(envelope, envelope.getReason());
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
273 state.impossiblePath();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
274 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
275 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
276
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
277 if (StampTool.isObjectNonNull(payload)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
278 // payload needs no downcasting, it satisfies as-is the GuardingPiNode's condition.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
279 if (precisionLoss(envelope, payload)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
280 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
281 * TODO The GuardingPiNode has an outgoing stamp whose narrowing goes beyond what
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
282 * the condition checks. That's suspicious.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
283 */
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
284 PiNode replacement = graph.unique(PiNode.create(payload, envelope.stamp()));
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
285 reasoner.added.add(replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
286 removeGuardingPiNode(envelope, replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
287 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
288 } else {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
289 removeGuardingPiNode(envelope, payload);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
290 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
291 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
292 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
293 // if a non-null witness available, the GuardingPiNode can be removed
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
294
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
295 Witness w = state.typeInfo(payload);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
296 GuardingNode nonNullAnchor = (w != null && w.isNonNull()) ? w.guard() : null;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
297 if (nonNullAnchor != null) {
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
298 PiNode replacement = graph.unique(PiNode.create(payload, envelope.stamp(), nonNullAnchor.asNode()));
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
299 reasoner.added.add(replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
300 removeGuardingPiNode(envelope, replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
301 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
302 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
303
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
304 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
305 * TODO What about, nodes that always denote non-null values? (Even though their stamp
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
306 * forgot to make that clear) Candidates: ObjectGetClassNode, Parameter(0) on instance
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
307 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
308
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
309 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
310 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
311
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
312 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
313 * Porcelain method.
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
314 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
315 * This method handles the case where the GuardingPiNode succeeds if payload null or its actual
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
316 * type equal or subtype of `toType`
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
317 *
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
318 * @see #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
319 *
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
320 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
321 private boolean tryRemoveGuardingPiNodeCheckCastCond(GuardingPiNode envelope, ResolvedJavaType toType) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
322 assert toType != null;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
323 ValueNode payload = envelope.object();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
324
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
325 ObjectStamp outgoingStamp = (ObjectStamp) envelope.stamp();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
326 ObjectStamp payloadStamp = (ObjectStamp) payload.stamp();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
327
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
328 if (!outgoingStamp.equals(FlowUtil.asRefinedStamp(payloadStamp, toType))) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
329 warnAboutOutOfTheBlueGuardingPiNode(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
330 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
331
15427
3af4870a67e4 [flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15393
diff changeset
332 ValueNode d = reasoner.downcast(payload);
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
333 if (d == null) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
334 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
335 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
336
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
337 if (StampTool.isObjectAlwaysNull(d)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
338 removeGuardingPiNode(envelope, d);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
339 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
340 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
341 ObjectStamp dStamp = (ObjectStamp) d.stamp();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
342 if (isEqualOrMorePrecise(dStamp.type(), toType)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
343 removeGuardingPiNode(envelope, d);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
344 return true;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
345 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
346 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
347 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
348
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
349 /*
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
350 * TODO There should be an assert in GuardingPiNode to detect that as soon as it happens
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
351 * (constructor, setStamp).
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
352 */
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
353 private static void warnAboutOutOfTheBlueGuardingPiNode(GuardingPiNode envelope) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
354 Debug.log(String.format("GuardingPiNode has an outgoing stamp whose narrowing goes beyond what its condition checks: %s", envelope));
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
355 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
356
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
357 private static boolean isNullCheckOn(LogicNode cond, ValueNode subject) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
358 if (!(cond instanceof IsNullNode)) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
359 return false;
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
360 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
361 IsNullNode isNull = (IsNullNode) cond;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15585
diff changeset
362 return isNull.getValue() == subject;
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
363 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
364
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
365 /**
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
366 * Porcelain method.
15393
1d3c23e675ed fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents: 15388
diff changeset
367 */
15388
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
368 private void removeGuardingPiNode(GuardingPiNode envelope, ValueNode replacement) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
369 assert !precisionLoss(envelope, replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
370 metricGuardingPiNodeRemoved.increment();
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
371 envelope.replaceAtUsages(replacement);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
372 assert FlowUtil.lacksUsages(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
373 graph.removeFixed(envelope);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
374 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
375
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
376 public static boolean isEqualOrMorePrecise(ResolvedJavaType a, ResolvedJavaType b) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
377 return a.equals(b) || FlowUtil.isMorePrecise(a, b);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
378 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
379
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
380 public static boolean isEqualOrMorePrecise(ObjectStamp a, ObjectStamp b) {
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
381 return a.equals(b) || FlowUtil.isMorePrecise(a, b);
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
382 }
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
383
769fc3629f59 Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff changeset
384 }