Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java @ 16841:cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 11:34:38 +0200 |
parents | de84713267fa |
children | 06c15e88d383 |
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:
15517
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:
15517
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:
15517
diff
changeset
|
27 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:
15517
diff
changeset
|
28 |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15517
diff
changeset
|
29 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:
15517
diff
changeset
|
30 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:
15517
diff
changeset
|
31 import com.oracle.graal.debug.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15517
diff
changeset
|
32 import com.oracle.graal.graph.*; |
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15517
diff
changeset
|
33 import com.oracle.graal.graph.spi.*; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
34 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:
15517
diff
changeset
|
35 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:
15517
diff
changeset
|
36 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:
15517
diff
changeset
|
37 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:
15517
diff
changeset
|
38 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:
15517
diff
changeset
|
39 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:
15517
diff
changeset
|
40 import com.oracle.graal.nodes.util.*; |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
44 * This class implements a simple partial evaluator that recursively reduces a given |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
45 * {@link com.oracle.graal.nodes.calc.FloatingNode} into a simpler one based on the current state. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
46 * Such evaluator comes handy when visiting a {@link com.oracle.graal.nodes.FixedNode} N, just |
15431
746c0bda7ba6
[flow-sensitive] formatting
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15429
diff
changeset
|
47 * before updating the state for N. At the pre-state, an {@link EquationalReasoner} can be used to |
746c0bda7ba6
[flow-sensitive] formatting
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15429
diff
changeset
|
48 * reduce N's inputs (actually only those inputs of Value and Condition |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
49 * {@link com.oracle.graal.nodeinfo.InputType InputType}). For an explanation of where it's |
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
50 * warranted to replace "old input" with "reduced input", see the inline comments in method |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
51 * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node n) deverbosify(Node n)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
52 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
53 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
54 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
55 * The name {@link EquationalReasoner EquationalReasoner} was chosen because it conveys what it |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
56 * does. |
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 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
59 public final class EquationalReasoner { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
60 |
15498
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
61 private static final DebugMetric metricInstanceOfRemoved = Debug.metric("FSR-InstanceOfRemoved"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
62 private static final DebugMetric metricNullCheckRemoved = Debug.metric("FSR-NullCheckRemoved"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
63 private static final DebugMetric metricObjectEqualsRemoved = Debug.metric("FSR-ObjectEqualsRemoved"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
64 private static final DebugMetric metricEquationalReasoning = Debug.metric("FSR-EquationalReasoning"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
65 private static final DebugMetric metricDowncasting = Debug.metric("FSR-Downcasting"); |
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
66 private static final DebugMetric metricNullInserted = Debug.metric("FSR-NullInserted"); |
15388
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 private final StructuredGraph graph; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
69 private final CanonicalizerTool tool; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
70 private final LogicConstantNode trueConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
71 private final LogicConstantNode falseConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
72 private final ConstantNode nullConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
73 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
74 private State state; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
75 private NodeBitMap visited; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
76 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
77 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
78 * The reduction of a {@link com.oracle.graal.nodes.calc.FloatingNode} performed by |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
79 * {@link EquationalReasoner EquationalReasoner} may result in a FloatingNode being added to the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
80 * graph. Those nodes aren't tracked in the {@link EquationalReasoner#visited visited} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
81 * {@link com.oracle.graal.graph.NodeBitMap NodeBitMap} but in this set instead (those nodes are |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
82 * added after the {@link com.oracle.graal.graph.NodeBitMap} was obtained). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
83 */ |
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:
15517
diff
changeset
|
84 final Set<ValueNode> added = newNodeIdentitySet(); |
15388
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 * The reduction of a FloatingNode performed by {@link EquationalReasoner EquationalReasoner} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
88 * may result in a FloatingNode being added to the graph. Those nodes are tracked in this map, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
89 * to avoid recomputing them. |
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 * The substitutions tracked in this field become invalid as described in |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
92 * {@link #updateState(com.oracle.graal.phases.common.cfs.State) updateState(State)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
93 */ |
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:
15517
diff
changeset
|
94 private final Map<ValueNode, ValueNode> substs = newNodeIdentityMap(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
95 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
96 public EquationalReasoner(StructuredGraph graph, CanonicalizerTool tool, LogicConstantNode trueConstant, LogicConstantNode falseConstant, ConstantNode nullConstant) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
97 this.graph = graph; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
98 this.tool = tool; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
99 this.trueConstant = trueConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
100 this.falseConstant = falseConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
101 this.nullConstant = nullConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
102 } |
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 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
105 * {@link #added} grows during a run of |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
106 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
107 * FlowSensitiveReductionPhase}, and doesn't survive across runs. |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
108 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
109 public void forceState(State s) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
110 state = s; |
15499
229537218983
[flow-sensitive] internal consistency asserts, state tracking
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15498
diff
changeset
|
111 assert state.repOK(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
112 substs.clear(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
113 added.clear(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
114 visited = null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
115 versionNrAsofLastForce = s.versionNr; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
116 } |
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 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
119 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
120 * Gaining more precise type information about an SSA value doesn't "invalidate" as such any of |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
121 * the substitutions tracked in {@link EquationalReasoner#substs substs}, at least not in the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
122 * sense of making the value tracked by one such entry "wrong". However, clearing the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
123 * {@link EquationalReasoner#substs substs} is still justified because next time they are |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
124 * computed, the newly computed reduction could (in principle) be more effective (due to the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
125 * more precise type information). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
126 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
127 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
128 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
129 * Between clearings of cached substitutions, it is expected they get applied a number of times |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
130 * to justify the bookkeeping cost. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
131 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
132 * |
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 public void updateState(State s) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
135 assert s != null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
136 if (state == null || state != s || state.versionNr != versionNrAsofLastForce) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
137 forceState(s); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
138 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
139 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
140 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
141 private int versionNrAsofLastForce = 0; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
142 |
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 * Reduce the argument based on the state at the program point where the argument is consumed. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
145 * For most FixedNodes, that's how their inputs can be reduced. Two exceptions: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
146 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
147 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
148 * the condition of a {@link com.oracle.graal.nodes.GuardingPiNode}, see |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
149 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
150 * </li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
151 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
152 * the condition of a {@link com.oracle.graal.nodes.FixedGuardNode}, see |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
153 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitFixedGuardNode(com.oracle.graal.nodes.FixedGuardNode)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
154 * </li> |
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 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
157 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
158 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
159 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
160 * Part of the reduction work is delegated to baseCase-style reducers, whose contract explicitly |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
161 * requires them not to deverbosify the argument's inputs --- the decision is made based on the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
162 * argument only (thus "base case"). Returning the unmodified argument is how a baseCase-style |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
163 * tells this method to fall to the default case (for a floating node only: walk into the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
164 * argument's inputs, canonicalize followed by |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
165 * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
166 * rememberSubstitution()} if any input changed). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
167 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
168 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
169 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
170 * This method must behave as a function (idempotent query method), ie refrain from mutating the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
171 * state other than updating caches: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
172 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
173 * <li>{@link EquationalReasoner#added EquationalReasoner#added},</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
174 * <li>{@link EquationalReasoner#visited EquationalReasoner#visited} and</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
175 * <li>the cache updated via |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
176 * {@link EquationalReasoner#rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
177 * EquationalReasoner#rememberSubstitution(ValueNode, FloatingNode)}.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
178 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
179 * </p> |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
182 * In turn, baseCase-style reducers are even more constrained: besides behaving as functions, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
183 * their contract prevents them from updating any caches (basically because they already grab |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
184 * the answer from caches, if the answer isn't there they should just return their unmodified |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
185 * argument). |
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 * This method returns: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
190 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
191 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
192 * the original argument, in case no reduction possible.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
193 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
194 * a {@link com.oracle.graal.nodes.ValueNode ValueNode} different from the argument, in case the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
195 * conditions for a reduction were met. The node being returned might be already in the graph. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
196 * In any case it's canonicalized already, the caller need not perform that again.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
197 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
198 * the unmodified argument, in case no reduction was made. Otherwise, a maximally reduced |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
199 * {@link com.oracle.graal.nodes.ValueNode}.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
200 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
201 * </p> |
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 * @see com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#deverbosifyInputsInPlace(com.oracle.graal.nodes.ValueNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
204 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
205 * @see com.oracle.graal.phases.common.cfs.BaseReduction.Tool |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
206 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
207 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
208 public Node deverbosify(final Node n) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
209 |
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 // cases that don't initiate any call-chain that may enter this method |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
212 // -------------------------------------------------------------------- |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
213 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
214 if (n == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
215 return null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
216 } |
15483
01a8820c1228
[flow-sensitive] minor refactorings for readability, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15441
diff
changeset
|
217 assert !(n instanceof GuardNode) : "This phase not intended to run during MidTier"; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
218 if (!(n instanceof ValueNode)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
219 return n; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
220 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
221 ValueNode v = (ValueNode) n; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
222 if (v.stamp() instanceof IllegalStamp) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
223 return v; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
224 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
225 if (FlowUtil.isLiteralNode(v)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
226 return v; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
227 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
228 ValueNode result = substs.get(v); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
229 if (result != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
230 // picked cached substitution |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
231 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
232 } |
15517
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
233 if (FlowUtil.hasLegalObjectStamp(v) && state.isNull(v)) { |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
234 // it's ok to return nullConstant in deverbosify unlike in downcast |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
235 metricNullInserted.increment(); |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
236 return nullConstant; |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
237 } |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
238 if (v instanceof ValueProxy) { |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
239 return v; |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
240 } |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
241 if (!(n instanceof FloatingNode)) { |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
242 return n; |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
243 } |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
244 if ((visited != null && visited.contains(n)) || added.contains(v)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
245 return v; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
246 } |
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 // -------------------------------------------------------------------- |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
249 // stack overflow prevention via added, visited |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
250 // -------------------------------------------------------------------- |
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 if (visited == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
253 visited = graph.createNodeBitMap(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
254 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
255 visited.mark(n); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
256 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
257 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
258 * Past this point, if we ever want `n` to be deverbosified, it must be looked-up by one of |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
259 * the cases above. One sure way to achieve that is with `rememberSubstitution(old, new)` |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
260 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
261 |
15517
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
262 /* |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
263 * `deverbosifyFloatingNode()` will drill down over floating inputs, when that not possible |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
264 * anymore it resorts to calling `downcast()`. Thus it's ok to take the |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
265 * `deverbosifyFloatingNode()` route first, as no downcasting opportunity will be missed. |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
266 */ |
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
267 return deverbosifyFloatingNode((FloatingNode) n); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
268 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
269 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
270 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
271 * This method: |
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 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
274 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
275 * Recurses only over floating inputs to attempt reductions, leave anything else as is.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
276 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
277 * Performs copy-on-write aka lazy-DAG-copying as described in source comments, in-line.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
278 * <li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
279 * Usage: must be called only from {@link #deverbosify(com.oracle.graal.graph.Node) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
280 * deverbosify(Node)}.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
281 * </ul> |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
282 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
283 public Node deverbosifyFloatingNode(final FloatingNode n) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
284 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
285 assert n != null : "Should have been caught in deverbosify()"; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
286 assert !(n instanceof ValueProxy) : "Should have been caught in deverbosify()"; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
287 assert !FlowUtil.isLiteralNode(n) : "Should have been caught in deverbosify()"; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
288 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
289 if (n instanceof PhiNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
290 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
291 * Each input to a PhiNode should be deverbosified with the state applicable to the path |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
292 * providing such input, as done in visitAbstractEndNode() |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
293 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
294 return n; |
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 final FloatingNode f = baseCaseFloating(n); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
298 if (f != n) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
299 return f; |
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
302 FloatingNode changed = null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
303 for (ValueNode i : FlowUtil.distinctValueAndConditionInputs(f)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
304 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
305 * Although deverbosify() is invoked below, it's only for floating inputs. That way, the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
306 * state can't be used to make invalid conclusions. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
307 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
308 Node j = (i instanceof FloatingNode) ? deverbosify(i) : i; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
309 if (i != j) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
310 assert j != f; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
311 if (changed == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
312 changed = (FloatingNode) f.copyWithInputs(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
313 added.add(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
314 // copyWithInputs() implies graph.unique(changed) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
315 assert changed.isAlive(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
316 assert FlowUtil.lacksUsages(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
317 } |
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 * Note: we don't trade i for j at each usage of i (doing so would change meaning) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
320 * but only at those usages consumed by `changed`. In turn, `changed` won't replace |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
321 * `n` at arbitrary usages, but only where such substitution is valid as per the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
322 * state holding there. In practice, this means the buck stops at the "root" |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
323 * FixedNode on whose inputs deverbosify() is invoked for the first time, via |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
324 * deverbosifyInputsInPlace(). |
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 FlowUtil.replaceInPlace(changed, i, j); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
327 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
328 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
329 if (changed == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
330 assert visited.contains(f) || added.contains(f); |
15517
4f603d776ecc
[flow-sensitive] too many type-refinements didn't improve performance
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15516
diff
changeset
|
331 return f; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
332 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
333 FlowUtil.inferStampAndCheck(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
334 added.add(changed); |
16206
2a1f3a8f76f1
handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
335 |
16239
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
336 if (changed instanceof Canonicalizable) { |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
337 ValueNode canon = (ValueNode) ((Canonicalizable) changed).canonical(tool); |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
338 if (canon != null && !canon.isAlive()) { |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
339 assert !canon.isDeleted(); |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
340 canon = graph.addOrUniqueWithInputs(canon); |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
341 } |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
342 // might be already in `added`, no problem adding it again. |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
343 added.add(canon); |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
344 rememberSubstitution(f, canon); |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
345 return canon; |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
346 } else { |
de84713267fa
use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
347 return changed; |
16206
2a1f3a8f76f1
handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
348 } |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
349 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
350 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
351 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
352 * In case of doubt (on whether a reduction actually triggered) it's always ok to invoke " |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
353 * <code>rememberSubstitution(f, downcast(f))</code>": this method records a map entry only if |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
354 * pre-image and image differ. |
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 * @return the image of the substitution (ie, the second argument) unmodified. |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
357 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
358 private <M extends ValueNode> M rememberSubstitution(ValueNode from, M to) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
359 assert from != null && to != null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
360 if (from == to) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
361 return to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
362 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
363 // we don't track literals because they map to themselves |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
364 if (FlowUtil.isLiteralNode(from)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
365 assert from == to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
366 return to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
367 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
368 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
369 * It's ok for different keys (which were not unique in the graph after all) to map to the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
370 * same value. However any given key can't map to different values. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
371 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
372 ValueNode image = substs.get(from); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
373 if (image != null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
374 assert image == to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
375 return to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
376 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
377 substs.put(from, to); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
378 return to; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
379 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
380 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
381 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
382 * The contract for this baseCase-style method is covered in |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
383 * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
384 * EquationalReasoner#deverbosify()} |
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 * @return a {@link com.oracle.graal.nodes.calc.FloatingNode} different from the argument, in |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
387 * case a reduction was made. The node being returned might be already in the graph. In |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
388 * any case it's canonicalized already, the caller need not perform that again. In case |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
389 * no reduction was made, this method returns the unmodified argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
390 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
391 private FloatingNode baseCaseFloating(final FloatingNode f) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
392 if (f instanceof LogicNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
393 FloatingNode result = baseCaseLogicNode((LogicNode) f); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
394 return rememberSubstitution(f, result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
395 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
396 return f; |
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
399 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
400 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
401 * Reduce the argument based on the state at the program point for it (ie, based on |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
402 * "valid facts" only, without relying on any floating-guard-assumption). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
403 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
404 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
405 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
406 * The inputs of the argument aren't traversed into, for that |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
407 * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
408 * EquationalReasoner#deverbosify()} should be used instead. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
409 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
410 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
411 * This method must behave as a function (idempotent query method): it should refrain from |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
412 * changing the state, as well as from updating caches (other than DebugMetric-s). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
413 * </p> |
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 * @return a {@link com.oracle.graal.nodes.LogicNode} different from the argument, in case a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
416 * reduction was made. The node being returned might be already in the graph. In any |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
417 * case it's canonicalized already, the caller need not perform that again. In case no |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
418 * reduction was made, this method returns the unmodified argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
419 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
420 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
421 public FloatingNode baseCaseLogicNode(LogicNode condition) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
422 assert condition != null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
423 if (condition instanceof LogicConstantNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
424 return condition; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
425 } else if (state.trueFacts.containsKey(condition)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
426 metricEquationalReasoning.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
427 return trueConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
428 } else if (state.falseFacts.containsKey(condition)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
429 metricEquationalReasoning.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
430 return falseConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
431 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
432 if (condition instanceof InstanceOfNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
433 return baseCaseInstanceOfNode((InstanceOfNode) condition); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
434 } else if (condition instanceof IsNullNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
435 return baseCaseIsNullNode((IsNullNode) condition); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
436 } else if (condition instanceof ObjectEqualsNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
437 return baseCaseObjectEqualsNode((ObjectEqualsNode) condition); |
15491
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
438 } else if (condition instanceof ShortCircuitOrNode) { |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
439 return baseCaseShortCircuitOrNode((ShortCircuitOrNode) condition); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
440 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
441 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
442 return condition; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
443 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
444 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
445 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
446 * Actually the same result delivered by this method could be obtained by just letting |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
447 * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
448 * EquationalReasoner#deverbosify()} handle the argument in the default case for floating nodes |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
449 * (ie, deverbosify inputs followed by canonicalize). However it's done here for metrics |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
450 * purposes. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
451 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
452 * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
453 * otherwise the unmodified argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
454 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
455 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
456 private LogicNode baseCaseInstanceOfNode(InstanceOfNode instanceOf) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16206
diff
changeset
|
457 ValueNode scrutinee = GraphUtil.unproxify(instanceOf.getValue()); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
458 if (!FlowUtil.hasLegalObjectStamp(scrutinee)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
459 return instanceOf; |
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 if (state.isNull(scrutinee)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
462 metricInstanceOfRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
463 return falseConstant; |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
464 } else if (state.knownNotToPassInstanceOf(scrutinee, instanceOf.type())) { |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
465 // scrutinee turns out to be null -> falseConstant right answer |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
466 // scrutinee not null, but known-not-to-conform -> falseConstant |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
467 metricInstanceOfRemoved.increment(); |
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
468 return falseConstant; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
469 } else if (state.isNonNull(scrutinee) && state.knownToConform(scrutinee, instanceOf.type())) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
470 metricInstanceOfRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
471 return trueConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
472 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
473 return instanceOf; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
474 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
475 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
476 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
477 * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
478 * performed; otherwise the unmodified argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
479 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
480 */ |
15516
8653634b9d11
[flow-sensitive] readability, baseCaseIsNullNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15515
diff
changeset
|
481 private FloatingNode baseCaseIsNullNode(IsNullNode isNu) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16206
diff
changeset
|
482 ValueNode object = isNu.getValue(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
483 if (!FlowUtil.hasLegalObjectStamp(object)) { |
15516
8653634b9d11
[flow-sensitive] readability, baseCaseIsNullNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15515
diff
changeset
|
484 return isNu; |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
485 } |
15516
8653634b9d11
[flow-sensitive] readability, baseCaseIsNullNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15515
diff
changeset
|
486 if (state.isNull(object)) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
487 metricNullCheckRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
488 return trueConstant; |
15516
8653634b9d11
[flow-sensitive] readability, baseCaseIsNullNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15515
diff
changeset
|
489 } else if (state.isNonNull(object)) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
490 metricNullCheckRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
491 return falseConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
492 } |
15516
8653634b9d11
[flow-sensitive] readability, baseCaseIsNullNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15515
diff
changeset
|
493 return isNu; |
15388
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
496 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
497 * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
498 * otherwise the unmodified argument. |
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 private LogicNode baseCaseObjectEqualsNode(ObjectEqualsNode equals) { |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16206
diff
changeset
|
501 if (!FlowUtil.hasLegalObjectStamp(equals.getX()) || !FlowUtil.hasLegalObjectStamp(equals.getY())) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
502 return equals; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
503 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16206
diff
changeset
|
504 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:
16206
diff
changeset
|
505 ValueNode y = GraphUtil.unproxify(equals.getY()); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
506 if (state.isNull(x) && state.isNonNull(y) || state.isNonNull(x) && state.isNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
507 metricObjectEqualsRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
508 return falseConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
509 } else if (state.isNull(x) && state.isNull(y)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
510 metricObjectEqualsRemoved.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
511 return trueConstant; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
512 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
513 return equals; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
514 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
515 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
516 /** |
15491
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
517 * The following is tried: |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
518 * |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
519 * <ol> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
520 * <li> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
521 * A {@link com.oracle.graal.phases.common.cfs.Witness} that is at check-cast level level |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
522 * doesn't entail {@link com.oracle.graal.nodes.calc.IsNullNode} (on its own) nor |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
523 * {@link com.oracle.graal.nodes.java.InstanceOfNode} (also on its own) but of course it entails |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
524 * <code>(IsNull || IsInstanceOf)</code>. Good thing |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
525 * {@link com.oracle.graal.phases.common.cfs.CastCheckExtractor} detects that very pattern.</li> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
526 * <li> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
527 * Otherwise return the unmodified argument (later on, |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
528 * {@link #deverbosifyFloatingNode(com.oracle.graal.nodes.calc.FloatingNode)} will attempt to |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
529 * simplify the {@link com.oracle.graal.nodes.ShortCircuitOrNode}).</li> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
530 * </ol> |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
531 * |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
532 * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made; |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
533 * otherwise the unmodified argument. |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
534 */ |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
535 private LogicNode baseCaseShortCircuitOrNode(ShortCircuitOrNode orNode) { |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
536 CastCheckExtractor cast = CastCheckExtractor.extract(orNode); |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
537 if (cast != null) { |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
538 if (state.knownToConform(cast.subject, cast.type)) { |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
539 return trueConstant; |
15515
2eb6330e13a3
[flow-sensitive] fix in knownNotToConform
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15499
diff
changeset
|
540 } else if (state.knownNotToPassCheckCast(cast.subject, cast.type)) { |
15491
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
541 return falseConstant; |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
542 } |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
543 return orNode; |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
544 } |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
545 return orNode; |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
546 } |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
547 |
7f492a524ca7
[flow-sensitive] bug fix, simplify ShortCircuitOrNode when of check-cast form
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15483
diff
changeset
|
548 /** |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
549 * It's always ok to use "<code>downcast(object)</code>" instead of " <code>object</code>" |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
550 * because this method re-wraps the argument in a {@link com.oracle.graal.nodes.PiNode} only if |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
551 * the new stamp is strictly more refined than the original. |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
554 * This method does not |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
555 * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
556 * . |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
557 * </p> |
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 * @return One of: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
560 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
561 * <li>a {@link com.oracle.graal.nodes.PiNode} with more precise stamp than the input if |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
562 * the state warrants such downcasting</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
563 * <li>a {@link com.oracle.graal.nodes.java.CheckCastNode CheckCastNode} for the same |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
564 * scrutinee in question</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
565 * <li>the unmodified argument otherwise.</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
566 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
567 */ |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
568 ValueNode downcast(final ValueNode object) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
569 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
570 // ------------------------------------------------- |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
571 // actions based only on the stamp of the input node |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
572 // ------------------------------------------------- |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
573 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
574 if (!FlowUtil.hasLegalObjectStamp(object)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
575 return object; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
576 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
577 if (FlowUtil.isLiteralNode(object)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
578 return object; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
579 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
580 if (StampTool.isObjectAlwaysNull(object.stamp())) { |
15441
97e0f9ec5752
[flow-sensitive] downcast of per-stamp-null, one fewer PiNode
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15440
diff
changeset
|
581 return object; |
15388
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 |
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 // actions based on the stamp and the witness |
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
588 ValueNode scrutinee = GraphUtil.unproxify(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
589 |
15429
edf0c031da76
[flow-sensitive] renaming: untrivialNull -> nonTrivialNull
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15428
diff
changeset
|
590 PiNode untrivialNull = nonTrivialNull(scrutinee); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
591 if (untrivialNull != null) { |
15498
e30d7eaa290d
[flow-sensitive] more metrics, documentation
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15493
diff
changeset
|
592 metricNullInserted.increment(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
593 return untrivialNull; |
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
596 Witness w = state.typeInfo(scrutinee); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
597 if (w == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
598 // no additional hints being tracked for the scrutinee |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
599 return object; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
600 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
601 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
602 assert !w.clueless(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
603 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
604 ObjectStamp inputStamp = (ObjectStamp) object.stamp(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
605 ObjectStamp witnessStamp = w.asStamp(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
606 if (inputStamp.equals(witnessStamp) || !FlowUtil.isMorePrecise(witnessStamp, inputStamp)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
607 // the witness offers no additional precision over current one |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
608 fixupTypeProfileStamp(object); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
609 return object; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
610 } |
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 assert !FlowUtil.isMorePrecise(inputStamp.type(), w.type()); |
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 ValueNode result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
615 if (object instanceof ValueProxy) { |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
616 result = downcastValueProxy((ValueProxy) object, w); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
617 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
618 result = downcastedUtil(object, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
619 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
620 |
15440
10274c654f75
[flow-sensitive] no-precision-loss check in downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15431
diff
changeset
|
621 assert !BaseReduction.precisionLoss(object, result); |
10274c654f75
[flow-sensitive] no-precision-loss check in downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15431
diff
changeset
|
622 |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
623 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
624 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
625 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
626 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
627 * TODO TypeProfileProxyNode.inferStamp doesn't infer non-null from non-null payload |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
628 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
629 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
630 * And there's a bunch of asserts in |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
631 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase} that assert no |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
632 * type-precision gets lost. Thus the need to fix-up on our own, as done here. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
633 * </p> |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
634 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
635 private static void fixupTypeProfileStamp(ValueNode object) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
636 if (!(object instanceof TypeProfileProxyNode)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
637 return; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
638 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
639 TypeProfileProxyNode profile = (TypeProfileProxyNode) object; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
640 ObjectStamp outgoinStamp = (ObjectStamp) profile.stamp(); |
16156
0993768dfc8e
new UnaryNode base class
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15551
diff
changeset
|
641 ObjectStamp payloadStamp = (ObjectStamp) profile.getValue().stamp(); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
642 if (payloadStamp.nonNull() && !outgoinStamp.nonNull()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
643 profile.setStamp(FlowUtil.asNonNullStamp(outgoinStamp)); |
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 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
646 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
647 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
648 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
649 * Porcelain method. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
650 * </p> |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
653 * Utility to create, add to the graph, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
654 * {@link EquationalReasoner#rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)} |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
655 * , and return a {@link com.oracle.graal.nodes.PiNode} that narrows into the given stamp, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
656 * anchoring the payload. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
657 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
658 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
659 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
660 * The resulting node might not have been in the graph already. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
661 * </p> |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
662 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
663 private PiNode wrapInPiNode(ValueNode payload, GuardingNode anchor, ObjectStamp newStamp, boolean remember) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
664 try (Debug.Scope s = Debug.scope("Downcast", payload)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
665 assert payload != anchor : payload.graph().toString(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
666 metricDowncasting.increment(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
667 PiNode result = graph.unique(new PiNode(payload, newStamp, anchor.asNode())); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
668 // we've possibly got a new node in the graph --- bookkeeping is in order. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
669 added.add(result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
670 if (remember) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
671 rememberSubstitution(payload, result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
672 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
673 Debug.log("Downcasting from %s to %s", payload, result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
674 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
675 } catch (Throwable e) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
676 throw Debug.handle(e); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
677 } |
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 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
680 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
681 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
682 * This method returns: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
683 * <ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
684 * <li><b>null</b>, if the argument is known null due to its stamp. Otherwise,</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
685 * <li><b>a PiNode</b> wrapping the null constant and an anchor offering evidence as to why the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
686 * argument is known null, if such anchor is available. Otherwise,</li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
687 * <li><b>null</b></li> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
688 * </ul> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
689 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
690 * This method does not |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
691 * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)} |
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 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
694 */ |
15429
edf0c031da76
[flow-sensitive] renaming: untrivialNull -> nonTrivialNull
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15428
diff
changeset
|
695 public PiNode nonTrivialNull(ValueNode object) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
696 assert FlowUtil.hasLegalObjectStamp(object); |
15493
49a917f9fa07
[flow-sensitive] refactoring, factor out evidence-search
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15492
diff
changeset
|
697 GuardingNode anchor = state.nonTrivialNullAnchor(object); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
698 if (anchor == null) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
699 return null; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
700 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
701 if (object instanceof GuardedNode && StampTool.isObjectAlwaysNull(object.stamp())) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
702 return (PiNode) object; |
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 // notice nullConstant is wrapped, not object |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
705 PiNode result = wrapInPiNode(nullConstant, anchor, (ObjectStamp) StampFactory.alwaysNull(), false); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
706 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
707 } |
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 // @formatter:off |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
710 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
711 * <p>ValueProxys can be classified along two dimensions, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
712 * in addition to the fixed-floating dichotomy.</p> |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
715 * First, we might be interested in separating those ValueProxys |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
716 * that are entitled to change (usually narrow) their stamp from those that aren't. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
717 * In the first category are: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
718 * PiNode, PiArrayNode, GuardingPiNode, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
719 * CheckCastNode, UnsafeCastNode, and |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
720 * GuardedValueNode. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
721 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
722 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
723 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
724 * A note on stamp-narrowing ValueProxys: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
725 * our state abstraction tracks only the type refinements induced by CheckCastNode and GuardingPiNode |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
726 * (which are fixed nodes, unlike the other stamp-narrowing ValueProxys; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
727 * the reason being that the state abstraction can be updated only at fixed nodes). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
728 * As a result, the witness for a (PiNode, PiArrayNode, UnsafeCastNode, or GuardedValueNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
729 * may be less precise than the proxy's stamp. We don't want to lose such precision, |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
730 * thus <code>downcast(proxy) == proxy</code> in such cases. |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
731 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
732 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
733 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
734 * The second classification focuses on |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
735 * the additional information that travels with the proxy |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
736 * (in addition to its "payload", ie getOriginalValue(), and any narrowing-stamp). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
737 * Such additional information boils down to: |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
738 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
739 * (a) type profile (TypeProfileProxyNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
740 * (b) type profile (CheckCastNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
741 * (c) anchor (GuardedValueNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
742 * (d) anchor (PiNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
743 * (e) anchor and array length (PiArrayNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
744 * (f) optional anchor (UnsafeCastNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
745 * (g) deopt-condition (GuardingPiNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
746 * (h) LocationIdentity (MemoryProxyNOde) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
747 * (i) control-flow dependency (FixedValueAnchorNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
748 * (j) proxyPoint (ProxyNode -- think loops) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
749 *</p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
750 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
751 // @formatter:on |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
752 private ValueNode downcastValueProxy(ValueProxy proxy, Witness w) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
753 assert FlowUtil.hasLegalObjectStamp((ValueNode) proxy); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
754 assert FlowUtil.hasLegalObjectStamp((proxy).getOriginalNode()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
755 assert GraphUtil.unproxify((ValueNode) proxy) == GraphUtil.unproxify(proxy.getOriginalNode()); |
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 assert GraphUtil.unproxify((ValueNode) proxy) == GraphUtil.unproxify((proxy).getOriginalNode()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
758 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
759 if (proxy instanceof PiNode) { |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
760 return downcastPiNodeOrPiArrayNode((PiNode) proxy, w); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
761 } else if (proxy instanceof GuardingPiNode) { |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
762 return downcastGuardingPiNode((GuardingPiNode) proxy, w); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
763 } else if (proxy instanceof TypeProfileProxyNode) { |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
764 return downcastTypeProfileProxyNode((TypeProfileProxyNode) proxy); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
765 } else if (proxy instanceof CheckCastNode) { |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
766 return downcastCheckCastNode((CheckCastNode) proxy, w); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
767 } else if (proxy instanceof ProxyNode || proxy instanceof GuardedValueNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
768 // TODO scaladacapo return downcastedUtil((ValueNode) proxy, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
769 return (ValueNode) proxy; |
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 assert false : "TODO case not yet handled"; |
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 // TODO complete the missing implementation for the cases not yet handled |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
775 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
776 return ((ValueNode) proxy); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
777 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
778 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
779 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
780 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
781 * Why would we want to downcast a GuardingPiNode? Is it even possible? Like, for example, a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
782 * GuardingPiNode originating in the lowering of a CheckCastNode (carried out by |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
783 * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
784 * visitCheckCastNode()}). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
785 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
786 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
787 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
788 * It's both possible and desirable. Example: <code> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
789 * Number n = (Number) o; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
790 * if (n instanceof Integer) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
791 * return n.intValue(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
792 * } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
793 * </code> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
794 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
795 * The receiver of intValue() is a usage of a previous checkCast, for which the current witness |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
796 * provides a more refined type (and an anchor). In this case, the advantage of downcasting a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
797 * GuardingPiNode is clear: devirtualizing the `intValue()` callsite. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
798 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
799 * |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
800 * @see #downcastValueProxy |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
801 */ |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
802 public ValueNode downcastGuardingPiNode(GuardingPiNode envelope, Witness w) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
803 assert envelope != w.guard().asNode() : "The stamp of " + envelope + " would lead to downcasting with that very same GuardingPiNode as guard."; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
804 return downcastedUtil(envelope, w); |
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 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
808 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
809 * This method accepts both {@link com.oracle.graal.nodes.PiNode} and |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
810 * {@link com.oracle.graal.nodes.PiArrayNode} argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
811 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
812 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
813 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
814 * In case a witness reveals a strictly more precise type than the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
815 * {@link com.oracle.graal.nodes.PiNode}'s stamp, this method wraps the argument in a new |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
816 * {@link com.oracle.graal.nodes.PiNode} with updated stamp, and returns it. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
817 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
818 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
819 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
820 * A {@link com.oracle.graal.nodes.PiArrayNode} argument ends up wrapped in a |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
821 * {@link com.oracle.graal.nodes.PiNode}. Thus, the |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
822 * {@link com.oracle.graal.nodes.PiArrayNode#length} information doesn't get lost. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
823 * </p> |
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 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
826 * Note: {@link com.oracle.graal.nodes.PiNode}'s semantics allow un-packing its payload as soon |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
827 * as it type conforms to that of the {@link com.oracle.graal.nodes.PiNode} (that's what |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
828 * {@link com.oracle.graal.nodes.PiNode#canonical(com.oracle.graal.graph.spi.CanonicalizerTool) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
829 * PiNode.canonical()} does). Not clear the benefits of duplicating that logic here. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
830 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
831 * |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
832 * @see #downcastValueProxy |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
833 */ |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
834 private ValueNode downcastPiNodeOrPiArrayNode(PiNode envelope, Witness w) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
835 return downcastedUtil(envelope, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
836 } |
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 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
839 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
840 * In a case the payload of the {@link com.oracle.graal.nodes.TypeProfileProxyNode} can be |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
841 * downcasted, this method returns a copy-on-write version with the downcasted payload. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
842 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
843 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
844 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
845 * Otherwise returns the unmodified argument. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
846 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
847 * |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
848 * @see #downcastValueProxy |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
849 */ |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
850 private ValueNode downcastTypeProfileProxyNode(TypeProfileProxyNode envelope) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
851 ValueNode payload = envelope.getOriginalNode(); |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
852 ValueNode d = downcast(payload); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
853 if (payload != d) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
854 TypeProfileProxyNode changed = (TypeProfileProxyNode) envelope.copyWithInputs(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
855 added.add(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
856 // copyWithInputs() implies graph.unique(changed) |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
857 FlowUtil.replaceInPlace(changed, payload, d); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
858 FlowUtil.inferStampAndCheck(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
859 fixupTypeProfileStamp(changed); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
860 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
861 * It's not prudent to (1) obtain the canonical() of the (changed) TypeProfileProxyNode |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
862 * to (2) replace its usages; because we're potentially walking a DAG (after all, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
863 * TypeProfileProxyNode is a floating-node). Those steps, which admittedly are needed, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
864 * are better performed upon replacing in-place the inputs of a FixedNode, or during |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
865 * Canonicalize. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
866 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
867 return changed; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
868 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
869 fixupTypeProfileStamp(envelope); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
870 return envelope; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
871 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
872 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
873 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
874 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
875 * Re-wrap the checkCast in a type-refining {@link com.oracle.graal.nodes.PiNode PiNode} only if |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
876 * the downcasted scrutinee does not conform to the checkCast's target-type. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
877 * </p> |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
878 */ |
15428
bdb517afe524
[flow-sensitive] renaming: downcast-helpers
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15427
diff
changeset
|
879 private ValueNode downcastCheckCastNode(CheckCastNode checkCast, Witness w) { |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
880 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
881 final ResolvedJavaType toType = checkCast.type(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
882 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
883 if (checkCast.object() instanceof CheckCastNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
884 ValueNode innerMost = checkCast; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
885 while (innerMost instanceof CheckCastNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
886 innerMost = ((CheckCastNode) innerMost).object(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
887 } |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
888 ValueNode deepest = downcast(innerMost); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
889 ResolvedJavaType deepestType = ((ObjectStamp) deepest.stamp()).type(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
890 if ((deepestType != null && deepestType.equals(toType)) || FlowUtil.isMorePrecise(deepestType, toType)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
891 assert !w.knowsBetterThan(deepest); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
892 return deepest; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
893 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
894 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
895 |
15427
3af4870a67e4
[flow-sensitive] renaming: downcasted -> downcast
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
15393
diff
changeset
|
896 ValueNode subject = downcast(checkCast.object()); |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
897 ObjectStamp subjectStamp = (ObjectStamp) subject.stamp(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
898 ResolvedJavaType subjectType = subjectStamp.type(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
899 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
900 if (subjectType != null && toType.isAssignableFrom(subjectType)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
901 assert !w.knowsBetterThan(subject); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
902 return subject; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
903 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
904 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
905 return downcastedUtil(checkCast, w); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
906 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
907 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
908 /** |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
909 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
910 * Porcelain method. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
911 * </p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
912 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
913 * <p> |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
914 * This method wraps the argument in a new {@link com.oracle.graal.nodes.PiNode PiNode} (created |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
915 * to hold an updated stamp) provided the argument's stamp can be strictly refined, and returns |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
916 * it. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
917 * </p> |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15388
diff
changeset
|
918 */ |
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
919 private ValueNode downcastedUtil(ValueNode subject, Witness w) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
920 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
921 ObjectStamp originalStamp = (ObjectStamp) subject.stamp(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
922 ObjectStamp outgoingStamp = originalStamp; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
923 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
924 if (w.isNonNull() && !outgoingStamp.nonNull()) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
925 outgoingStamp = FlowUtil.asNonNullStamp(outgoingStamp); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
926 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
927 if (FlowUtil.isMorePrecise(w.type(), outgoingStamp.type())) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
928 outgoingStamp = FlowUtil.asRefinedStamp(outgoingStamp, w.type()); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
929 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
930 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
931 if (outgoingStamp != originalStamp) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
932 assert FlowUtil.isMorePrecise(outgoingStamp, originalStamp); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
933 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
934 boolean isWitnessGuardAnAliasForScrutinee = false; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
935 if (w.guard() instanceof GuardingPiNode || w.guard() instanceof PiNode) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
936 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
937 * The guard offered by the witness canonicalizes into its subject (a possibly |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
938 * type-refined scrutinee) provided its subject conforms as per stamp. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
939 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
940 if (w.guard().asNode().stamp().equals(outgoingStamp)) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
941 isWitnessGuardAnAliasForScrutinee = true; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
942 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
943 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
944 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
945 ValueNode result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
946 if (isWitnessGuardAnAliasForScrutinee) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
947 result = w.guard().asNode(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
948 assert !w.knowsBetterThan(result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
949 return result; // TODO this works. explain why. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
950 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
951 result = wrapInPiNode(subject, w.guard(), outgoingStamp, true); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
952 assert !w.knowsBetterThan(result); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
953 return result; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
954 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
955 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
956 } else { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
957 assert !w.knowsBetterThan(subject); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
958 return subject; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
959 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
960 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
961 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
962 } |