annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java @ 22790:615f3bbbb174

Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 08 Oct 2015 17:41:33 -0700
parents 05183a084a08
children 5ce3e8996c83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
1 /*
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22573
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
4 *
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
8 *
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
13 * accompanied this code).
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
14 *
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
18 *
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
21 * questions.
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
22 */
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
23 package com.oracle.graal.phases.common;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
24
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
25 import java.util.List;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
26 import java.util.Map;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
27 import java.util.Objects;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
28 import java.util.Set;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
29
22790
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
30 import jdk.vm.ci.meta.JavaKind;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
31 import jdk.vm.ci.meta.ResolvedJavaMethod;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
32 import jdk.vm.ci.meta.ResolvedJavaType;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 22032
diff changeset
33
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
34 import com.oracle.graal.compiler.common.type.IntegerStamp;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
35 import com.oracle.graal.compiler.common.type.Stamp;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
36 import com.oracle.graal.compiler.common.type.StampFactory;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
37 import com.oracle.graal.debug.Debug;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
38 import com.oracle.graal.debug.Debug.Scope;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
39 import com.oracle.graal.debug.DebugMetric;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
40 import com.oracle.graal.graph.Node;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
41 import com.oracle.graal.nodes.AbstractBeginNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
42 import com.oracle.graal.nodes.AbstractEndNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
43 import com.oracle.graal.nodes.AbstractMergeNode;
16563
1e63cb55f61d Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16219
diff changeset
44 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
45 import com.oracle.graal.nodes.ConditionAnchorNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
46 import com.oracle.graal.nodes.ConstantNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
47 import com.oracle.graal.nodes.FixedGuardNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
48 import com.oracle.graal.nodes.FixedNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
49 import com.oracle.graal.nodes.GuardNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
50 import com.oracle.graal.nodes.IfNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
51 import com.oracle.graal.nodes.Invoke;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
52 import com.oracle.graal.nodes.LogicConstantNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
53 import com.oracle.graal.nodes.LogicNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
54 import com.oracle.graal.nodes.LoopBeginNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
55 import com.oracle.graal.nodes.LoopExitNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
56 import com.oracle.graal.nodes.PhiNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
57 import com.oracle.graal.nodes.PiNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
58 import com.oracle.graal.nodes.ProxyNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
59 import com.oracle.graal.nodes.ShortCircuitOrNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
60 import com.oracle.graal.nodes.StartNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
61 import com.oracle.graal.nodes.StructuredGraph;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
62 import com.oracle.graal.nodes.ValueNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
63 import com.oracle.graal.nodes.ValuePhiNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
64 import com.oracle.graal.nodes.calc.ConditionalNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
65 import com.oracle.graal.nodes.calc.FloatingNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
66 import com.oracle.graal.nodes.calc.IntegerBelowNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
67 import com.oracle.graal.nodes.calc.IntegerEqualsNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
68 import com.oracle.graal.nodes.calc.IsNullNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
69 import com.oracle.graal.nodes.calc.ObjectEqualsNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
70 import com.oracle.graal.nodes.extended.GuardingNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
71 import com.oracle.graal.nodes.extended.LoadHubNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
72 import com.oracle.graal.nodes.extended.ValueAnchorNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
73 import com.oracle.graal.nodes.java.CheckCastNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
74 import com.oracle.graal.nodes.java.InstanceOfNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
75 import com.oracle.graal.nodes.java.MethodCallTargetNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
76 import com.oracle.graal.nodes.java.TypeSwitchNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
77 import com.oracle.graal.nodes.spi.ValueProxy;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
78 import com.oracle.graal.nodes.type.StampTool;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
79 import com.oracle.graal.nodes.util.GraphUtil;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
80 import com.oracle.graal.phases.Phase;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
81 import com.oracle.graal.phases.graph.MergeableState;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
82 import com.oracle.graal.phases.graph.SinglePassNodeIterator;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
83
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
84 public class ConditionalEliminationPhase extends Phase {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
85
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
86 private static final DebugMetric metricConditionRegistered = Debug.metric("ConditionRegistered");
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
87 private static final DebugMetric metricTypeRegistered = Debug.metric("TypeRegistered");
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
88 private static final DebugMetric metricNullnessRegistered = Debug.metric("NullnessRegistered");
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
89 private static final DebugMetric metricObjectEqualsRegistered = Debug.metric("ObjectEqualsRegistered");
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
90 private static final DebugMetric metricCheckCastRemoved = Debug.metric("CheckCastRemoved");
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
91 private static final DebugMetric metricInstanceOfRemoved = Debug.metric("InstanceOfRemoved");
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
92 private static final DebugMetric metricNullCheckRemoved = Debug.metric("NullCheckRemoved");
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
93 private static final DebugMetric metricObjectEqualsRemoved = Debug.metric("ObjectEqualsRemoved");
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
94 private static final DebugMetric metricGuardsRemoved = Debug.metric("GuardsRemoved");
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
95
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
96 private StructuredGraph graph;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
97
18487
0f4813e0b4a9 Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
98 public ConditionalEliminationPhase() {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
99 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
100
22573
74b3e5c0209c suppressed -Xlint:try warnings
Doug Simon <doug.simon@oracle.com>
parents: 22400
diff changeset
101 @SuppressWarnings("try")
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
102 @Override
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
103 protected void run(StructuredGraph inputGraph) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
104 graph = inputGraph;
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
105 try (Scope s = Debug.scope("ConditionalElimination")) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
106 new ConditionalElimination(graph.start(), new State()).apply();
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
107 } catch (Throwable e) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
108 throw Debug.handle(e);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
109 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
110 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
111
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
112 /**
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
113 * Type information about a {@code value} that it produced by a {@code guard}. Usage of the
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
114 * stamp information requires adopting the guard. Usually this means replacing an existing guard
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
115 * with this guard.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
116 */
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
117 static class GuardedStamp {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
118 private final ValueNode value;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
119 private final Stamp stamp;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
120 private final GuardNode guard;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
121
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
122 GuardedStamp(ValueNode value, Stamp stamp, GuardNode guard) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
123 this.value = value;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
124 this.stamp = stamp;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
125 this.guard = guard;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
126 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
127
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
128 public Stamp getStamp() {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
129 return stamp;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
130 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
131
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
132 public GuardNode getGuard() {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
133 return guard;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
134 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
135
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
136 public ValueNode getValue() {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
137 return value;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
138 }
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
139 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
140
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13873
diff changeset
141 public static class State extends MergeableState<State> implements Cloneable {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
142
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
143 private Map<ValueNode, ResolvedJavaType> knownTypes;
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
144 private Set<ValueNode> knownNonNull;
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
145 private Set<ValueNode> knownNull;
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
146 private Map<LogicNode, GuardingNode> trueConditions;
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
147 private Map<LogicNode, GuardingNode> falseConditions;
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15311
diff changeset
148 private Map<ValueNode, GuardedStamp> valueConstraints;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
149
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
150 public State() {
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
151 this.knownTypes = Node.newIdentityMap();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
152 this.knownNonNull = Node.newSet();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
153 this.knownNull = Node.newSet();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
154 this.trueConditions = Node.newIdentityMap();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
155 this.falseConditions = Node.newIdentityMap();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
156 this.valueConstraints = Node.newIdentityMap();
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
157 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
158
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
159 public State(State other) {
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
160 this.knownTypes = Node.newIdentityMap(other.knownTypes);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
161 this.knownNonNull = Node.newSet(other.knownNonNull);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
162 this.knownNull = Node.newSet(other.knownNull);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
163 this.trueConditions = Node.newIdentityMap(other.trueConditions);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
164 this.falseConditions = Node.newIdentityMap(other.falseConditions);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
165 this.valueConstraints = Node.newIdentityMap(other.valueConstraints);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
166 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
167
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
168 @Override
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
169 public boolean merge(AbstractMergeNode merge, List<State> withStates) {
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
170 Map<ValueNode, ResolvedJavaType> newKnownTypes = Node.newIdentityMap();
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
171 Map<LogicNode, GuardingNode> newTrueConditions = Node.newIdentityMap();
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
172 Map<LogicNode, GuardingNode> newFalseConditions = Node.newIdentityMap();
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
173 Map<ValueNode, GuardedStamp> newValueConstraints = Node.newIdentityMap();
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
174
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
175 Set<ValueNode> newKnownNull = Node.newSet(knownNull);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18333
diff changeset
176 Set<ValueNode> newKnownNonNull = Node.newSet(knownNonNull);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
177 for (State state : withStates) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
178 newKnownNull.retainAll(state.knownNull);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
179 newKnownNonNull.retainAll(state.knownNonNull);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
180 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
181
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
182 for (Map.Entry<ValueNode, ResolvedJavaType> entry : knownTypes.entrySet()) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
183 ValueNode node = entry.getKey();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
184 ResolvedJavaType type = entry.getValue();
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
185
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
186 for (State other : withStates) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
187 ResolvedJavaType otherType = other.getNodeType(node);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
188 type = widen(type, otherType);
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
189 if (type == null) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
190 break;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
191 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
192 }
18583
12bd2b344b08 replace usages of == with .equals()
Doug Simon <doug.simon@oracle.com>
parents: 18490
diff changeset
193 if (type != null && !type.equals(StampTool.typeOrNull(node))) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
194 newKnownTypes.put(node, type);
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
195 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
196 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
197
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
198 for (Map.Entry<LogicNode, GuardingNode> entry : trueConditions.entrySet()) {
7767
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
199 LogicNode check = entry.getKey();
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
200 GuardingNode guard = entry.getValue();
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
201
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
202 for (State other : withStates) {
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
203 GuardingNode otherGuard = other.trueConditions.get(check);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
204 if (otherGuard == null) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
205 guard = null;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
206 break;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
207 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
208 if (otherGuard != guard) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
209 guard = merge;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
210 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
211 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
212 if (guard != null) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
213 newTrueConditions.put(check, guard);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
214 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
215 }
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
216 for (Map.Entry<LogicNode, GuardingNode> entry : falseConditions.entrySet()) {
7767
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
217 LogicNode check = entry.getKey();
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
218 GuardingNode guard = entry.getValue();
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
219
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
220 for (State other : withStates) {
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
221 GuardingNode otherGuard = other.falseConditions.get(check);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
222 if (otherGuard == null) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
223 guard = null;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
224 break;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
225 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
226 if (otherGuard != guard) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
227 guard = merge;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
228 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
229 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
230 if (guard != null) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
231 newFalseConditions.put(check, guard);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
232 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
233 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
234
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
235 // this piece of code handles phis
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
236 if (!(merge instanceof LoopBeginNode)) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
237 for (PhiNode phi : merge.phis()) {
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22573
diff changeset
238 if (phi instanceof ValuePhiNode && phi.getStackKind() == JavaKind.Object) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
239 ValueNode firstValue = phi.valueAt(0);
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5774
diff changeset
240 ResolvedJavaType type = getNodeType(firstValue);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
241 boolean nonNull = knownNonNull.contains(firstValue);
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
242 boolean isNull = knownNull.contains(firstValue);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
243
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
244 for (int i = 0; i < withStates.size(); i++) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
245 State otherState = withStates.get(i);
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
246 ValueNode value = phi.valueAt(i + 1);
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5774
diff changeset
247 ResolvedJavaType otherType = otherState.getNodeType(value);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
248 type = widen(type, otherType);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
249 nonNull &= otherState.knownNonNull.contains(value);
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
250 isNull &= otherState.knownNull.contains(value);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
251 }
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
252 if (type != null) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
253 newKnownTypes.put(phi, type);
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
254 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
255 if (nonNull) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
256 newKnownNonNull.add(phi);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
257 }
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
258 if (isNull) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
259 newKnownNull.add(phi);
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
260 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
261 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
262 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
263 }
6587
795df1687282 renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6564
diff changeset
264
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
265 this.knownTypes = newKnownTypes;
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
266 this.knownNonNull = newKnownNonNull;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
267 this.knownNull = newKnownNull;
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
268 this.trueConditions = newTrueConditions;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
269 this.falseConditions = newFalseConditions;
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
270 this.valueConstraints = newValueConstraints;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
271 return true;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
272 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
273
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
274 public ResolvedJavaType getNodeType(ValueNode node) {
10767
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
275 ResolvedJavaType result = knownTypes.get(GraphUtil.unproxify(node));
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
276 return result == null ? StampTool.typeOrNull(node) : result;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
277 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
278
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
279 public boolean isNull(ValueNode value) {
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18487
diff changeset
280 return StampTool.isPointerAlwaysNull(value) || knownNull.contains(GraphUtil.unproxify(value));
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
281 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
282
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
283 public boolean isNonNull(ValueNode value) {
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18487
diff changeset
284 return StampTool.isPointerNonNull(value) || knownNonNull.contains(GraphUtil.unproxify(value));
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
285 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
286
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
287 @Override
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
288 public State clone() {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
289 return new State(this);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
290 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
291
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
292 /**
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
293 * Adds information about a condition. If isTrue is true then the condition is known to
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
294 * hold, otherwise the condition is known not to hold.
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
295 */
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
296 public void addCondition(boolean isTrue, LogicNode condition, GuardingNode anchor) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
297 if (isTrue) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
298 if (!trueConditions.containsKey(condition)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
299 trueConditions.put(condition, anchor);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
300 metricConditionRegistered.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
301 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
302 } else {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
303 if (!falseConditions.containsKey(condition)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
304 falseConditions.put(condition, anchor);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
305 metricConditionRegistered.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
306 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
307 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
308 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
309
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
310 /**
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
311 * Adds information about the nullness of a value. If isNull is true then the value is known
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
312 * to be null, otherwise the value is known to be non-null.
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
313 */
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
314 public void addNullness(boolean isNull, ValueNode value) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
315 if (isNull) {
10802
e6bb7edcc66c fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents: 10790
diff changeset
316 if (!isNull(value)) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
317 metricNullnessRegistered.increment();
10802
e6bb7edcc66c fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents: 10790
diff changeset
318 knownNull.add(GraphUtil.unproxify(value));
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
319 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
320 } else {
10802
e6bb7edcc66c fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents: 10790
diff changeset
321 if (!isNonNull(value)) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
322 metricNullnessRegistered.increment();
10802
e6bb7edcc66c fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents: 10790
diff changeset
323 knownNonNull.add(GraphUtil.unproxify(value));
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
324 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
325 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
326 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
327
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
328 public void addType(ResolvedJavaType type, ValueNode value) {
10767
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
329 ValueNode original = GraphUtil.unproxify(value);
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
330 ResolvedJavaType knownType = getNodeType(original);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
331 ResolvedJavaType newType = tighten(type, knownType);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
332
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
333 if (!newType.equals(knownType)) {
10767
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
334 knownTypes.put(original, newType);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
335 metricTypeRegistered.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
336 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
337 }
11706
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
338
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
339 public void clear() {
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
340 knownTypes.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
341 knownNonNull.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
342 knownNull.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
343 trueConditions.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
344 falseConditions.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
345 }
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
346 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
347
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
348 public static ResolvedJavaType widen(ResolvedJavaType a, ResolvedJavaType b) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
349 if (a == null || b == null) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
350 return null;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
351 } else if (a.equals(b)) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
352 return a;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
353 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
354 return a.findLeastCommonAncestor(b);
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
355 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
356 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
357
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
358 public static ResolvedJavaType tighten(ResolvedJavaType a, ResolvedJavaType b) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
359 if (a == null) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
360 return b;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
361 } else if (b == null) {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
362 return a;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
363 } else if (a.equals(b)) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
364 return a;
7097
6644cecbd3a7 Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7037
diff changeset
365 } else if (a.isAssignableFrom(b)) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
366 return b;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
367 } else {
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
368 return a;
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
369 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
370 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
371
16825
24892f7da98a fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents: 16811
diff changeset
372 public class ConditionalElimination extends SinglePassNodeIterator<State> {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7257
diff changeset
373
7767
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
374 private final LogicNode trueConstant;
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
375 private final LogicNode falseConstant;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
376
15585
4d5b1e7a4d93 [single-pass-iter] early pruning of state map, visit a whole method
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15583
diff changeset
377 public ConditionalElimination(StartNode start, State initialState) {
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
378 super(start, initialState);
8389
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
379 trueConstant = LogicConstantNode.tautology(graph);
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
380 falseConstant = LogicConstantNode.contradiction(graph);
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
381 }
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
382
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
383 @Override
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
384 public void finished() {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
385 if (trueConstant.hasNoUsages()) {
8389
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
386 graph.removeFloating(trueConstant);
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
387 }
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
388 if (falseConstant.hasNoUsages()) {
8389
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
389 graph.removeFloating(falseConstant);
e53b31b29aa4 clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7767
diff changeset
390 }
15588
9a63ccd66007 [single-pass-iter] additional documentation and assertions
Miguel Garcia <miguel.m.garcia@oracle.com>
parents: 15585
diff changeset
391 super.finished();
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
392 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
393
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
394 private void registerCondition(boolean isTrue, LogicNode condition, GuardingNode anchor) {
10789
ec4c7c33e8e5 rename: LogicBinaryNode -> ShortCircuitBooleanNode, Logic[Conjunction|Disjunction]Node -> ShortCircuit[And|Or]Node
Doug Simon <doug.simon@oracle.com>
parents: 10767
diff changeset
395 if (!isTrue && condition instanceof ShortCircuitOrNode) {
13750
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
396 /*
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
397 * We can only do this for fixed nodes, because floating guards will be registered
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
398 * at a BeginNode but might be "valid" only later due to data flow dependencies.
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
399 * Therefore, registering both conditions of a ShortCircuitOrNode for a floating
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
400 * guard could lead to cycles in data flow, because the guard will be used as anchor
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
401 * for both conditions, and one condition could be depending on the other.
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
402 */
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
403 if (anchor instanceof FixedNode) {
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
404 ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition;
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
405 registerCondition(disjunction.isXNegated(), disjunction.getX(), anchor);
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
406 registerCondition(disjunction.isYNegated(), disjunction.getY(), anchor);
a03cb658e68e only register ShortCircuitOrNodes in ConditionalElimination for fixed anchors
Lukas Stadler <lukas.stadler@jku.at>
parents: 12655
diff changeset
407 }
12485
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
408 }
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
409 state.addCondition(isTrue, condition, anchor);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
410
12485
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
411 if (isTrue && condition instanceof InstanceOfNode) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
412 InstanceOfNode instanceOf = (InstanceOfNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
413 ValueNode object = instanceOf.getValue();
12485
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
414 state.addNullness(false, object);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
415 state.addType(instanceOf.type(), object);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
416 } else if (condition instanceof IsNullNode) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
417 IsNullNode nullCheck = (IsNullNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
418 state.addNullness(isTrue, nullCheck.getValue());
12485
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
419 } else if (condition instanceof ObjectEqualsNode) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
420 ObjectEqualsNode equals = (ObjectEqualsNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
421 ValueNode x = equals.getX();
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
422 ValueNode y = equals.getY();
12485
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
423 if (isTrue) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
424 if (state.isNull(x) && !state.isNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
425 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
426 state.addNullness(true, y);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
427 } else if (!state.isNull(x) && state.isNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
428 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
429 state.addNullness(true, x);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
430 }
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
431 if (state.isNonNull(x) && !state.isNonNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
432 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
433 state.addNullness(false, y);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
434 } else if (!state.isNonNull(x) && state.isNonNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
435 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
436 state.addNullness(false, x);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
437 }
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
438 } else {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
439 if (state.isNull(x) && !state.isNonNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
440 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
441 state.addNullness(false, y);
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
442 } else if (!state.isNonNull(x) && state.isNull(y)) {
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
443 metricObjectEqualsRegistered.increment();
b433297f21c4 Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12049
diff changeset
444 state.addNullness(false, x);
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
445 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
446 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
447 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
448 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
449
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18937
diff changeset
450 private void registerControlSplitInfo(Node pred, AbstractBeginNode begin) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
451 assert pred != null && begin != null;
18333
db6b7d3dfa1d ConditionalElimination: only clear the state on loop exits if the graph needs to remain in loop closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18191
diff changeset
452 /*
db6b7d3dfa1d ConditionalElimination: only clear the state on loop exits if the graph needs to remain in loop closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18191
diff changeset
453 * We does not create value proxies for values it may connect accross loop exit node so
db6b7d3dfa1d ConditionalElimination: only clear the state on loop exits if the graph needs to remain in loop closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18191
diff changeset
454 * we have to clear the state at loop exits if the graph needs value proxies
db6b7d3dfa1d ConditionalElimination: only clear the state on loop exits if the graph needs to remain in loop closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18191
diff changeset
455 */
db6b7d3dfa1d ConditionalElimination: only clear the state on loop exits if the graph needs to remain in loop closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18191
diff changeset
456 if (begin instanceof LoopExitNode && begin.graph().hasValueProxies()) {
11706
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
457 state.clear();
cfca65c7cf02 Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11393
diff changeset
458 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
459
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
460 if (pred instanceof IfNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
461 IfNode ifNode = (IfNode) pred;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
462
7767
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
463 if (!(ifNode.condition() instanceof LogicConstantNode)) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
464 registerCondition(begin == ifNode.trueSuccessor(), ifNode.condition(), begin);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
465 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
466 } else if (pred instanceof TypeSwitchNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
467 TypeSwitchNode typeSwitch = (TypeSwitchNode) pred;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
468
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
469 if (typeSwitch.value() instanceof LoadHubNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
470 LoadHubNode loadHub = (LoadHubNode) typeSwitch.value();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
471 ResolvedJavaType type = null;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
472 for (int i = 0; i < typeSwitch.keyCount(); i++) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
473 if (typeSwitch.keySuccessor(i) == begin) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
474 if (type == null) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
475 type = typeSwitch.typeAt(i);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
476 } else {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
477 type = widen(type, typeSwitch.typeAt(i));
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
478 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
479 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
480 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
481 if (type != null) {
16219
24c30ecf930f rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
482 state.addNullness(false, loadHub.getValue());
24c30ecf930f rename object() to getValue() in LoadHubNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16207
diff changeset
483 state.addType(type, loadHub.getValue());
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
484 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
485 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
486 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
487 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
488
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
489 private GuardedStamp computeGuardedStamp(GuardNode guard) {
16601
cd25e42d9b22 rename IntegerBelowThanNode to IntegerBelowNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16563
diff changeset
490 if (guard.condition() instanceof IntegerBelowNode) {
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
491 if (guard.isNegated()) {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
492 // Not sure how to reason about negated guards
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
493 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
494 }
16601
cd25e42d9b22 rename IntegerBelowThanNode to IntegerBelowNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16563
diff changeset
495 IntegerBelowNode below = (IntegerBelowNode) guard.condition();
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22573
diff changeset
496 if (below.getX().getStackKind() == JavaKind.Int && below.getX().isConstant() && !below.getY().isConstant()) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
497 Stamp stamp = StampTool.unsignedCompare(below.getX().stamp(), below.getY().stamp());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
498 if (stamp != null) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
499 return new GuardedStamp(below.getY(), stamp, guard);
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
500 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
501 }
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22573
diff changeset
502 if (below.getY().getStackKind() == JavaKind.Int && below.getY().isConstant() && !below.getX().isConstant()) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
503 Stamp stamp = StampTool.unsignedCompare(below.getX().stamp(), below.getY().stamp());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
504 if (stamp != null) {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
505 return new GuardedStamp(below.getX(), stamp, guard);
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
506 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
507 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
508 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
509 return null;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
510 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
511
18396
05fde207f06c ConditionalEliminaion: some refactorings and simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18395
diff changeset
512 private boolean eliminateTrivialGuardOrRegisterStamp(GuardNode guard) {
05fde207f06c ConditionalEliminaion: some refactorings and simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18395
diff changeset
513 if (tryReplaceWithExistingGuard(guard)) {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
514 return true;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
515 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
516 // Can't be eliminated so accumulate any type information from the guard
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
517 registerConditionalStamp(guard);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
518 return false;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
519 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
520
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
521 /**
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
522 * Replace {@code guard} with {@code anchor} .
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
523 *
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
524 * @param guard The guard to eliminate.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
525 * @param anchor Node to replace the guard.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
526 */
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
527 private void eliminateGuard(GuardNode guard, GuardingNode anchor) {
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
528 guard.replaceAtUsages(anchor.asNode());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
529 metricGuardsRemoved.increment();
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
530 GraphUtil.killWithUnusedFloatingInputs(guard);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
531 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
532
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
533 /**
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
534 * See if a conditional type constraint can prove this guard.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
535 *
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
536 * @param guard
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
537 * @return true if the guard was eliminated.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
538 */
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
539 private boolean testImpliedGuard(GuardNode guard) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
540 if (state.valueConstraints.size() == 0) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
541 // Nothing to do.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
542 return false;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
543 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
544
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
545 GuardNode existingGuard = null;
16601
cd25e42d9b22 rename IntegerBelowThanNode to IntegerBelowNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16563
diff changeset
546 if (guard.condition() instanceof IntegerBelowNode) {
cd25e42d9b22 rename IntegerBelowThanNode to IntegerBelowNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16563
diff changeset
547 IntegerBelowNode below = (IntegerBelowNode) guard.condition();
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
548 IntegerStamp xStamp = (IntegerStamp) below.getX().stamp();
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
549 IntegerStamp yStamp = (IntegerStamp) below.getY().stamp();
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
550 GuardedStamp cstamp = state.valueConstraints.get(below.getX());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
551 if (cstamp != null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
552 xStamp = (IntegerStamp) cstamp.getStamp();
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
553 } else {
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
554 cstamp = state.valueConstraints.get(below.getY());
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
555 if (cstamp != null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
556 yStamp = (IntegerStamp) cstamp.getStamp();
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
557 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
558 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
559 if (cstamp != null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
560 if (cstamp.getGuard() == guard) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
561 // found ourselves
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
562 return false;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
563 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
564 // See if we can use the other guard
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
565 if (!guard.isNegated() && !cstamp.getGuard().isNegated() && yStamp.isPositive()) {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
566 if (xStamp.isPositive() && xStamp.upperBound() < yStamp.lowerBound()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
567 // Proven true
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
568 existingGuard = cstamp.getGuard();
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
569 Debug.log("existing guard %s %1s proves %1s", existingGuard, existingGuard.condition(), guard.condition());
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
570 } else if (xStamp.isStrictlyNegative() || xStamp.lowerBound() >= yStamp.upperBound()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
571 // An earlier guard proves that this will always fail but it's probably
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
572 // not worth trying to use it.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
573 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
574 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
575 }
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
576 } else if (guard.condition() instanceof IntegerEqualsNode && guard.isNegated()) {
14936
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
577 IntegerEqualsNode equals = (IntegerEqualsNode) guard.condition();
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
578 GuardedStamp cstamp = state.valueConstraints.get(equals.getY());
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
579 if (cstamp != null && equals.getX().isConstant()) {
14936
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
580 IntegerStamp stamp = (IntegerStamp) cstamp.getStamp();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 17154
diff changeset
581 if (!stamp.contains(equals.getX().asJavaConstant().asLong())) {
14936
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
582 // x != n is true if n is outside the range of the stamp
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
583 existingGuard = cstamp.getGuard();
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
584 Debug.log("existing guard %s %1s proves !%1s", existingGuard, existingGuard.condition(), guard.condition());
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
585 }
159b21f41915 add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14934
diff changeset
586 }
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
587 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
588
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
589 if (existingGuard != null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
590 // Found a guard which proves this guard to be true, so replace it.
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
591 eliminateGuard(guard, existingGuard);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
592 return true;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
593 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
594 return false;
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
595 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
596
18396
05fde207f06c ConditionalEliminaion: some refactorings and simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18395
diff changeset
597 private boolean tryReplaceWithExistingGuard(GuardNode guard) {
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
598 GuardingNode existingGuard = guard.isNegated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition());
14933
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
599 if (existingGuard != null && existingGuard != guard) {
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
600 eliminateGuard(guard, existingGuard);
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
601 return true;
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
602 }
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
603 return false;
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
604 }
0a7fce0ac01b eliminate duplicate guards with the same anchor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14863
diff changeset
605
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
606 private void registerConditionalStamp(GuardNode guard) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
607 GuardedStamp conditional = computeGuardedStamp(guard);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
608 if (conditional != null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
609 GuardedStamp other = state.valueConstraints.get(conditional.getValue());
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
610 if (other == null) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
611 state.valueConstraints.put(conditional.getValue(), conditional);
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
612 } else if (guard.isNegated() != other.getGuard().isNegated()) {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
613 // This seems impossible
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
614 // Debug.log("negated and !negated guards %1s %1s", guard, other.getGuard());
18398
728637aa02e6 Rename GuardNode.negated to GuardNode.isNegated
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18396
diff changeset
615 } else if (!guard.isNegated()) {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
616 // two different constraints, pick the one with the tightest type
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
617 // information
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
618 Stamp result = conditional.getStamp().join(other.getStamp());
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
619 if (result == conditional.getStamp()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
620 Debug.log("%1s overrides existing value %1s", guard.condition(), other.getGuard().condition());
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
621 state.valueConstraints.put(conditional.getValue(), conditional);
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
622 } else if (result == other.getStamp()) {
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
623 // existing type constraint is best
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
624 Debug.log("existing value is best %s", other.getGuard());
10720
7cc08d83111d correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 10532
diff changeset
625 } else {
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
626 // The merger produced some combination of values
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
627 Debug.log("type merge produced new type %s", result);
10720
7cc08d83111d correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 10532
diff changeset
628 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
629 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
630 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
631 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
632
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
633 /**
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
634 * Determines if, at the current point in the control flow, the condition is known to be
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
635 * true, false or unknown. In case of true or false the corresponding value is returned,
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
636 * otherwise null.
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
637 */
7767
4a6646d8eb87 separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7724
diff changeset
638 private <T extends ValueNode> T evaluateCondition(LogicNode condition, T trueValue, T falseValue) {
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
639 if (state.trueConditions.containsKey(condition)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
640 return trueValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
641 } else if (state.falseConditions.containsKey(condition)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
642 return falseValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
643 } else {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
644 if (condition instanceof InstanceOfNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
645 InstanceOfNode instanceOf = (InstanceOfNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
646 ValueNode object = instanceOf.getValue();
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
647 if (state.isNull(object)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
648 metricInstanceOfRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
649 return falseValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
650 } else if (state.isNonNull(object)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
651 ResolvedJavaType type = state.getNodeType(object);
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
652 if (type != null && instanceOf.type().isAssignableFrom(type)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
653 metricInstanceOfRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
654 return trueValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
655 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
656 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
657 } else if (condition instanceof IsNullNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
658 IsNullNode isNull = (IsNullNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
659 ValueNode object = isNull.getValue();
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
660 if (state.isNull(object)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
661 metricNullCheckRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
662 return trueValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
663 } else if (state.isNonNull(object)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
664 metricNullCheckRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
665 return falseValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
666 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
667 } else if (condition instanceof ObjectEqualsNode) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
668 ObjectEqualsNode equals = (ObjectEqualsNode) condition;
16207
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
669 ValueNode x = equals.getX();
df6f2365b153 rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15848
diff changeset
670 ValueNode y = equals.getY();
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
671 if (state.isNull(x) && state.isNonNull(y) || state.isNonNull(x) && state.isNull(y)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
672 metricObjectEqualsRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
673 return falseValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
674 } else if (state.isNull(x) && state.isNull(y)) {
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
675 metricObjectEqualsRemoved.increment();
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
676 return trueValue;
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
677 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
678 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
679 }
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
680 return null;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
681 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
682
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
683 @Override
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
684 protected void node(FixedNode node) {
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18937
diff changeset
685 if (node instanceof AbstractBeginNode) {
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
686 processAbstractBegin((AbstractBeginNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
687 } else if (node instanceof FixedGuardNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
688 processFixedGuard((FixedGuardNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
689 } else if (node instanceof CheckCastNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
690 processCheckCast((CheckCastNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
691 } else if (node instanceof ConditionAnchorNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
692 processConditionAnchor((ConditionAnchorNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
693 } else if (node instanceof IfNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
694 processIf((IfNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
695 } else if (node instanceof AbstractEndNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
696 processAbstractEnd((AbstractEndNode) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
697 } else if (node instanceof Invoke) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
698 processInvoke((Invoke) node);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
699 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
700 }
7706
9ea26951d826 fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
701
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
702 private void processIf(IfNode ifNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
703 LogicNode compare = ifNode.condition();
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
704
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
705 LogicNode replacement = null;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
706 GuardingNode replacementAnchor = null;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
707 AbstractBeginNode survivingSuccessor = null;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
708 if (state.trueConditions.containsKey(compare)) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
709 replacement = trueConstant;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
710 replacementAnchor = state.trueConditions.get(compare);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
711 survivingSuccessor = ifNode.trueSuccessor();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
712 } else if (state.falseConditions.containsKey(compare)) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
713 replacement = falseConstant;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
714 replacementAnchor = state.falseConditions.get(compare);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
715 survivingSuccessor = ifNode.falseSuccessor();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
716 } else {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
717 replacement = evaluateCondition(compare, trueConstant, falseConstant);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
718 if (replacement != null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
719 if (replacement == trueConstant) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
720 survivingSuccessor = ifNode.trueSuccessor();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
721 } else {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
722 assert replacement == falseConstant;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
723 survivingSuccessor = ifNode.falseSuccessor();
14863
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
724 }
ea712c41c5a2 merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
725 }
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
726 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
727
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
728 if (replacement != null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
729 trySimplify(ifNode, compare, replacement, replacementAnchor, survivingSuccessor);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
730 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
731 }
10532
1194e94f9c16 fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents: 9436
diff changeset
732
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
733 private void trySimplify(IfNode ifNode, LogicNode compare, LogicNode replacement, GuardingNode replacementAnchor, AbstractBeginNode survivingSuccessor) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
734 if (replacementAnchor != null && !(replacementAnchor instanceof AbstractBeginNode)) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
735 ValueAnchorNode anchor = graph.add(new ValueAnchorNode(replacementAnchor.asNode()));
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
736 graph.addBeforeFixed(ifNode, anchor);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
737 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
738 boolean canSimplify = true;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
739 for (Node n : survivingSuccessor.usages().snapshot()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
740 if (n instanceof GuardNode || n instanceof ProxyNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
741 // Keep wired to the begin node.
10532
1194e94f9c16 fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents: 9436
diff changeset
742 } else {
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
743 if (replacementAnchor == null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
744 // Cannot simplify this IfNode as there is no anchor.
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
745 canSimplify = false;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
746 break;
11317
12fe444e68d2 Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11310
diff changeset
747 }
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
748 // Rewire to the replacement anchor.
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
749 n.replaceFirstInput(survivingSuccessor, replacementAnchor.asNode());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
750 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
751 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
752
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
753 if (canSimplify) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
754 ifNode.setCondition(replacement);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
755 if (compare.hasNoUsages()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
756 GraphUtil.killWithUnusedFloatingInputs(compare);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
757 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
758 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
759 }
11309
2f216d44bce4 Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11305
diff changeset
760
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
761 private void processInvoke(Invoke invoke) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
762 if (invoke.callTarget() instanceof MethodCallTargetNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
763 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
764 ValueNode receiver = callTarget.receiver();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
765 if (receiver != null && callTarget.invokeKind().isIndirect()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
766 ResolvedJavaType type = state.getNodeType(receiver);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
767 if (!Objects.equals(type, StampTool.typeOrNull(receiver))) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
768 ResolvedJavaMethod method = type.resolveConcreteMethod(callTarget.targetMethod(), invoke.getContextType());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
769 if (method != null) {
22032
d1a41fbfcfd2 Replace ResolvedJavaType.isFinal with more meaningful and correct isLeaf
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21556
diff changeset
770 if (method.canBeStaticallyBound() || type.isLeaf() || type.isArray()) {
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
771 callTarget.setInvokeKind(InvokeKind.Special);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
772 callTarget.setTargetMethod(method);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5393
diff changeset
773 }
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
774 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
775 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
776 }
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
777 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
778 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
779
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
780 private void processAbstractEnd(AbstractEndNode endNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
781 for (PhiNode phi : endNode.merge().phis()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
782 int index = endNode.merge().phiPredecessorIndex(endNode);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
783 ValueNode value = phi.valueAt(index);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
784 if (value instanceof ConditionalNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
785 ConditionalNode materialize = (ConditionalNode) value;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
786 LogicNode compare = materialize.condition();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
787 ValueNode replacement = evaluateCondition(compare, materialize.trueValue(), materialize.falseValue());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
788
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
789 if (replacement != null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
790 phi.setValueAt(index, replacement);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
791 if (materialize.hasNoUsages()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
792 GraphUtil.killWithUnusedFloatingInputs(materialize);
10767
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
793 }
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
794 }
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
795 }
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
796 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
797 }
10767
88d0dc388450 let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents: 10749
diff changeset
798
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
799 private void processConditionAnchor(ConditionAnchorNode conditionAnchorNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
800 LogicNode condition = conditionAnchorNode.condition();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
801 GuardingNode replacementAnchor = null;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
802 if (conditionAnchorNode.isNegated()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
803 if (state.falseConditions.containsKey(condition)) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
804 replacementAnchor = state.falseConditions.get(condition);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
805 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
806 } else {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
807 if (state.trueConditions.containsKey(condition)) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
808 replacementAnchor = state.trueConditions.get(condition);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
809 }
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
810 }
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
811 if (replacementAnchor != null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
812 conditionAnchorNode.replaceAtUsages(replacementAnchor.asNode());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
813 conditionAnchorNode.graph().removeFixed(conditionAnchorNode);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
814 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
815 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
816
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
817 private void processCheckCast(CheckCastNode checkCast) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
818 ValueNode object = checkCast.object();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
819 boolean isNull = state.isNull(object);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
820 ResolvedJavaType type = state.getNodeType(object);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
821 if (isNull || (type != null && checkCast.type().isAssignableFrom(type))) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
822 boolean nonNull = state.isNonNull(object);
19716
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19053
diff changeset
823 // if (true)
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19053
diff changeset
824 // throw new RuntimeException(checkCast.toString());
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
825 GuardingNode replacementAnchor = null;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
826 if (nonNull) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
827 replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
828 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
829 if (replacementAnchor == null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
830 replacementAnchor = AbstractBeginNode.prevBegin(checkCast);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
831 }
19707
d57ca11a6883 Use FixedGuard in tryCheckcastSingleImplementor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19053
diff changeset
832 assert !(replacementAnchor instanceof FloatingNode) : "unsafe to mix unlowered Checkcast with floating guards";
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
833 PiNode piNode;
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
834 if (isNull) {
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22573
diff changeset
835 ConstantNode nullObject = ConstantNode.defaultForKind(JavaKind.Object, graph);
19053
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
836 piNode = graph.unique(new PiNode(nullObject, nullObject.stamp(), replacementAnchor.asNode()));
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
837 } else {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
838 piNode = graph.unique(new PiNode(object, StampFactory.declaredTrusted(type, nonNull), replacementAnchor.asNode()));
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
839 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
840 checkCast.replaceAtUsages(piNode);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
841 graph.removeFixed(checkCast);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
842 metricCheckCastRemoved.increment();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
843 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
844 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
845
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
846 private void processFixedGuard(FixedGuardNode guard) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
847 GuardingNode existingGuard = guard.isNegated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
848 if (existingGuard != null && existingGuard instanceof FixedGuardNode) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
849 guard.replaceAtUsages(existingGuard.asNode());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
850 guard.graph().removeFixed(guard);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
851 } else {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
852 registerCondition(!guard.isNegated(), guard.condition(), guard);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
853 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
854 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
855
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
856 private void processAbstractBegin(AbstractBeginNode begin) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
857 Node pred = begin.predecessor();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
858
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
859 if (pred != null) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
860 registerControlSplitInfo(pred, begin);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
861 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
862
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
863 // First eliminate any guards which can be trivially removed and register any
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
864 // type constraints the guards produce.
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
865 for (GuardNode guard : begin.guards().snapshot()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
866 eliminateTrivialGuardOrRegisterStamp(guard);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
867 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
868
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
869 // Collect the guards which have produced conditional stamps.
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
870 // XXX (gd) IdentityHashMap.values().contains performs a linear search
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
871 // so we prefer to build a set
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
872 Set<GuardNode> provers = Node.newSet();
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
873 for (GuardedStamp e : state.valueConstraints.values()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
874 provers.add(e.getGuard());
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
875 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
876
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
877 // Process the remaining guards. Guards which produced some type constraint should
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
878 // just be registered since they aren't trivially deleteable. Test the other guards
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
879 // to see if they can be deleted using type constraints.
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
880 for (GuardNode guard : begin.guards().snapshot()) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
881 if (provers.contains(guard) || !(tryReplaceWithExistingGuard(guard) || testImpliedGuard(guard))) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
882 registerCondition(!guard.isNegated(), guard.condition(), guard);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
883 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
884 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
885 assert assertImpliedGuard(provers);
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
886 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
887
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
888 private boolean assertImpliedGuard(Set<GuardNode> provers) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
889 for (GuardNode guard : provers) {
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
890 assert !testImpliedGuard(guard) : "provers shouldn't be trivially eliminatable";
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
891 }
fa4e9a76a5ed Split methods in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
892 return true;
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
893 }
11332
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
894
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
895 private GuardingNode searchAnchor(ValueNode value, ResolvedJavaType type) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
896 for (Node n : value.usages()) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
897 if (n instanceof InstanceOfNode) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
898 InstanceOfNode instanceOfNode = (InstanceOfNode) n;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
899 if (instanceOfNode.type().equals(type) && state.trueConditions.containsKey(instanceOfNode)) {
18395
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
900 GuardingNode v = state.trueConditions.get(instanceOfNode);
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
901 if (v != null) {
1cd104505b61 ConditionalElimination: use GuardingNode interface where possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18383
diff changeset
902 return v;
11332
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
903 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
904 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
905 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
906 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
907
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
908 for (Node n : value.usages()) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
909 if (n instanceof ValueProxy) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
910 ValueProxy proxyNode = (ValueProxy) n;
15009
e49f62425090 introduce non-ValueNode Proxy interface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
911 if (proxyNode.getOriginalNode() == value) {
11332
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
912 GuardingNode result = searchAnchor((ValueNode) n, type);
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
913 if (result != null) {
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
914 return result;
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
915 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
916 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
917
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
918 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
919 }
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
920
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
921 return null;
e4a1593cc6e4 Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11317
diff changeset
922 }
5391
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
923 }
5097f21f6c2b add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
924 }