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