Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java @ 12655:2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 03 Nov 2013 15:27:52 +0100 |
parents | b433297f21c4 |
children | a03cb658e68e |
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 |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
25 import java.lang.reflect.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
26 import java.util.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5443
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
5391
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.*; |
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.*; |
11317
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11310
diff
changeset
|
36 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
11332
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
37 import com.oracle.graal.nodes.spi.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.type.*; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 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
|
40 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
|
41 import com.oracle.graal.phases.graph.*; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
43 public class ConditionalEliminationPhase extends Phase { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 |
7706
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 metricConditionRegistered = Debug.metric("ConditionRegistered"); |
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 metricTypeRegistered = Debug.metric("TypeRegistered"); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11943
diff
changeset
|
55 private final MetaAccessProvider metaAccess; |
5391
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 private StructuredGraph graph; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
58 |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11943
diff
changeset
|
59 public ConditionalEliminationPhase(MetaAccessProvider metaAccess) { |
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11943
diff
changeset
|
60 this.metaAccess = metaAccess; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
61 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
62 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
63 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 protected void run(StructuredGraph inputGraph) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 graph = inputGraph; |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
66 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
|
67 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 |
10803
4532725151cc
make MergeableState an abstract class instead of an interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
10802
diff
changeset
|
69 public static class State extends MergeableState<State> { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
70 |
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
|
71 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
|
72 private HashSet<ValueNode> knownNonNull; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
73 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
|
74 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
|
75 private IdentityHashMap<LogicNode, ValueNode> falseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
76 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
77 public State() { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
78 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
|
79 this.knownNonNull = new HashSet<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
80 this.knownNull = new HashSet<>(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
81 this.trueConditions = new IdentityHashMap<>(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
82 this.falseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
85 public State(State other) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
86 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
|
87 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
|
88 this.knownNull = new HashSet<>(other.knownNull); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
89 this.trueConditions = new IdentityHashMap<>(other.trueConditions); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
90 this.falseConditions = new IdentityHashMap<>(other.falseConditions); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 } |
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 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 IdentityHashMap<LogicNode, ValueNode> newFalseConditions = new IdentityHashMap<>(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
99 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
|
100 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
|
101 for (State state : withStates) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
102 newKnownNull.retainAll(state.knownNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
103 newKnownNonNull.retainAll(state.knownNonNull); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
104 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
105 |
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 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
|
107 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
|
108 ResolvedJavaType type = entry.getValue(); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 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
|
111 ResolvedJavaType otherType = other.getNodeType(node); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 type = widen(type, otherType); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 if (type == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 break; |
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 } |
11265 | 117 if (type != null && type != ObjectStamp.typeOrNull(node)) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 newKnownTypes.put(node, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
121 |
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
|
122 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
|
123 LogicNode check = entry.getKey(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
124 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
125 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
126 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
127 ValueNode otherGuard = other.trueConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
128 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
129 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
130 break; |
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 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
133 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
134 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
135 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
136 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
137 newTrueConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
138 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
139 } |
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
|
140 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
|
141 LogicNode check = entry.getKey(); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
142 ValueNode guard = entry.getValue(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
143 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
144 for (State other : withStates) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
145 ValueNode otherGuard = other.falseConditions.get(check); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
146 if (otherGuard == null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
147 guard = null; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
148 break; |
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 if (otherGuard != guard) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
151 guard = merge; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
152 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
153 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
154 if (guard != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
155 newFalseConditions.put(check, guard); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
156 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
157 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
158 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
159 // this piece of code handles phis |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 if (!(merge instanceof LoopBeginNode)) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 for (PhiNode phi : merge.phis()) { |
5774
a1db0ea58b53
Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5541
diff
changeset
|
162 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
|
163 ValueNode firstValue = phi.valueAt(0); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
164 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
|
165 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
|
166 boolean isNull = knownNull.contains(firstValue); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 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
|
169 State otherState = withStates.get(i); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 ValueNode value = phi.valueAt(i + 1); |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5774
diff
changeset
|
171 ResolvedJavaType otherType = otherState.getNodeType(value); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 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
|
173 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
|
174 isNull &= otherState.knownNull.contains(value); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
176 if (type != null) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 newKnownTypes.put(phi, type); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
179 if (nonNull) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
180 newKnownNonNull.add(phi); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
182 if (isNull) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
183 newKnownNull.add(phi); |
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 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
186 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 } |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
188 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 this.knownTypes = newKnownTypes; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
190 this.knownNonNull = newKnownNonNull; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
191 this.knownNull = newKnownNull; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
192 this.trueConditions = newTrueConditions; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
193 this.falseConditions = newFalseConditions; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 return true; |
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 |
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
|
197 public ResolvedJavaType getNodeType(ValueNode node) { |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
198 ResolvedJavaType result = knownTypes.get(GraphUtil.unproxify(node)); |
11265 | 199 return result == null ? ObjectStamp.typeOrNull(node) : result; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
200 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
201 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
202 public boolean isNull(ValueNode value) { |
11265 | 203 return ObjectStamp.isObjectAlwaysNull(value) || knownNull.contains(GraphUtil.unproxify(value)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
204 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
205 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
206 public boolean isNonNull(ValueNode value) { |
11265 | 207 return ObjectStamp.isObjectNonNull(value) || knownNonNull.contains(GraphUtil.unproxify(value)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
208 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
209 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
210 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
211 public State clone() { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
212 return new State(this); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
214 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
215 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
216 * 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
|
217 * 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
|
218 */ |
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
|
219 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
|
220 if (isTrue) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
221 if (!trueConditions.containsKey(condition)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
222 trueConditions.put(condition, anchor); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
223 metricConditionRegistered.increment(); |
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 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
226 if (!falseConditions.containsKey(condition)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
227 falseConditions.put(condition, anchor); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
228 metricConditionRegistered.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
229 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
230 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
231 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
232 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
233 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
234 * 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
|
235 * 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
|
236 */ |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
237 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
|
238 if (isNull) { |
10802
e6bb7edcc66c
fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents:
10790
diff
changeset
|
239 if (!isNull(value)) { |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
240 metricNullnessRegistered.increment(); |
10802
e6bb7edcc66c
fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents:
10790
diff
changeset
|
241 knownNull.add(GraphUtil.unproxify(value)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
242 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
243 } else { |
10802
e6bb7edcc66c
fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents:
10790
diff
changeset
|
244 if (!isNonNull(value)) { |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
245 metricNullnessRegistered.increment(); |
10802
e6bb7edcc66c
fix for ConditionalEliminationPhase.addNullness
Lukas Stadler <lukas.stadler@jku.at>
parents:
10790
diff
changeset
|
246 knownNonNull.add(GraphUtil.unproxify(value)); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
247 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
248 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
249 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
250 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
251 public void addType(ResolvedJavaType type, ValueNode value) { |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
252 ValueNode original = GraphUtil.unproxify(value); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
253 ResolvedJavaType knownType = getNodeType(original); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
254 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
|
255 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
256 if (newType != knownType) { |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
257 knownTypes.put(original, newType); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
258 metricTypeRegistered.increment(); |
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 } |
11706
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
261 |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
262 public void clear() { |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
263 knownTypes.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
264 knownNonNull.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
265 knownNull.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
266 trueConditions.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
267 falseConditions.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
268 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
269 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 |
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
|
271 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
|
272 if (a == null || b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
273 return null; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 } 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
|
277 return a.findLeastCommonAncestor(b); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
278 } |
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 |
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
|
281 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
|
282 if (a == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
283 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
284 } else if (b == null) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
285 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
286 } else if (a == b) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
287 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
|
288 } else if (a.isAssignableFrom(b)) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
289 return b; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
290 } else { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 return a; |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 } |
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 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
295 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
|
296 |
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
|
297 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
|
298 private final LogicNode falseConstant; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
299 |
6587
795df1687282
renamed CheckCastElimination to ConditionalElimination, plus a few small changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
6564
diff
changeset
|
300 public ConditionalElimination(FixedNode start, State initialState) { |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
301 super(start, initialState); |
8389
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
302 trueConstant = LogicConstantNode.tautology(graph); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
303 falseConstant = LogicConstantNode.contradiction(graph); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
304 } |
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 @Override |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
307 public void finished() { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
308 if (trueConstant.usages().isEmpty()) { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
309 graph.removeFloating(trueConstant); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
310 } |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
311 if (falseConstant.usages().isEmpty()) { |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
312 graph.removeFloating(falseConstant); |
e53b31b29aa4
clean up unused true/false constants in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7767
diff
changeset
|
313 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
314 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
315 |
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
|
316 private void registerCondition(boolean isTrue, LogicNode condition, ValueNode anchor) { |
10789
ec4c7c33e8e5
rename: LogicBinaryNode -> ShortCircuitBooleanNode, Logic[Conjunction|Disjunction]Node -> ShortCircuit[And|Or]Node
Doug Simon <doug.simon@oracle.com>
parents:
10767
diff
changeset
|
317 if (!isTrue && condition instanceof ShortCircuitOrNode) { |
ec4c7c33e8e5
rename: LogicBinaryNode -> ShortCircuitBooleanNode, Logic[Conjunction|Disjunction]Node -> ShortCircuit[And|Or]Node
Doug Simon <doug.simon@oracle.com>
parents:
10767
diff
changeset
|
318 ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition; |
10749
e7c0658c2f25
record disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10748
diff
changeset
|
319 registerCondition(disjunction.isXNegated(), disjunction.getX(), anchor); |
e7c0658c2f25
record disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10748
diff
changeset
|
320 registerCondition(disjunction.isYNegated(), disjunction.getY(), anchor); |
12485
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
321 } |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
322 state.addCondition(isTrue, condition, anchor); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
323 |
12485
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
324 if (isTrue && condition instanceof InstanceOfNode) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
325 InstanceOfNode instanceOf = (InstanceOfNode) condition; |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
326 ValueNode object = instanceOf.object(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
327 state.addNullness(false, object); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
328 state.addType(instanceOf.type(), object); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
329 } else if (condition instanceof IsNullNode) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
330 IsNullNode nullCheck = (IsNullNode) condition; |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
331 state.addNullness(isTrue, nullCheck.object()); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
332 } else if (condition instanceof ObjectEqualsNode) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
333 ObjectEqualsNode equals = (ObjectEqualsNode) condition; |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
334 ValueNode x = equals.x(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
335 ValueNode y = equals.y(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
336 if (isTrue) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
337 if (state.isNull(x) && !state.isNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
338 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
339 state.addNullness(true, y); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
340 } else if (!state.isNull(x) && state.isNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
341 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
342 state.addNullness(true, x); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
343 } |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
344 if (state.isNonNull(x) && !state.isNonNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
345 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
346 state.addNullness(false, y); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
347 } else if (!state.isNonNull(x) && state.isNonNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
348 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
349 state.addNullness(false, x); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
350 } |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
351 } else { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
352 if (state.isNull(x) && !state.isNonNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
353 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
354 state.addNullness(false, y); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
355 } else if (!state.isNonNull(x) && state.isNull(y)) { |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
356 metricObjectEqualsRegistered.increment(); |
b433297f21c4
Conditional Elimination should not skip registering ShortCut conditions
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12049
diff
changeset
|
357 state.addNullness(false, x); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
358 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
359 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
360 } |
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 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
363 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
|
364 assert pred != null && begin != null; |
11706
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
365 if (begin instanceof LoopExitNode) { |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
366 state.clear(); |
cfca65c7cf02
Do not propagate state over loop exits in conditional elimination phase as the phase does not insert proxy nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11393
diff
changeset
|
367 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
368 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
369 if (pred instanceof IfNode) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
370 IfNode ifNode = (IfNode) pred; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
371 |
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
|
372 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
|
373 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
|
374 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
375 } 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
|
376 TypeSwitchNode typeSwitch = (TypeSwitchNode) pred; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
377 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
378 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
|
379 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
|
380 ResolvedJavaType type = null; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
381 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
|
382 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
|
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 type = typeSwitch.typeAt(i); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
385 } else { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
386 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
|
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 if (type != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
391 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
|
392 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
|
393 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
394 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
395 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
396 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
397 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
398 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
|
399 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
|
400 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
401 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
|
402 if (existingGuards != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
403 guard.replaceAtUsages(existingGuards); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
404 GraphUtil.killWithUnusedFloatingInputs(guard); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
405 metricGuardsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
406 } else { |
10720
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
407 ValueNode anchor = state.trueConditions.get(condition); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
408 if (anchor != null) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
409 if (!guard.negated()) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
410 guard.replaceAtUsages(anchor); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
411 metricGuardsRemoved.increment(); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
412 GraphUtil.killWithUnusedFloatingInputs(guard); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
413 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
414 } else { |
10720
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
415 anchor = state.falseConditions.get(condition); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
416 if (anchor != null) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
417 if (guard.negated()) { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
418 guard.replaceAtUsages(anchor); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
419 metricGuardsRemoved.increment(); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
420 GraphUtil.killWithUnusedFloatingInputs(guard); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
421 } |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
422 } else { |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
423 registerCondition(!guard.negated(), condition, guard); |
7cc08d83111d
correctly anchor eliminated guards during ConditionalElimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
424 } |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
425 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
426 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
427 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
428 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
429 /** |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
430 * 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
|
431 * 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
|
432 * otherwise null. |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
433 */ |
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
|
434 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
|
435 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
|
436 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
437 } 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
|
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 { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
440 if (condition instanceof InstanceOfNode) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
441 InstanceOfNode instanceOf = (InstanceOfNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
442 ValueNode object = instanceOf.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
443 if (state.isNull(object)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
444 metricInstanceOfRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
445 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
446 } 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
|
447 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
|
448 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
|
449 metricInstanceOfRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
450 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
451 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
452 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
453 } 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
|
454 IsNullNode isNull = (IsNullNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
455 ValueNode object = isNull.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
456 if (state.isNull(object)) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
457 metricNullCheckRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
458 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
459 } 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
|
460 metricNullCheckRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
461 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
462 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
463 } 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
|
464 ObjectEqualsNode equals = (ObjectEqualsNode) condition; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
465 ValueNode x = equals.x(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
466 ValueNode y = equals.y(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
467 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
|
468 metricObjectEqualsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
469 return falseValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
470 } 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
|
471 metricObjectEqualsRemoved.increment(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
472 return trueValue; |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
473 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
474 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
475 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
476 return null; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
477 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
478 |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
479 @Override |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
480 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
|
481 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
|
482 AbstractBeginNode begin = (AbstractBeginNode) node; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
483 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
|
484 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
485 if (pred != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
486 registerControlSplitInfo(pred, begin); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
487 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
488 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
|
489 registerGuard(guard); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
490 } |
10781
c53544484645
process FixedGuardNodes in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10767
diff
changeset
|
491 } else if (node instanceof FixedGuardNode) { |
c53544484645
process FixedGuardNodes in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10767
diff
changeset
|
492 FixedGuardNode guard = (FixedGuardNode) node; |
c53544484645
process FixedGuardNodes in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10767
diff
changeset
|
493 registerCondition(!guard.isNegated(), guard.condition(), guard); |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
494 } else if (node instanceof CheckCastNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
495 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
|
496 ValueNode object = checkCast.object(); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
497 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
|
498 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
|
499 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
|
500 boolean nonNull = state.isNonNull(object); |
11305
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
501 GuardingNode replacementAnchor = null; |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
502 if (nonNull) { |
11332
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
503 replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type); |
11305
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
504 } |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
505 ValueAnchorNode anchor = null; |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
506 if (replacementAnchor == null) { |
11711
f12b418ebc74
Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11706
diff
changeset
|
507 anchor = graph.add(new ValueAnchorNode(null)); |
11305
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
508 replacementAnchor = anchor; |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
509 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
510 PiNode piNode; |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
511 if (isNull) { |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11943
diff
changeset
|
512 ConstantNode nullObject = ConstantNode.forObject(null, metaAccess, graph); |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12485
diff
changeset
|
513 piNode = graph.unique(new PiNode(nullObject, StampFactory.forConstant(nullObject.getValue(), metaAccess), replacementAnchor.asNode())); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
514 } else { |
11752
7e7edb86fb43
Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11711
diff
changeset
|
515 piNode = graph.unique(new PiNode(object, StampFactory.declared(type, nonNull), replacementAnchor.asNode())); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
516 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
517 checkCast.replaceAtUsages(piNode); |
11305
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
518 if (anchor != null) { |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
519 graph.replaceFixedWithFixed(checkCast, anchor); |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
520 } else { |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
521 graph.removeFixed(checkCast); |
edf7e09ad382
Search for correct replacement anchor for eliminated checkcasts in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11298
diff
changeset
|
522 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
523 metricCheckCastRemoved.increment(); |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
524 } |
11943
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
525 } else if (node instanceof ConditionAnchorNode) { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
526 ConditionAnchorNode conditionAnchorNode = (ConditionAnchorNode) node; |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
527 LogicNode condition = conditionAnchorNode.condition(); |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
528 ValueNode replacementAnchor = null; |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
529 if (conditionAnchorNode.isNegated()) { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
530 if (state.falseConditions.containsKey(condition)) { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
531 replacementAnchor = state.falseConditions.get(condition); |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
532 } |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
533 } else { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
534 if (state.trueConditions.containsKey(condition)) { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
535 replacementAnchor = state.trueConditions.get(condition); |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
536 } |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
537 } |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
538 if (replacementAnchor != null) { |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
539 conditionAnchorNode.replaceAtUsages(replacementAnchor); |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
540 conditionAnchorNode.graph().removeFixed(conditionAnchorNode); |
0fa39f034839
Allow floating unsafe loads.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11752
diff
changeset
|
541 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
542 } else if (node instanceof IfNode) { |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
543 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
|
544 LogicNode compare = ifNode.condition(); |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
545 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
546 LogicNode replacement = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
547 ValueNode replacementAnchor = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
548 AbstractBeginNode survivingSuccessor = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
549 if (state.trueConditions.containsKey(compare)) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
550 replacement = trueConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
551 replacementAnchor = state.trueConditions.get(compare); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
552 survivingSuccessor = ifNode.trueSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
553 } else if (state.falseConditions.containsKey(compare)) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
554 replacement = falseConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
555 replacementAnchor = state.falseConditions.get(compare); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
556 survivingSuccessor = ifNode.falseSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
557 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
558 replacement = evaluateCondition(compare, trueConstant, falseConstant); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
559 if (replacement != null) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
560 if (replacement == trueConstant) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
561 survivingSuccessor = ifNode.trueSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
562 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
563 assert replacement == falseConstant; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
564 survivingSuccessor = ifNode.falseSuccessor(); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
565 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
566 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
567 } |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
568 |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
569 if (replacement != null) { |
11393
fb6353944874
Make ConditionalEliminationPhase more robust when removing IfNodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11332
diff
changeset
|
570 if (!(replacementAnchor instanceof AbstractBeginNode)) { |
11317
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11310
diff
changeset
|
571 ValueAnchorNode anchor = graph.add(new ValueAnchorNode(replacementAnchor)); |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11310
diff
changeset
|
572 graph.addBeforeFixed(ifNode, anchor); |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11310
diff
changeset
|
573 } |
11309
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
574 for (Node n : survivingSuccessor.usages().snapshot()) { |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
575 if (n instanceof GuardNode || n instanceof ProxyNode) { |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
576 // Keep wired to the begin node. |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
577 } else { |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
578 if (replacementAnchor == null) { |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
579 // Cannot simplify this IfNode as there is no anchor. |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
580 return; |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
581 } |
11309
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
582 // Rewire to the replacement anchor. |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
583 n.replaceFirstInput(survivingSuccessor, replacementAnchor); |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
9436
diff
changeset
|
584 } |
11309
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
585 } |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
586 |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
587 ifNode.setCondition(replacement); |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
588 if (compare.usages().isEmpty()) { |
2f216d44bce4
Fix anchoring in ConditionalEliminationPhase when simplifying an IfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11305
diff
changeset
|
589 GraphUtil.killWithUnusedFloatingInputs(compare); |
7706
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
590 } |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
591 } |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8649
diff
changeset
|
592 } 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
|
593 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
|
594 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
|
595 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
|
596 ValueNode value = phi.valueAt(index); |
7724
ac3579b4adc9
remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7706
diff
changeset
|
597 if (value instanceof ConditionalNode) { |
ac3579b4adc9
remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7706
diff
changeset
|
598 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
|
599 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
|
600 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
|
601 |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
602 if (replacement != null) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
603 phi.setValueAt(index, replacement); |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
604 if (materialize.usages().isEmpty()) { |
9ea26951d826
fix TypeSystemTest, cleanup of ConditionalEliminationPhase, handle ObjectEqualsNode and MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
605 GraphUtil.killWithUnusedFloatingInputs(materialize); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5393
diff
changeset
|
606 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
607 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
608 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
609 } |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
610 } else if (node instanceof Invoke) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
611 Invoke invoke = (Invoke) node; |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
612 if (invoke.callTarget() instanceof MethodCallTargetNode) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
613 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget(); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
614 ValueNode receiver = callTarget.receiver(); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
615 if (receiver != null && (callTarget.invokeKind() == InvokeKind.Interface || callTarget.invokeKind() == InvokeKind.Virtual)) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
616 ResolvedJavaType type = state.getNodeType(receiver); |
11265 | 617 if (type != ObjectStamp.typeOrNull(receiver)) { |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
618 ResolvedJavaMethod method = type.resolveMethod(callTarget.targetMethod()); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
619 if (method != null) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
620 if ((method.getModifiers() & Modifier.FINAL) != 0 || (type.getModifiers() & Modifier.FINAL) != 0) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
621 callTarget.setInvokeKind(InvokeKind.Special); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
622 callTarget.setTargetMethod(method); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
623 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
624 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
625 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
626 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
627 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10749
diff
changeset
|
628 |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
629 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
630 } |
11332
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
631 |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
632 private GuardingNode searchAnchor(ValueNode value, ResolvedJavaType type) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
633 for (Node n : value.usages()) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
634 if (n instanceof InstanceOfNode) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
635 InstanceOfNode instanceOfNode = (InstanceOfNode) n; |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
636 if (instanceOfNode.type() == type && state.trueConditions.containsKey(instanceOfNode)) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
637 ValueNode v = state.trueConditions.get(instanceOfNode); |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
638 if (v instanceof GuardingNode) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
639 return (GuardingNode) v; |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
640 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
641 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
642 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
643 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
644 |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
645 for (Node n : value.usages()) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
646 if (n instanceof ValueProxy) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
647 ValueProxy proxyNode = (ValueProxy) n; |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
648 if (proxyNode.getOriginalValue() == value) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
649 GuardingNode result = searchAnchor((ValueNode) n, type); |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
650 if (result != null) { |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
651 return result; |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
652 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
653 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
654 |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
655 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
656 } |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
657 |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
658 return null; |
e4a1593cc6e4
Search through tree of proxies for replacement anchor in ConditionalEliminationPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11317
diff
changeset
|
659 } |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
660 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
661 } |