Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java @ 10720:7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 12 Jul 2013 15:29:47 +0200 |
parents | 1194e94f9c16 |
children | a5c9bc1f28fb |
rev | line source |
---|---|
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
26 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5443
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import com.oracle.graal.debug.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.graph.*; |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
30 import com.oracle.graal.graph.iterators.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
32 import com.oracle.graal.nodes.PhiNode.PhiType; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.calc.*; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
34 import com.oracle.graal.nodes.extended.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.java.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.type.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.util.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
38 import com.oracle.graal.phases.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
39 import com.oracle.graal.phases.graph.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
41 public class ConditionalEliminationPhase extends Phase { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
53 private final MetaAccessProvider metaAccessProvider; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 private StructuredGraph graph; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
57 public ConditionalEliminationPhase(MetaAccessProvider metaAccessProvider) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
58 this.metaAccessProvider = metaAccessProvider; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
59 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
60 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
61 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 protected void run(StructuredGraph inputGraph) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
63 graph = inputGraph; |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
64 new ConditionalElimination(graph.start(), new State()).apply(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 public static class State implements MergeableState<State> { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 |
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
|
69 private IdentityHashMap<ValueNode, ResolvedJavaType> knownTypes; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
70 private HashSet<ValueNode> knownNonNull; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 private HashSet<ValueNode> knownNull; |
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
|
72 private IdentityHashMap<LogicNode, ValueNode> trueConditions; |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
73 private IdentityHashMap<LogicNode, ValueNode> falseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 public State() { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
76 this.knownTypes = new IdentityHashMap<>(); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
77 this.knownNonNull = new HashSet<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
78 this.knownNull = new HashSet<>(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
79 this.trueConditions = new IdentityHashMap<>(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
80 this.falseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
81 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
83 public State(State other) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
84 this.knownTypes = new IdentityHashMap<>(other.knownTypes); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
85 this.knownNonNull = new HashSet<>(other.knownNonNull); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
86 this.knownNull = new HashSet<>(other.knownNull); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
87 this.trueConditions = new IdentityHashMap<>(other.trueConditions); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
88 this.falseConditions = new IdentityHashMap<>(other.falseConditions); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 public boolean merge(MergeNode merge, List<State> 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
|
93 IdentityHashMap<ValueNode, ResolvedJavaType> newKnownTypes = new IdentityHashMap<>(); |
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
|
94 IdentityHashMap<LogicNode, ValueNode> newTrueConditions = new IdentityHashMap<>(); |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
95 IdentityHashMap<LogicNode, ValueNode> newFalseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
97 HashSet<ValueNode> newKnownNull = new HashSet<>(knownNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
98 HashSet<ValueNode> newKnownNonNull = new HashSet<>(knownNonNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
99 for (State state : withStates) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
100 newKnownNull.retainAll(state.knownNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
101 newKnownNonNull.retainAll(state.knownNonNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
102 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
103 |
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
|
104 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
|
105 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
|
106 ResolvedJavaType type = entry.getValue(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 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
|
109 ResolvedJavaType otherType = other.getNodeType(node); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 type = widen(type, otherType); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 if (type == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 break; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
115 if (type == null && type != node.objectStamp().type()) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 newKnownTypes.put(node, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
119 |
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
|
120 for (Map.Entry<LogicNode, ValueNode> entry : trueConditions.entrySet()) { |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
121 LogicNode check = entry.getKey(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
122 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
123 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
124 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
125 ValueNode otherGuard = other.trueConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
126 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
127 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
128 break; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
129 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
130 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
131 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
132 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
133 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
134 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
135 newTrueConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
136 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
137 } |
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
|
138 for (Map.Entry<LogicNode, ValueNode> entry : falseConditions.entrySet()) { |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
139 LogicNode check = entry.getKey(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
140 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
141 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
142 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
143 ValueNode otherGuard = other.falseConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
144 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
145 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
146 break; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
147 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
148 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
149 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
150 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
151 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
152 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
153 newFalseConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
154 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
155 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
156 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
157 // this piece of code handles phis |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 if (!(merge instanceof LoopBeginNode)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 for (PhiNode phi : merge.phis()) { |
5774
a1db0ea58b53
Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5541
diff
changeset
|
160 if (phi.type() == PhiType.Value && phi.kind() == Kind.Object) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 ValueNode firstValue = phi.valueAt(0); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
162 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
|
163 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
|
164 boolean isNull = knownNull.contains(firstValue); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 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
|
167 State otherState = withStates.get(i); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 ValueNode value = phi.valueAt(i + 1); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
169 ResolvedJavaType otherType = otherState.getNodeType(value); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 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
|
171 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
|
172 isNull &= otherState.knownNull.contains(value); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
174 if (type != null) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 newKnownTypes.put(phi, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
176 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
177 if (nonNull) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
178 newKnownNonNull.add(phi); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
180 if (isNull) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 newKnownNull.add(phi); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
182 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
183 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
184 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
185 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
186 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 this.knownTypes = newKnownTypes; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
188 this.knownNonNull = newKnownNonNull; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 this.knownNull = newKnownNull; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
190 this.trueConditions = newTrueConditions; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
191 this.falseConditions = newFalseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
192 return true; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
193 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 |
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
|
195 public ResolvedJavaType getNodeType(ValueNode node) { |
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
|
196 ResolvedJavaType result = knownTypes.get(node); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
197 return result == null ? node.objectStamp().type() : result; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
198 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
199 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
200 public boolean isNull(ValueNode value) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
201 return value.objectStamp().alwaysNull() || knownNull.contains(value); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
202 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
203 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
204 public boolean isNonNull(ValueNode value) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
205 return value.objectStamp().nonNull() || knownNonNull.contains(value); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
206 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
207 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
208 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 public void loopBegin(LoopBeginNode loopBegin) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
210 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
211 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 public void loopEnds(LoopBeginNode loopBegin, List<State> loopEndStates) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
215 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 @Override |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
217 public void afterSplit(AbstractBeginNode node) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
218 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
219 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
220 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
221 public State clone() { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
222 return new State(this); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
223 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
224 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
225 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
226 * 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
|
227 * 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
|
228 */ |
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
|
229 public void addCondition(boolean isTrue, LogicNode condition, ValueNode anchor) { |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
230 if (isTrue) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
231 if (!trueConditions.containsKey(condition)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
232 trueConditions.put(condition, anchor); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
233 metricConditionRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
234 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
235 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
236 if (!falseConditions.containsKey(condition)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
237 falseConditions.put(condition, anchor); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
238 metricConditionRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
239 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
240 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
241 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
242 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
243 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
244 * 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
|
245 * 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
|
246 */ |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
247 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
|
248 if (isNull) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
249 if (!isNull(value)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
250 metricNullnessRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
251 knownNull.add(value); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
252 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
253 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
254 if (!isNonNull(value)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
255 metricNullnessRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
256 knownNonNull.add(value); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
257 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
258 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
259 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
260 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
261 public void addType(ResolvedJavaType type, ValueNode value) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
262 ResolvedJavaType knownType = getNodeType(value); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
263 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
|
264 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
265 if (newType != knownType) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
266 knownTypes.put(value, newType); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
267 metricTypeRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
268 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
269 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
271 |
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
|
272 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
|
273 if (a == null || b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 return null; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
277 } 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
|
278 return a.findLeastCommonAncestor(b); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
279 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
280 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
281 |
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
|
282 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
|
283 if (a == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
284 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
285 } else if (b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
286 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
287 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
288 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
|
289 } else if (a.isAssignableFrom(b)) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
290 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 } else { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
293 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
294 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
295 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
296 public class ConditionalElimination extends PostOrderNodeIterator<State> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7257
diff
changeset
|
297 |
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
|
298 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
|
299 private final LogicNode falseConstant; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
300 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
301 public ConditionalElimination(FixedNode start, State initialState) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
302 super(start, initialState); |
8389
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
303 trueConstant = LogicConstantNode.tautology(graph); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
304 falseConstant = LogicConstantNode.contradiction(graph); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
305 } |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
306 |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
307 @Override |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
308 public void finished() { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
309 if (trueConstant.usages().isEmpty()) { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
310 graph.removeFloating(trueConstant); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
311 } |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
312 if (falseConstant.usages().isEmpty()) { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
313 graph.removeFloating(falseConstant); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
314 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
315 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
316 |
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
|
317 private void registerCondition(boolean isTrue, LogicNode condition, ValueNode anchor) { |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
318 state.addCondition(isTrue, condition, anchor); |
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 if (isTrue && condition instanceof InstanceOfNode) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
321 InstanceOfNode instanceOf = (InstanceOfNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
322 ValueNode object = instanceOf.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
323 state.addNullness(false, object); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
324 state.addType(instanceOf.type(), object); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
325 } 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
|
326 IsNullNode nullCheck = (IsNullNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
327 state.addNullness(isTrue, nullCheck.object()); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
328 } 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
|
329 ObjectEqualsNode equals = (ObjectEqualsNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
330 ValueNode x = equals.x(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
331 ValueNode y = equals.y(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
332 if (isTrue) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
333 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
|
334 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
335 state.addNullness(true, y); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
336 } 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
|
337 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
338 state.addNullness(true, x); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
339 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
340 if (state.isNonNull(x) && !state.isNonNull(y)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
341 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
342 state.addNullness(false, y); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
343 } else if (!state.isNonNull(x) && state.isNonNull(y)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
344 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
345 state.addNullness(false, x); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
346 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
347 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
348 if (state.isNull(x) && !state.isNonNull(y)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
349 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
350 state.addNullness(true, y); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
351 } else if (!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
|
352 metricObjectEqualsRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
353 state.addNullness(true, x); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
354 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
355 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
356 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
357 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
358 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
359 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
|
360 assert pred != null && begin != null; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
361 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
362 if (pred instanceof IfNode) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
363 IfNode ifNode = (IfNode) pred; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
364 |
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
|
365 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
|
366 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
|
367 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
368 } 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
|
369 TypeSwitchNode typeSwitch = (TypeSwitchNode) pred; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
370 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
371 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
|
372 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
|
373 ResolvedJavaType type = null; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
374 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
|
375 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
|
376 if (type == null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
377 type = typeSwitch.typeAt(i); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
378 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
379 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
|
380 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
381 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
382 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
383 if (type != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
384 state.addNullness(false, loadHub.object()); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
385 state.addType(type, loadHub.object()); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
386 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
387 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
388 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
389 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
390 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
391 private void registerGuard(GuardNode guard) { |
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
|
392 LogicNode condition = guard.condition(); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
393 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
394 ValueNode existingGuards = guard.negated() ? state.falseConditions.get(condition) : state.trueConditions.get(condition); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
395 if (existingGuards != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
396 guard.replaceAtUsages(existingGuards); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
397 GraphUtil.killWithUnusedFloatingInputs(guard); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
398 metricGuardsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
399 } else { |
10720
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
400 ValueNode anchor = state.trueConditions.get(condition); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
401 if (anchor != null) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
402 if (!guard.negated()) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
403 guard.replaceAtUsages(anchor); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
404 metricGuardsRemoved.increment(); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
405 GraphUtil.killWithUnusedFloatingInputs(guard); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
406 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
407 } else { |
10720
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
408 anchor = state.falseConditions.get(condition); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
409 if (anchor != null) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
410 if (guard.negated()) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
411 guard.replaceAtUsages(anchor); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
412 metricGuardsRemoved.increment(); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
413 GraphUtil.killWithUnusedFloatingInputs(guard); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
414 } |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
415 } else { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
416 registerCondition(!guard.negated(), condition, guard); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
417 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
418 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
419 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
420 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
421 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
422 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
423 * 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
|
424 * 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
|
425 * otherwise null. |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
426 */ |
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
|
427 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
|
428 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
|
429 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
430 } 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
|
431 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
432 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
433 if (condition instanceof InstanceOfNode) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
434 InstanceOfNode instanceOf = (InstanceOfNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
435 ValueNode object = instanceOf.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
436 if (state.isNull(object)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
437 metricInstanceOfRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
438 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
439 } 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
|
440 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
|
441 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
|
442 metricInstanceOfRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
443 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
444 } |
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 } 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
|
447 IsNullNode isNull = (IsNullNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
448 ValueNode object = isNull.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
449 if (state.isNull(object)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
450 metricNullCheckRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
451 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
452 } 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
|
453 metricNullCheckRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
454 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
455 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
456 } 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
|
457 ObjectEqualsNode equals = (ObjectEqualsNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
458 ValueNode x = equals.x(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
459 ValueNode y = equals.y(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
460 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
|
461 metricObjectEqualsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
462 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
463 } 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
|
464 metricObjectEqualsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
465 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
466 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
467 } |
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 return null; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
470 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
471 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
472 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
473 protected void node(FixedNode node) { |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
474 if (node instanceof AbstractBeginNode) { |
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
475 AbstractBeginNode begin = (AbstractBeginNode) node; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
476 Node pred = node.predecessor(); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
477 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
478 if (pred != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
479 registerControlSplitInfo(pred, begin); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
480 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
481 for (GuardNode guard : begin.guards().snapshot()) { |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
482 registerGuard(guard); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
483 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
484 } else if (node instanceof CheckCastNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
485 CheckCastNode checkCast = (CheckCastNode) node; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
486 ValueNode object = checkCast.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
487 boolean isNull = state.isNull(object); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
488 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
|
489 if (isNull || (type != null && checkCast.type().isAssignableFrom(type))) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
490 boolean nonNull = state.isNonNull(object); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
491 ValueAnchorNode anchor = graph.add(new ValueAnchorNode()); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
492 PiNode piNode; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
493 if (isNull) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
494 ConstantNode nullObject = ConstantNode.forObject(null, metaAccessProvider, graph); |
8649
39fc99302250
PiNode: use existing dependencies array for anchor
Bernhard Urban <bernhard.urban@jku.at>
parents:
8389
diff
changeset
|
495 piNode = graph.unique(new PiNode(nullObject, StampFactory.forConstant(nullObject.value, metaAccessProvider), anchor)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
496 } else { |
8649
39fc99302250
PiNode: use existing dependencies array for anchor
Bernhard Urban <bernhard.urban@jku.at>
parents:
8389
diff
changeset
|
497 piNode = graph.unique(new PiNode(object, StampFactory.declared(type, nonNull), anchor)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
498 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
499 checkCast.replaceAtUsages(piNode); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
500 graph.replaceFixedWithFixed(checkCast, anchor); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
501 metricCheckCastRemoved.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
502 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
503 } else if (node instanceof IfNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
504 IfNode ifNode = (IfNode) node; |
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
|
505 LogicNode compare = ifNode.condition(); |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
506 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
507 LogicNode replacement = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
508 ValueNode replacementAnchor = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
509 AbstractBeginNode survivingSuccessor = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
510 if (state.trueConditions.containsKey(compare)) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
511 replacement = trueConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
512 replacementAnchor = state.trueConditions.get(compare); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
513 survivingSuccessor = ifNode.trueSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
514 } else if (state.falseConditions.containsKey(compare)) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
515 replacement = falseConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
516 replacementAnchor = state.falseConditions.get(compare); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
517 survivingSuccessor = ifNode.falseSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
518 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
519 replacement = evaluateCondition(compare, trueConstant, falseConstant); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
520 if (replacement != null) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
521 if (replacement == trueConstant) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
522 survivingSuccessor = ifNode.trueSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
523 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
524 assert replacement == falseConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
525 survivingSuccessor = ifNode.falseSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
526 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
527 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
528 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
529 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
530 if (replacement != null) { |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
531 NodeIterable<Node> anchored = survivingSuccessor.anchored(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
532 if (!anchored.isEmpty() && replacementAnchor == null) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
533 // Cannot simplify an IfNode unless we have a new anchor point |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
534 // for any nodes currently anchored to the surviving branch |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
535 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
536 if (!anchored.isEmpty()) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
537 // Ideally we'd simply want to re-anchor to replacementAnchor. However, |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
538 // this can cause guards currently anchored to the surviving branch |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
539 // to float too high in the graph. So, we insert a new anchor between |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
540 // the guards and replacementAnchor. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
541 ValueAnchorNode valueAnchor = graph.add(new ValueAnchorNode()); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
542 for (Node a : anchored.snapshot()) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
543 a.replaceFirstInput(survivingSuccessor, valueAnchor); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
544 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
545 valueAnchor.addAnchoredNode(replacementAnchor); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
546 graph.addBeforeFixed(ifNode, valueAnchor); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
547 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
548 ifNode.setCondition(replacement); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
549 if (compare.usages().isEmpty()) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
550 GraphUtil.killWithUnusedFloatingInputs(compare); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
551 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
552 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
553 } |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8649
diff
changeset
|
554 } else if (node instanceof AbstractEndNode) { |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8649
diff
changeset
|
555 AbstractEndNode endNode = (AbstractEndNode) node; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
556 for (PhiNode phi : endNode.merge().phis()) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
557 int index = endNode.merge().phiPredecessorIndex(endNode); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
558 ValueNode value = phi.valueAt(index); |
7724
ac3579b4adc9
remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7706
diff
changeset
|
559 if (value instanceof ConditionalNode) { |
ac3579b4adc9
remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7706
diff
changeset
|
560 ConditionalNode materialize = (ConditionalNode) value; |
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
|
561 LogicNode compare = materialize.condition(); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
562 ValueNode replacement = evaluateCondition(compare, materialize.trueValue(), materialize.falseValue()); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
563 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
564 if (replacement != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
565 phi.setValueAt(index, replacement); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
566 if (materialize.usages().isEmpty()) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
567 GraphUtil.killWithUnusedFloatingInputs(materialize); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
568 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
569 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
570 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
571 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
572 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
573 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
574 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
575 } |