Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java @ 5775:2c088af17e59
Removed left over Ri* prefixed identifiers
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 05 Jul 2012 21:47:16 +0200 |
parents | a1db0ea58b53 |
children | 16c3284c94cd |
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 */ |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.phases; |
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.compiler.graph.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.debug.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.graph.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.calc.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.extended.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.java.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.type.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.util.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 public class CheckCastEliminationPhase extends Phase { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 private static final DebugMetric metricInstanceOfRegistered = Debug.metric("InstanceOfRegistered"); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 private static final DebugMetric metricIsTypeRegistered = Debug.metric("IsTypeRegistered"); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 private static final DebugMetric metricNullCheckRegistered = Debug.metric("NullCheckRegistered"); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 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
|
44 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
|
45 private static final DebugMetric metricNullCheckRemoved = Debug.metric("NullCheckRemoved"); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 private static final DebugMetric metricNullCheckGuardRemoved = Debug.metric("NullCheckGuardRemoved"); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
47 private static final DebugMetric metricGuardsReplaced = Debug.metric("GuardsReplaced"); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 private StructuredGraph graph; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
51 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 protected void run(StructuredGraph inputGraph) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 graph = inputGraph; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 new EliminateCheckCasts(graph.start(), new State()).apply(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 public static class State implements MergeableState<State> { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
58 |
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
|
59 private IdentityHashMap<ValueNode, ResolvedJavaType> knownTypes; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 private HashSet<ValueNode> knownNotNull; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
61 private HashSet<ValueNode> knownNull; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
62 private IdentityHashMap<BooleanNode, ValueNode> trueConditions; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
63 private IdentityHashMap<BooleanNode, ValueNode> falseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 public State() { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 this.knownTypes = new IdentityHashMap<>(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 this.knownNotNull = new HashSet<>(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 this.knownNull = new HashSet<>(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
69 this.trueConditions = new IdentityHashMap<>(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
70 this.falseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
72 |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
73 public State(State other) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
74 this.knownTypes = new IdentityHashMap<>(other.knownTypes); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
75 this.knownNotNull = new HashSet<>(other.knownNotNull); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
76 this.knownNull = new HashSet<>(other.knownNull); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
77 this.trueConditions = new IdentityHashMap<>(other.trueConditions); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
78 this.falseConditions = new IdentityHashMap<>(other.falseConditions); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
79 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
80 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
81 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 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
|
83 IdentityHashMap<ValueNode, ResolvedJavaType> newKnownTypes = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 HashSet<ValueNode> newKnownNotNull = new HashSet<>(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 HashSet<ValueNode> newKnownNull = new HashSet<>(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
86 IdentityHashMap<BooleanNode, ValueNode> newTrueConditions = new IdentityHashMap<>(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
87 IdentityHashMap<BooleanNode, ValueNode> newFalseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 |
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
|
89 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
|
90 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
|
91 ResolvedJavaType type = entry.getValue(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
93 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
|
94 ResolvedJavaType otherType = other.getNodeType(node); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 type = widen(type, otherType); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 if (type == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 break; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
100 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
|
101 newKnownTypes.put(node, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 for (ValueNode node : knownNotNull) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 boolean notNull = true; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 for (State other : withStates) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 if (!other.knownNotNull.contains(node)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 notNull = false; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 break; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 if (notNull) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 newKnownNotNull.add(node); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 for (ValueNode node : knownNull) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 boolean nul = true; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 for (State other : withStates) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 if (!other.knownNull.contains(node)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 nul = false; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 break; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 if (nul) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 newKnownNull.add(node); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
127 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
128 for (Map.Entry<BooleanNode, ValueNode> entry : trueConditions.entrySet()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
129 BooleanNode check = entry.getKey(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
130 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
131 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
132 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
133 ValueNode otherGuard = other.trueConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
134 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
135 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
136 break; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
137 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
138 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
139 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
140 } |
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 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
143 newTrueConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
144 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
145 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
146 for (Map.Entry<BooleanNode, ValueNode> entry : falseConditions.entrySet()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
147 BooleanNode check = entry.getKey(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
148 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
149 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
150 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
151 ValueNode otherGuard = other.falseConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
152 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
153 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
154 break; |
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 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
157 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
158 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
159 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
160 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
161 newFalseConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
162 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
163 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
164 |
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 // this piece of code handles phis (merges the types and knownNull/knownNotNull of the values) |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 if (!(merge instanceof LoopBeginNode)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 for (PhiNode phi : merge.phis()) { |
5774
a1db0ea58b53
Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5541
diff
changeset
|
169 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
|
170 ValueNode firstValue = phi.valueAt(0); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
171 ResolvedJavaType type = getNodeType(firstValue); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 boolean notNull = knownNotNull.contains(firstValue); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 boolean nul = knownNull.contains(firstValue); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 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
|
176 State otherState = withStates.get(i); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 ValueNode value = phi.valueAt(i + 1); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
178 ResolvedJavaType otherType = otherState.getNodeType(value); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 type = widen(type, otherType); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
180 notNull &= otherState.knownNotNull.contains(value); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 nul &= otherState.knownNull.contains(value); |
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 if (type == null && type != phi.declaredType()) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
184 newKnownTypes.put(phi, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
185 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
186 if (notNull) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 newKnownNotNull.add(phi); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
188 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 if (nul) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
190 newKnownNull.add(phi); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
191 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
192 } |
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 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
195 */ |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
196 this.knownTypes = newKnownTypes; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
197 this.knownNotNull = newKnownNotNull; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
198 this.knownNull = newKnownNull; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
199 this.trueConditions = newTrueConditions; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
200 this.falseConditions = newFalseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
201 return true; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
202 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
203 |
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
|
204 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
|
205 ResolvedJavaType result = knownTypes.get(node); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
206 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
|
207 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
208 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
210 public void loopBegin(LoopBeginNode loopBegin) { |
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 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 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
|
215 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
217 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
218 public void afterSplit(FixedNode node) { |
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 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
221 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
222 public State clone() { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
223 return new State(this); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
224 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
225 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
226 |
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
|
227 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
|
228 if (a == null || b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
229 return null; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
230 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
231 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
232 } else { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
233 return a.leastCommonAncestor(b); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
234 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
235 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
236 |
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
|
237 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
|
238 if (a == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
239 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
240 } else if (b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
241 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
242 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
243 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
244 } else if (a.isSubtypeOf(b)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
245 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
246 } else if (b.isSubtypeOf(a)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
247 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
248 } else { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
249 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
250 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
251 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
252 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
253 public class EliminateCheckCasts extends PostOrderNodeIterator<State> { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
254 private BeginNode lastBegin = null; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
255 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
256 public EliminateCheckCasts(FixedNode start, State initialState) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
257 super(start, initialState); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
258 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
259 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
260 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
261 protected void node(FixedNode node) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
262 if (node instanceof BeginNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
263 BeginNode begin = (BeginNode) node; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
264 lastBegin = begin; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
265 Node pred = node.predecessor(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
266 if (pred != null && pred instanceof IfNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 IfNode ifNode = (IfNode) pred; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
268 if (!(ifNode.compare() instanceof ConstantNode)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
269 boolean isTrue = (node == ifNode.trueSuccessor()); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
270 if (isTrue) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
271 state.trueConditions.put(ifNode.compare(), begin); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
272 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
273 state.falseConditions.put(ifNode.compare(), begin); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
274 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
275 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 if (ifNode.compare() instanceof InstanceOfNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
277 InstanceOfNode instanceOf = (InstanceOfNode) ifNode.compare(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
278 if ((node == ifNode.trueSuccessor())) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
279 ValueNode object = instanceOf.object(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
280 state.knownNotNull.add(object); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
281 state.knownTypes.put(object, tighten(instanceOf.targetClass(), state.getNodeType(object))); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
282 metricInstanceOfRegistered.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
283 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
284 } else if (ifNode.compare() instanceof IsNullNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
285 IsNullNode nullCheck = (IsNullNode) ifNode.compare(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
286 boolean isNull = (node == ifNode.trueSuccessor()); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
287 if (isNull) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
288 state.knownNull.add(nullCheck.object()); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
289 } else { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
290 state.knownNotNull.add(nullCheck.object()); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 metricNullCheckRegistered.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
293 } else if (ifNode.compare() instanceof IsTypeNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
294 IsTypeNode isType = (IsTypeNode) ifNode.compare(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
295 if (isType.objectClass() instanceof ReadHubNode && (node == ifNode.trueSuccessor())) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
296 ReadHubNode readHub = (ReadHubNode) isType.objectClass(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
297 ValueNode object = readHub.object(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
298 state.knownNotNull.add(object); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
299 state.knownTypes.put(object, tighten(isType.type(), state.getNodeType(object))); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
300 metricIsTypeRegistered.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
301 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
302 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
303 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
304 for (GuardNode guard : begin.guards().snapshot()) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
305 BooleanNode condition = guard.condition(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
306 ValueNode existingGuards = guard.negated() ? state.falseConditions.get(condition) : state.trueConditions.get(condition); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
307 if (existingGuards != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
308 guard.replaceAtUsages(existingGuards); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
309 GraphUtil.killWithUnusedFloatingInputs(guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
310 metricGuardsReplaced.increment(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
311 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
312 boolean removeCheck = false; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
313 if (condition instanceof IsNullNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
314 IsNullNode isNull = (IsNullNode) condition; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
315 if (guard.negated() && state.knownNotNull.contains(isNull.object())) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
316 removeCheck = true; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
317 } else if (!guard.negated() && state.knownNull.contains(isNull.object())) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
318 removeCheck = true; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
319 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
320 if (removeCheck) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
321 metricNullCheckGuardRemoved.increment(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
322 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
323 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
324 if (removeCheck) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
325 guard.replaceAtUsages(begin); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
326 GraphUtil.killWithUnusedFloatingInputs(guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
327 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
328 if (guard.negated()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
329 state.falseConditions.put(condition, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
330 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
331 state.trueConditions.put(condition, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
332 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
333 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
334 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
335 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
336 } else if (node instanceof CheckCastNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
337 CheckCastNode checkCast = (CheckCastNode) node; |
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
|
338 ResolvedJavaType type = state.getNodeType(checkCast.object()); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
339 if (checkCast.targetClass() != null && type != null && type.isSubtypeOf(checkCast.targetClass())) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
340 PiNode piNode; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
341 boolean nonNull = state.knownNotNull.contains(checkCast.object()); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5425
diff
changeset
|
342 piNode = graph.unique(new PiNode(checkCast.object(), lastBegin, nonNull ? StampFactory.declaredNonNull(type) : StampFactory.declared(type))); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
343 checkCast.replaceAtUsages(piNode); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
344 graph.removeFixed(checkCast); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
345 metricCheckCastRemoved.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
346 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
347 } else if (node instanceof IfNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
348 IfNode ifNode = (IfNode) node; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
349 BooleanNode replaceWith = null; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
350 BooleanNode compare = ifNode.compare(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
351 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
352 if (state.trueConditions.containsKey(compare)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
353 replaceWith = ConstantNode.forBoolean(true, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
354 } else if (state.falseConditions.containsKey(compare)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
355 replaceWith = ConstantNode.forBoolean(false, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
356 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
357 if (compare instanceof InstanceOfNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
358 InstanceOfNode instanceOf = (InstanceOfNode) compare; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
359 ValueNode object = instanceOf.object(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
360 if (state.knownNull.contains(object)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
361 replaceWith = ConstantNode.forBoolean(false, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
362 } else if (state.knownNotNull.contains(object)) { |
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
|
363 ResolvedJavaType type = state.getNodeType(object); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
364 if (type != null && type.isSubtypeOf(instanceOf.targetClass())) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
365 replaceWith = ConstantNode.forBoolean(true, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
366 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
367 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
368 if (replaceWith != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
369 metricInstanceOfRemoved.increment(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
370 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
371 } else if (compare instanceof IsNullNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
372 IsNullNode isNull = (IsNullNode) compare; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
373 ValueNode object = isNull.object(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
374 if (state.knownNull.contains(object)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
375 replaceWith = ConstantNode.forBoolean(true, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
376 } else if (state.knownNotNull.contains(object)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
377 replaceWith = ConstantNode.forBoolean(false, graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
378 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
379 if (replaceWith != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
380 metricNullCheckRemoved.increment(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
381 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
382 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
383 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
384 if (replaceWith != null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
385 ifNode.setCompare(replaceWith); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
386 if (compare.usages().isEmpty()) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
387 GraphUtil.killWithUnusedFloatingInputs(compare); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
388 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
389 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
390 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
391 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
392 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
393 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
394 } |