Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java @ 18163:c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 24 Oct 2014 16:18:10 +0200 |
parents | 4182366b8eed |
children | 1518c3296cc8 |
rev | line source |
---|---|
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
1 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
4 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
8 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
14 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
18 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
21 * questions. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
22 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.phases.common.cfs; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
24 |
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:
15515
diff
changeset
|
25 import static com.oracle.graal.graph.util.CollectionsAccess.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
26 |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
27 import java.lang.reflect.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
28 import java.util.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
29 |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
32 import com.oracle.graal.debug.*; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.*; |
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:
15515
diff
changeset
|
34 import com.oracle.graal.nodes.calc.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
35 import com.oracle.graal.nodes.extended.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
36 import com.oracle.graal.nodes.java.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
37 import com.oracle.graal.nodes.spi.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
38 import com.oracle.graal.nodes.type.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
39 import com.oracle.graal.nodes.util.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
40 import com.oracle.graal.phases.graph.*; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
41 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
42 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
43 * A State instance is mutated in place as each FixedNode is visited in a basic block of |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
44 * instructions. Basic block: starts with a {@link com.oracle.graal.nodes.BeginNode BeginNode}, ends |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
45 * at an {@link com.oracle.graal.nodes.EndNode EndNode} or |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
46 * {@link com.oracle.graal.nodes.ControlSinkNode ControlSinkNode} and lacks intervening control |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
47 * splits or merges. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
48 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
49 public final class State extends MergeableState<State> implements Cloneable { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
50 |
15498
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
51 private static final DebugMetric metricTypeRegistered = Debug.metric("FSR-TypeRegistered"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
52 private static final DebugMetric metricNullnessRegistered = Debug.metric("FSR-NullnessRegistered"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
53 private static final DebugMetric metricObjectEqualsRegistered = Debug.metric("FSR-ObjectEqualsRegistered"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
54 private static final DebugMetric metricImpossiblePathDetected = Debug.metric("FSR-ImpossiblePathDetected"); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
55 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
56 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
57 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
58 * Each state update results in a higher {@link State#versionNr versionNr}. The |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
59 * {@link State#versionNr versionNr} of different State instances can't be meaningfully compared |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
60 * (ie, same {@link State#versionNr versionNr} just indicates they've gone through the same |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
61 * number of updates). In particular, the {@link State#versionNr versionNr} of a merged state |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
62 * doesn't guarantee any more than being different from those of the states being merged. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
63 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
64 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
65 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
66 * Still, {@link State#versionNr versionNr} proves useful in two cases: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
67 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
68 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
69 * <li>recording the {@link State#versionNr versionNr} right after {@link State State} cloning, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
70 * allows finding out afterwards whether (a) both states have diverged, (b) just one of them, or |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
71 * (c) none of them.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
72 * <li>a {@link State State} may become {@link State#isUnreachable isUnreachable}. In such case, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
73 * it may make a difference whether any updates were performed on the state from the time it was |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
74 * cloned. Those updates indicate information not available in the state is was cloned from. For |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
75 * the purposes of {@link FlowSensitiveReduction FlowSensitiveReduction} an unreachable state |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
76 * need not be merged with any other (because control-flow won't reach the merge point over the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
77 * path of the unreachable state).</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
78 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
79 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
80 * |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
81 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
82 int versionNr = 0; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
83 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
84 boolean isUnreachable = false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
85 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
86 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
87 * Getting here implies an opportunity was detected for dead-code-elimination. A counterpoint |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
88 * argument goes as follows: perhaps we don't get here that often, in which case the effort to |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
89 * detect an "impossible path" could be shaved off. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
90 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
91 * @see com.oracle.graal.phases.common.cfs.BaseReduction.PostponedDeopt |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
92 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
93 void impossiblePath() { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
94 isUnreachable = true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
95 metricImpossiblePathDetected.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
96 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
97 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
98 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
99 * <p> |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
100 * This map tracks properties about reference-values, ie combinations of: definitely-null, |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
101 * known-to-be-non-null, seen-type. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
102 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
103 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
104 * <p> |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
105 * In contrast to {@link #trueFacts} and {@link #falseFacts}, this map can answer queries even |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
106 * though the exact {@link LogicNode} standing for such query hasn't been tracked. For example, |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
107 * queries about subtyping. Additionally, a {@link Witness} can combine separate pieces of |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
108 * information more flexibly, eg, two separate observations about non-null and check-cast are |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
109 * promoted to an instance-of witness. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
110 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
111 * |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
112 */ |
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:
15515
diff
changeset
|
113 private Map<ValueNode, Witness> typeRefinements; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
114 |
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:
15515
diff
changeset
|
115 Map<LogicNode, GuardingNode> trueFacts; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
116 Map<LogicNode, GuardingNode> falseFacts; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
117 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
118 public State() { |
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:
15515
diff
changeset
|
119 this.typeRefinements = newNodeIdentityMap(); |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
120 this.trueFacts = newNodeIdentityMap(); |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
121 this.falseFacts = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
122 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
123 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
124 public State(State other) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
125 this.isUnreachable = other.isUnreachable; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
126 this.versionNr = other.versionNr; |
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:
15515
diff
changeset
|
127 this.typeRefinements = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
128 for (Map.Entry<ValueNode, Witness> entry : other.typeRefinements.entrySet()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
129 this.typeRefinements.put(entry.getKey(), new Witness(entry.getValue())); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
130 } |
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:
15515
diff
changeset
|
131 this.trueFacts = newNodeIdentityMap(other.trueFacts); |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
132 this.falseFacts = newNodeIdentityMap(other.falseFacts); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
133 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
134 |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
135 public boolean repOK() { |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
136 // trueFacts and falseFacts disjoint |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
137 for (LogicNode trueFact : trueFacts.keySet()) { |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
138 assert !falseFacts.containsKey(trueFact) : trueFact + " tracked as both true and false fact."; |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
139 } |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
140 return true; |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
141 } |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
142 |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
143 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
144 * @return A new list containing only those states that are reachable. |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
145 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
146 private static ArrayList<State> reachableStates(List<State> states) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
147 ArrayList<State> result = new ArrayList<>(states); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
148 Iterator<State> iter = result.iterator(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
149 while (iter.hasNext()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
150 if (iter.next().isUnreachable) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
151 iter.remove(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
152 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
153 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
154 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
155 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
156 |
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:
15515
diff
changeset
|
157 private Map<ValueNode, Witness> mergeKnownTypes(MergeNode merge, ArrayList<State> withReachableStates) { |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
158 Map<ValueNode, Witness> newKnownTypes = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
159 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
160 for (Map.Entry<ValueNode, Witness> entry : typeRefinements.entrySet()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
161 ValueNode node = entry.getKey(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
162 Witness type = new Witness(entry.getValue()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
163 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
164 for (State other : withReachableStates) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
165 Witness otherType = other.typeInfo(node); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
166 if (otherType == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
167 type = null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
168 break; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
169 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
170 type.merge(otherType, merge); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
171 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
172 if (type != null && type.knowsBetterThan(node)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
173 assert node == GraphUtil.unproxify(node); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
174 newKnownTypes.put(node, type); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
175 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
176 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
177 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
178 return newKnownTypes; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
179 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
180 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
181 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
182 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
183 * This method handles phis, by adding to the resulting state any information that can be gained |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
184 * (about type-refinement and nullness) based on the data available at each of the incoming |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
185 * branches. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
186 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
187 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
188 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
189 * In more detail, <code>FlowSensitiveReduction#visitAbstractEndNode()</code> has already |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
190 * deverbosified the phi-values contributed by each reachable branch. The paths that |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
191 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction} determined to be |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
192 * unreachable will be eliminated by canonicalization and dead code elimination. For now they |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
193 * still exist, thus polluting the result of |
15754
45285c8eccbd
Never use the current node's stamp in ValueNode.inferStamp overrides.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15563
diff
changeset
|
194 * {@link com.oracle.graal.nodes.ValuePhiNode#inferStamp()} but we are careful to skip them when |
45285c8eccbd
Never use the current node's stamp in ValueNode.inferStamp overrides.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15563
diff
changeset
|
195 * merging type-witnesses and known-null maps. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
196 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
197 */ |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
198 private void mergePhis(MergeNode merge, List<State> withStates, Map<ValueNode, Witness> newKnownPhiTypes) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
199 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
200 if (merge instanceof LoopBeginNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
201 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
202 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
203 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
204 for (PhiNode phi : merge.phis()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
205 assert phi == GraphUtil.unproxify(phi); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
206 if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
207 ArrayList<ValueNode> reachingValues = new ArrayList<>(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
208 if (!isUnreachable) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
209 reachingValues.add(phi.valueAt(0)); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
210 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
211 for (int i = 0; i < withStates.size(); i++) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
212 State otherState = withStates.get(i); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
213 if (!otherState.isUnreachable) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
214 reachingValues.add(phi.valueAt(i + 1)); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
215 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
216 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
217 assert !reachingValues.isEmpty(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
218 ObjectStamp phiStamp = (ObjectStamp) phi.stamp(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
219 ObjectStamp nonPollutedStamp = (ObjectStamp) StampTool.meet(reachingValues); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
220 Witness w = new Witness(nonPollutedStamp, merge); |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
221 if (w.isNull() && !phiStamp.alwaysNull()) { |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
222 // precision gain: null |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
223 newKnownPhiTypes.put(phi, w); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
224 } else if (FlowUtil.isMorePrecise(w.type(), phiStamp.type())) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
225 // precision gain regarding type |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
226 newKnownPhiTypes.put(phi, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
227 // confirm no precision loss regarding nullness |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
228 assert implies(phiStamp.nonNull(), w.isNonNull()); |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
229 assert implies(phiStamp.alwaysNull(), w.isNull()); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
230 } else if (w.isNonNull() && !phiStamp.nonNull()) { |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
231 // precision gain: non-null |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
232 newKnownPhiTypes.put(phi, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
233 // confirm no precision loss regarding type |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
234 assert !FlowUtil.isMorePrecise(phiStamp.type(), w.type()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
235 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
236 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
237 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
238 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
239 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
240 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
241 private static boolean implies(boolean a, boolean b) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
242 return !a || b; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
243 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
244 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
245 @Override |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
246 public boolean merge(MergeNode merge, List<State> withStates) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
247 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
248 ArrayList<State> withReachableStates = reachableStates(withStates); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
249 if (withReachableStates.isEmpty()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
250 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
251 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
252 |
15444
be6685c6a831
[flow-sensitive] readability
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15443
diff
changeset
|
253 for (State other : withReachableStates) { |
be6685c6a831
[flow-sensitive] readability
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15443
diff
changeset
|
254 versionNr = Math.max(versionNr, other.versionNr) + 1; |
be6685c6a831
[flow-sensitive] readability
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15443
diff
changeset
|
255 if (!other.isUnreachable) { |
be6685c6a831
[flow-sensitive] readability
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15443
diff
changeset
|
256 isUnreachable = false; |
be6685c6a831
[flow-sensitive] readability
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15443
diff
changeset
|
257 } |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
258 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
259 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
260 if (isUnreachable) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
261 typeRefinements.clear(); |
15426
e9029a026dc9
[flow-sensitive] bug fixes, missing state clearing
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15425
diff
changeset
|
262 trueFacts.clear(); |
e9029a026dc9
[flow-sensitive] bug fixes, missing state clearing
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15425
diff
changeset
|
263 falseFacts.clear(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
264 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
265 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
266 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
267 // may also get updated in a moment, during processing of phi nodes. |
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:
15515
diff
changeset
|
268 Map<ValueNode, Witness> newKnownTypes = mergeKnownTypes(merge, withReachableStates); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
269 // may also get updated in a moment, during processing of phi nodes. |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
270 mergePhis(merge, withStates, newKnownTypes); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
271 this.typeRefinements = newKnownTypes; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
272 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
273 this.trueFacts = mergeTrueFacts(withReachableStates, merge); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
274 this.falseFacts = mergeFalseFacts(withReachableStates, merge); |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
275 |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
276 assert repOK(); |
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
277 |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
278 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
279 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
280 |
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:
15515
diff
changeset
|
281 private Map<LogicNode, GuardingNode> mergeTrueFacts(ArrayList<State> withReachableStates, GuardingNode merge) { |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
282 Map<LogicNode, GuardingNode> newTrueConditions = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
283 for (Map.Entry<LogicNode, GuardingNode> entry : trueFacts.entrySet()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
284 LogicNode check = entry.getKey(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
285 GuardingNode guard = entry.getValue(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
286 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
287 for (State other : withReachableStates) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
288 GuardingNode otherGuard = other.trueFacts.get(check); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
289 if (otherGuard == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
290 guard = null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
291 break; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
292 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
293 if (otherGuard != guard) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
294 guard = merge; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
295 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
296 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
297 if (guard != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
298 newTrueConditions.put(check, guard); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
299 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
300 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
301 return newTrueConditions; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
302 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
303 |
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:
15515
diff
changeset
|
304 private Map<LogicNode, GuardingNode> mergeFalseFacts(ArrayList<State> withReachableStates, GuardingNode merge) { |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15515
diff
changeset
|
305 Map<LogicNode, GuardingNode> newFalseConditions = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
306 for (Map.Entry<LogicNode, GuardingNode> entry : falseFacts.entrySet()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
307 LogicNode check = entry.getKey(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
308 GuardingNode guard = entry.getValue(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
309 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
310 for (State other : withReachableStates) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
311 GuardingNode otherGuard = other.falseFacts.get(check); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
312 if (otherGuard == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
313 guard = null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
314 break; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
315 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
316 if (otherGuard != guard) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
317 guard = merge; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
318 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
319 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
320 if (guard != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
321 newFalseConditions.put(check, guard); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
322 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
323 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
324 return newFalseConditions; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
325 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
326 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
327 /** |
15405 | 328 * @return null if no type-witness available for the argument, the witness otherwise. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
329 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
330 public Witness typeInfo(ValueNode object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
331 assert FlowUtil.hasLegalObjectStamp(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
332 return typeRefinements.get(GraphUtil.unproxify(object)); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
333 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
334 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
335 /** |
15405 | 336 * @return true iff the argument is known to stand for null. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
337 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
338 public boolean isNull(ValueNode object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
339 assert FlowUtil.hasLegalObjectStamp(object); |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
340 if (StampTool.isObjectAlwaysNull(object)) { |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
341 return true; |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
342 } |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
343 ValueNode scrutinee = GraphUtil.unproxify(object); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
344 Witness w = typeRefinements.get(scrutinee); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
345 return (w != null) && w.isNull(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
346 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
347 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
348 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
349 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
350 * It makes a difference calling {@link Witness#isNonNull()} as opposed to |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
351 * {@link State#isNonNull(com.oracle.graal.nodes.ValueNode)}. The former guarantees the witness |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
352 * provides a guard certifying non-nullness. The latter just tells us there exists some guard |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
353 * that certifies the property we asked about. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
354 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
355 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
356 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
357 * TODO improvement: isKnownNonNull could be made smarter by noticing some nodes always denote a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
358 * non-null value (eg, ObjectGetClassNode). Similarly for isKnownNull. Code that looks at the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
359 * stamp as well as code that looks for a non-null-witness would benefit from also checking such |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
360 * extended isKnownNonNull. Alternatively, the stamp of those nodes should always have |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
361 * is-non-null set. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
362 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
363 * |
15405 | 364 * @return true iff the argument is known to stand for non-null. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
365 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
366 public boolean isNonNull(ValueNode object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
367 assert FlowUtil.hasLegalObjectStamp(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
368 if (StampTool.isObjectNonNull(object)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
369 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
370 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
371 Witness w = typeInfo(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
372 return w == null ? false : w.isNonNull(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
373 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
374 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
375 /** |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
376 * @return true iff the argument definitely stands for an object-value that conforms to the |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
377 * given type. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
378 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
379 public boolean knownToConform(ValueNode object, ResolvedJavaType to) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
380 assert FlowUtil.hasLegalObjectStamp(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
381 assert !to.isPrimitive(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
382 ResolvedJavaType stampType = StampTool.typeOrNull(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
383 if (stampType != null && to.isAssignableFrom(stampType)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
384 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
385 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
386 final ValueNode scrutinee = GraphUtil.unproxify(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
387 if (isNull(scrutinee)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
388 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
389 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
390 Witness w = typeInfo(scrutinee); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
391 boolean witnessAnswer = w != null && w.type() != null && to.isAssignableFrom(w.type()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
392 if (witnessAnswer) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
393 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
394 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
395 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
396 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
397 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
398 /** |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
399 * @return true iff the argument is known to stand for an object that is definitely non-null and |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
400 * moreover does not conform to the given type. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
401 */ |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
402 public boolean knownNotToPassCheckCast(ValueNode object, ResolvedJavaType to) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
403 assert FlowUtil.hasLegalObjectStamp(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
404 assert !to.isPrimitive(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
405 final ValueNode scrutinee = GraphUtil.unproxify(object); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
406 if (isNull(scrutinee)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
407 // known-null means it conforms to whatever `to` |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
408 // and thus passes the check-cast |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
409 return false; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
410 } |
15491
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15444
diff
changeset
|
411 if (!isNonNull(scrutinee)) { |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15444
diff
changeset
|
412 // unless `null` can be ruled out, a positive answer isn't safe |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
413 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
414 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
415 ResolvedJavaType stampType = StampTool.typeOrNull(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
416 if (stampType != null && knownNotToConform(stampType, to)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
417 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
418 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
419 Witness w = typeInfo(scrutinee); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
420 boolean witnessAnswer = w != null && !w.cluelessAboutType() && knownNotToConform(w.type(), to); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
421 if (witnessAnswer) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
422 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
423 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
424 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
425 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
426 |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
427 /** |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
428 * @return true iff the argument is known to stand for an object that definitely does not |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
429 * conform to the given type (no matter whether the object turns out to be null or |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
430 * non-null). |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
431 */ |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
432 public boolean knownNotToPassInstanceOf(ValueNode object, ResolvedJavaType to) { |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
433 assert FlowUtil.hasLegalObjectStamp(object); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
434 assert !to.isPrimitive(); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
435 final ValueNode scrutinee = GraphUtil.unproxify(object); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
436 if (isNull(scrutinee)) { |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
437 return true; |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
438 } |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
439 ResolvedJavaType stampType = StampTool.typeOrNull(object); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
440 if (stampType != null && knownNotToConform(stampType, to)) { |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
441 // object turns out to be null, positive answer is correct |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
442 // object turns out non-null, positive answer is also correct |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
443 return true; |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
444 } |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
445 Witness w = typeInfo(scrutinee); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
446 boolean witnessAnswer = w != null && !w.cluelessAboutType() && knownNotToConform(w.type(), to); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
447 if (witnessAnswer) { |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
448 // object turns out to be null, positive answer is correct |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
449 // object turns out non-null, positive answer is also correct |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
450 return true; |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
451 } |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
452 return false; |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
453 } |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
454 |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
455 // @formatter:off |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
456 /** |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
457 * Determines if the first argument is known not to conform to the second argument. |
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
458 * |
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
459 * <pre> |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
460 * \ | | | | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
461 * \ b| | | | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
462 * a \ | | | | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
463 * \|iface|final|non-f| |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
464 * -----+-----------------| |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
465 * iface| F | F | F | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
466 * -----+-----------------| |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
467 * final| C | C | C | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
468 * -----+-----------------| |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
469 * non-f| F | C | C | |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
470 * -----------------------+ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
471 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
472 * where: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
473 * F: false |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
474 * C: check |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
475 * iface: interface |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
476 * final: exact non-interface reference-type |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
477 * non-f: non-exact non-interface reference-type |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
478 * </pre> |
15405 | 479 * @return true iff the first argument is known not to conform to the second argument. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
480 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
481 // @formatter:on |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
482 public static boolean knownNotToConform(ResolvedJavaType a, ResolvedJavaType b) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
483 assert !a.isPrimitive(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
484 assert !b.isPrimitive(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
485 if (b.isAssignableFrom(a)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
486 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
487 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
488 if (a.isInterface()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
489 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
490 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
491 boolean aFinal = Modifier.isFinal(a.getModifiers()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
492 if (b.isInterface() && !aFinal) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
493 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
494 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
495 if (a.isAssignableFrom(b)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
496 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
497 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
498 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
499 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
500 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
501 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
502 @Override |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
503 public State clone() { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
504 return new State(this); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
505 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
506 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
507 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
508 * Porcelain method. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
509 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
510 private Witness getOrElseAddTypeInfo(ValueNode object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
511 ValueNode scrutinee = GraphUtil.unproxify(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
512 Witness w = typeRefinements.get(scrutinee); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
513 if (w == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
514 w = new Witness(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
515 typeRefinements.put(scrutinee, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
516 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
517 return w; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
518 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
519 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
520 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
521 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
522 * Updates this {@link State State} to account for an observation about the scrutinee being |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
523 * non-null. In case instanceof was observed, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
524 * {@link #trackIO(com.oracle.graal.nodes.ValueNode, com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
525 * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
526 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
527 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
528 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
529 * No check is made on whether a contradiction would be introduced into the factbase (in which |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
530 * case the state should be marked unreachable), the caller takes care of that. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
531 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
532 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
533 * @return whether state was updated (iff the observation added any new information) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
534 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
535 public boolean trackNN(ValueNode object, GuardingNode anchor) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
536 if (isDependencyTainted(object, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
537 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
538 } |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
539 assert anchor instanceof FixedNode; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
540 ResolvedJavaType stampType = StampTool.typeOrNull(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
541 if (stampType != null && !stampType.isInterface()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
542 return trackIO(object, stampType, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
543 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
544 Witness w = getOrElseAddTypeInfo(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
545 if (w.trackNN(anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
546 versionNr++; |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
547 assert repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
548 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
549 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
550 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
551 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
552 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
553 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
554 * Updates this {@link State State} to account for an observation about the scrutinee conforming |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
555 * to a type. In case instanceof was observed, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
556 * {@link #trackIO(com.oracle.graal.nodes.ValueNode, com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
557 * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
558 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
559 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
560 * No check is made on whether a contradiction would be introduced into the factbase (in which |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
561 * case the state should be marked unreachable), the caller must take care of that. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
562 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
563 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
564 * @return false iff the observed type is an interface, or doesn't provide any new information |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
565 * not already known. Ie, this method returns true iff the observation resulted in |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
566 * information gain. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
567 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
568 public boolean trackCC(ValueNode object, ResolvedJavaType observed, GuardingNode anchor) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
569 if (observed.isInterface()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
570 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
571 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
572 if (isDependencyTainted(object, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
573 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
574 } |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
575 assert anchor instanceof FixedNode; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
576 Witness w = getOrElseAddTypeInfo(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
577 if (w.trackCC(observed, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
578 versionNr++; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
579 metricTypeRegistered.increment(); |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
580 assert repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
581 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
582 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
583 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
584 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
585 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
586 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
587 * Updates this {@link State State} to account for an observation about the non-null scrutinee |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
588 * conforming to a type. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
589 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
590 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
591 * No check is made on whether a contradiction would be introduced into the factbase (in which |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
592 * case the state should be marked unreachable), the caller must take care of that. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
593 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
594 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
595 * @return whether state was updated (iff the observation added any new information) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
596 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
597 public boolean trackIO(ValueNode object, ResolvedJavaType observed, GuardingNode anchor) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
598 assert !observed.isInterface() : "no infrastructure yet in State.Witness to support interfaces in general"; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
599 if (isDependencyTainted(object, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
600 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
601 } |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
602 assert anchor instanceof FixedNode; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
603 Witness w = getOrElseAddTypeInfo(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
604 if (w.trackIO(observed, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
605 versionNr++; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
606 metricTypeRegistered.increment(); |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
607 assert repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
608 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
609 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
610 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
611 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
612 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
613 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
614 * This method increases {@link #versionNr} (thus potentially invalidating |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
615 * {@link EquationalReasoner EquationalReasoner}'s caches) only if the fact wasn't known |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
616 * already. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
617 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
618 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
619 * No check is made on whether a contradiction would be introduced into the factbase (in which |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
620 * case the state should be marked unreachable), the caller must take care of that. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
621 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
622 * |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
623 */ |
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:
15515
diff
changeset
|
624 private void addFactPrimordial(LogicNode condition, Map<LogicNode, GuardingNode> to, GuardingNode anchor) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
625 assert condition != null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
626 if (!to.containsKey(condition)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
627 versionNr++; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
628 to.put(condition, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
629 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
630 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
631 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
632 /** |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
633 * Ideas for the future. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
634 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
635 * <li>track inferred less-than edges from (accumulated) CompareNode-s</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
636 * <li>track set-representative for equality classes determined by (chained) IntegerTestNode</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
637 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
638 * |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
639 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
640 public void addFact(boolean isTrue, LogicNode condition, GuardingNode anchor) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
641 assert anchor != null; |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
642 assert anchor instanceof FixedNode; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
643 assert !isUnreachable; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
644 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
645 if (condition instanceof LogicConstantNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
646 if (((LogicConstantNode) condition).getValue() != isTrue) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
647 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
648 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
649 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
650 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
651 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
652 if (condition instanceof LogicNegationNode) { |
16220
4182366b8eed
rename getInput() to getValue() in LogicNegationNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
653 addFact(!isTrue, ((LogicNegationNode) condition).getValue(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
654 } else if (condition instanceof ShortCircuitOrNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
655 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
656 * We can register the conditions being or-ed as long as the anchor is a fixed node, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
657 * because floating guards will be registered at a BeginNode but might be "valid" only |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
658 * later due to data flow dependencies. Therefore, registering both conditions of a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
659 * ShortCircuitOrNode for a floating guard could lead to cycles in data flow, because |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
660 * the guard will be used as anchor for both conditions, and one condition could be |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
661 * depending on the other. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
662 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
663 if (isTrue) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
664 CastCheckExtractor cce = CastCheckExtractor.extract(condition); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
665 if (cce == null || isDependencyTainted(cce.subject, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
666 addFactPrimordial(condition, isTrue ? trueFacts : falseFacts, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
667 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
668 trackCC(cce.subject, cce.type, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
669 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
670 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
671 ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
672 addFact(disjunction.isXNegated(), disjunction.getX(), anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
673 // previous addFact might have resulted in impossiblePath() |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
674 if (isUnreachable) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
675 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
676 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
677 addFact(disjunction.isYNegated(), disjunction.getY(), anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
678 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
679 } else if (condition instanceof InstanceOfNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
680 addFactInstanceOf(isTrue, (InstanceOfNode) condition, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
681 } else if (condition instanceof IsNullNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
682 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:
15754
diff
changeset
|
683 addNullness(isTrue, nullCheck.getValue(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
684 } else if (condition instanceof ObjectEqualsNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
685 addFactObjectEqualsNode(isTrue, (ObjectEqualsNode) condition, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
686 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
687 addFactPrimordial(condition, isTrue ? trueFacts : falseFacts, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
688 } |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
689 assert repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
690 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
691 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
692 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
693 * An instanceof hint is tracked differently depending on whether it's an interface-test or not |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
694 * (because type-refinements currently lacks the ability to track interface types). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
695 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
696 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
697 private void addFactInstanceOf(boolean isTrue, InstanceOfNode instanceOf, GuardingNode anchor) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
698 ValueNode object = instanceOf.getValue(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
699 if (isTrue) { |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
700 if (knownNotToPassInstanceOf(object, instanceOf.type())) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
701 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
702 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
703 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
704 addNullness(false, object, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
705 if (instanceOf.type().isInterface()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
706 if (!knownToConform(object, instanceOf.type())) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
707 addFactPrimordial(instanceOf, trueFacts, anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
708 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
709 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
710 trackIO(object, instanceOf.type(), anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
711 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
712 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
713 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
714 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
715 private void addFactObjectEqualsNode(boolean isTrue, ObjectEqualsNode equals, GuardingNode anchor) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
716 if (isDependencyTainted(equals.getX(), anchor)) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
717 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
718 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
719 if (isDependencyTainted(equals.getY(), anchor)) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
720 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
721 } |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
722 assert anchor instanceof FixedNode; |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
723 ValueNode x = GraphUtil.unproxify(equals.getX()); |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
724 ValueNode y = GraphUtil.unproxify(equals.getY()); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
725 if (isTrue) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
726 if (isNull(x) && isNonNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
727 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
728 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
729 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
730 if (isNonNull(x) && isNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
731 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
732 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
733 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
734 if (isNull(x) || isNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
735 metricObjectEqualsRegistered.increment(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
736 addNullness(true, equals.getX(), anchor); |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
737 addNullness(true, equals.getY(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
738 } else if (isNonNull(x) || isNonNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
739 metricObjectEqualsRegistered.increment(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
740 addNullness(false, equals.getX(), anchor); |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
741 addNullness(false, equals.getY(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
742 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
743 Witness wx = typeInfo(x); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
744 Witness wy = typeInfo(y); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
745 if (wx == null && wy == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
746 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
747 } else if (wx != null && wy != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
748 // tighten their type-hints, provided at least one available |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
749 // both witnesses may have seen == null, ie they may be NN witnesses |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
750 ResolvedJavaType best = FlowUtil.tighten(wx.type(), wy.type()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
751 if (best != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
752 assert !best.isInterface(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
753 // type tightening is enough, nullness already taken care of |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
754 trackCC(equals.getX(), best, anchor); |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
755 trackCC(equals.getY(), best, anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
756 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
757 } else if (wx == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
758 typeRefinements.put(x, new Witness(wy)); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
759 } else if (wy == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
760 typeRefinements.put(y, new Witness(wx)); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
761 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
762 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
763 if (isNull(x) && !isNonNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
764 metricObjectEqualsRegistered.increment(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
765 addNullness(false, equals.getY(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
766 } else if (!isNonNull(x) && isNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
767 metricObjectEqualsRegistered.increment(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
768 addNullness(false, equals.getX(), anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
769 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
770 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
771 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
772 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
773 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
774 * Adds information about the nullness of a value. If isNull is true then the value is known to |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
775 * be null, otherwise the value is known to be non-null. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
776 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
777 public void addNullness(boolean isNull, ValueNode value, GuardingNode anchor) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
778 if (isDependencyTainted(value, anchor)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
779 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
780 } |
15425
a92ff90899b6
[flow-sensitive] explicit assert about anchor being FixedNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15405
diff
changeset
|
781 assert anchor instanceof FixedNode; |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
782 ValueNode scrutinee = GraphUtil.unproxify(value); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
783 boolean wasNull = isNull(scrutinee); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
784 boolean wasNonNull = isNonNull(scrutinee); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
785 if (isNull) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
786 if (wasNonNull) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
787 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
788 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
789 metricNullnessRegistered.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
790 versionNr++; |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
791 Witness w = getOrElseAddTypeInfo(scrutinee); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
792 w.trackDN(anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
793 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
794 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
795 if (wasNull) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
796 impossiblePath(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
797 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
798 metricNullnessRegistered.increment(); |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
799 trackNN(scrutinee, anchor); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
800 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
801 } |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
802 assert repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
803 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
804 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
805 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
806 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
807 * @return true iff `value` may lose dependency not covered by `anchor`. |
15404
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
808 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
809 public static boolean isDependencyTainted(ValueNode value, GuardingNode anchor) { |
15426
e9029a026dc9
[flow-sensitive] bug fixes, missing state clearing
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15425
diff
changeset
|
810 assert anchor instanceof FixedNode; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
811 if (value instanceof ValueProxy) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
812 if (value instanceof GuardedNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
813 GuardedNode gn = (GuardedNode) value; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
814 GuardingNode guardian = gn.getGuard(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
815 if (guardian != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
816 boolean isGuardedByFixed = guardian instanceof FixedNode; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
817 if (!isGuardedByFixed) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
818 return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
819 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
820 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
821 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
822 // if (value instanceof GuardingNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
823 // return true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
824 // } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
825 ValueProxy proxy = (ValueProxy) value; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
826 return isDependencyTainted(proxy.getOriginalNode(), anchor); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
827 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
828 return false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
829 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
830 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
831 public void clear() { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
832 versionNr = 0; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
833 isUnreachable = false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
834 typeRefinements.clear(); |
15426
e9029a026dc9
[flow-sensitive] bug fixes, missing state clearing
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15425
diff
changeset
|
835 trueFacts.clear(); |
e9029a026dc9
[flow-sensitive] bug fixes, missing state clearing
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15425
diff
changeset
|
836 falseFacts.clear(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
837 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
838 |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
839 /** |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
840 * <p> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
841 * If the argument is known null due to its stamp, there's no need to have an anchor for that |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
842 * fact and this method returns null. |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
843 * </p> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
844 * |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
845 * <p> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
846 * Otherwise, if an anchor is found it is returned, null otherwise. |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
847 * </p> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
848 */ |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
849 public GuardingNode nonTrivialNullAnchor(ValueNode object) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
850 assert FlowUtil.hasLegalObjectStamp(object); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
851 if (StampTool.isObjectAlwaysNull(object)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
852 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
853 } |
15563
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
854 ValueNode scrutinee = GraphUtil.unproxify(object); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
855 Witness w = typeRefinements.get(scrutinee); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
856 if (w != null && w.isNull()) { |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
857 return w.guard(); |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
858 } |
5699bb48a436
[flow-sensitive] consolidating nullness-tracking in typeRefinements
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15551
diff
changeset
|
859 return null; |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
860 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
861 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
862 /** |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
863 * This method: |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
864 * <ul> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
865 * <li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
866 * attempts to find an existing {@link com.oracle.graal.nodes.extended.GuardingNode} that |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
867 * implies the property stated by the arguments. If found, returns it as positive evidence.</li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
868 * <li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
869 * otherwise, if the property of interest is known not to hold, negative evidence is returned.</li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
870 * <li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
871 * otherwise, null is returned.</li> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
872 * </ul> |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
873 */ |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
874 public Evidence outcome(boolean isTrue, LogicNode cond) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
875 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
876 // attempt to find an anchor for the condition of interest, verbatim |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
877 if (isTrue) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
878 GuardingNode existingGuard = trueFacts.get(cond); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
879 if (existingGuard != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
880 return new Evidence(existingGuard); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
881 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
882 if (falseFacts.containsKey(cond)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
883 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
884 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
885 } else { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
886 GuardingNode existingGuard = falseFacts.get(cond); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
887 if (existingGuard != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
888 return new Evidence(existingGuard); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
889 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
890 if (trueFacts.containsKey(cond)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
891 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
892 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
893 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
894 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
895 if (cond instanceof IsNullNode) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
896 return outcomeIsNullNode(isTrue, (IsNullNode) cond); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
897 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
898 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
899 if (cond instanceof InstanceOfNode) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
900 return outcomeInstanceOfNode(isTrue, (InstanceOfNode) cond); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
901 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
902 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
903 if (cond instanceof ShortCircuitOrNode) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
904 return outcomeShortCircuitOrNode(isTrue, (ShortCircuitOrNode) cond); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
905 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
906 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
907 // can't produce evidence |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
908 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
909 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
910 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
911 /** |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
912 * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}. |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
913 */ |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
914 private Evidence outcomeIsNullNode(boolean isTrue, IsNullNode isNullNode) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
915 if (isTrue) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
916 // grab an anchor attesting nullness |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
917 final GuardingNode replacement = nonTrivialNullAnchor(isNullNode.getValue()); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
918 if (replacement != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
919 return new Evidence(replacement); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
920 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
921 if (isNonNull(isNullNode.getValue())) { |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
922 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
923 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
924 } else { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
925 // grab an anchor attesting non-nullness |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
926 final Witness w = typeInfo(isNullNode.getValue()); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
927 if (w != null && w.isNonNull()) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
928 return new Evidence(w.guard()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
929 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
930 if (isNull(isNullNode.getValue())) { |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
931 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
932 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
933 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
934 // can't produce evidence |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
935 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
936 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
937 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
938 /** |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
939 * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}. |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
940 */ |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
941 private Evidence outcomeInstanceOfNode(boolean isTrue, InstanceOfNode iOf) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
942 final Witness w = typeInfo(iOf.getValue()); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
943 if (isTrue) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
944 if (isNull(iOf.getValue())) { |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
945 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
946 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
947 // grab an anchor attesting instanceof |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
948 if ((w != null) && (w.type() != null)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
949 if (w.isNonNull()) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
950 if (iOf.type().isAssignableFrom(w.type())) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
951 return new Evidence(w.guard()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
952 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
953 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
954 if (State.knownNotToConform(w.type(), iOf.type())) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
955 // null -> fails instanceof |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
956 // non-null but non-conformant -> also fails instanceof |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
957 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
958 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
959 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
960 } else { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
961 // grab an anchor attesting not-instanceof |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
962 // (1 of 2) attempt determining nullness |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15754
diff
changeset
|
963 final GuardingNode nullGuard = nonTrivialNullAnchor(iOf.getValue()); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
964 if (nullGuard != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
965 return new Evidence(nullGuard); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
966 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
967 // (2 of 2) attempt determining known-not-to-conform |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
968 if (w != null && !w.cluelessAboutType()) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
969 if (State.knownNotToConform(w.type(), iOf.type())) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
970 return new Evidence(w.guard()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
971 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
972 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
973 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
974 // can't produce evidence |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
975 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
976 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
977 |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
978 /** |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16220
diff
changeset
|
979 * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}. |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
980 */ |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
981 private Evidence outcomeShortCircuitOrNode(boolean isTrue, ShortCircuitOrNode orNode) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
982 if (!isTrue) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
983 // too tricky to reason about |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
984 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
985 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
986 CastCheckExtractor cce = CastCheckExtractor.extract(orNode); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
987 if (cce != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
988 // grab an anchor attesting check-cast |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
989 Witness w = typeInfo(cce.subject); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
990 if (w != null && w.type() != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
991 if (cce.type.isAssignableFrom(w.type())) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
992 return new Evidence(w.guard()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
993 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
994 if (isNonNull(cce.subject) && State.knownNotToConform(w.type(), cce.type)) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
995 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
996 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
997 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
998 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
999 // search for positive-evidence for the first or-input |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1000 Evidence evidenceX = outcome(!orNode.isXNegated(), orNode.getX()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1001 if (evidenceX != null && evidenceX.isPositive()) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1002 return evidenceX; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1003 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1004 // search for positive-evidence for the second or-input |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1005 Evidence evidenceY = outcome(!orNode.isYNegated(), orNode.getY()); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1006 if (evidenceY != null && evidenceY.isPositive()) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1007 return evidenceY; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1008 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1009 // check for contradictions on both or-inputs |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1010 if (evidenceX != null && evidenceY != null) { |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1011 assert evidenceX.isNegative() && evidenceY.isNegative(); |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1012 return Evidence.COUNTEREXAMPLE; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1013 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1014 // can't produce evidence |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1015 return null; |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1016 } |
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15491
diff
changeset
|
1017 |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
1018 } |