17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package org.graalvm.compiler.virtual.phases.ea;
24
25 import java.util.ArrayList;
26
27 import org.graalvm.compiler.debug.DebugContext;
28 import org.graalvm.compiler.graph.Node;
29 import org.graalvm.compiler.nodes.ControlSinkNode;
30 import org.graalvm.compiler.nodes.FixedNode;
31 import org.graalvm.compiler.nodes.FixedWithNextNode;
32 import org.graalvm.compiler.nodes.FrameState;
33 import org.graalvm.compiler.nodes.IfNode;
34 import org.graalvm.compiler.nodes.NodeView;
35 import org.graalvm.compiler.nodes.PhiNode;
36 import org.graalvm.compiler.nodes.PiNode;
37 import org.graalvm.compiler.nodes.ProxyNode;
38 import org.graalvm.compiler.nodes.StructuredGraph;
39 import org.graalvm.compiler.nodes.ValueNode;
40 import org.graalvm.compiler.nodes.debug.DynamicCounterNode;
41 import org.graalvm.compiler.nodes.debug.WeakCounterNode;
42 import org.graalvm.compiler.nodes.util.GraphUtil;
43 import org.graalvm.compiler.nodes.virtual.EscapeObjectState;
44 import org.graalvm.compiler.phases.common.DeadCodeEliminationPhase;
45
46 public final class GraphEffectList extends EffectList {
47
48 public GraphEffectList(DebugContext debug) {
49 super(debug);
50 }
51
52 /**
53 * Determines how many objects are virtualized (positive) or materialized (negative) by this
54 * effect.
55 */
56 private int virtualizationDelta;
57
99 }
100 }
101 });
102 }
103
104 public void addVirtualizationDelta(int delta) {
105 virtualizationDelta += delta;
106 }
107
108 public int getVirtualizationDelta() {
109 return virtualizationDelta;
110 }
111
112 /**
113 * Add the given floating node to the graph.
114 *
115 * @param node The floating node to be added.
116 */
117 public void addFloatingNode(ValueNode node, @SuppressWarnings("unused") String cause) {
118 add("add floating node", graph -> {
119 if (node instanceof ProxyNode) {
120 ProxyNode proxyNode = (ProxyNode) node;
121 ValueNode value = proxyNode.value();
122 if (!value.isAlive()) {
123 graph.addWithoutUnique(value);
124 }
125 }
126 graph.addWithoutUnique(node);
127 });
128 }
129
130 /**
131 * Sets the phi node's input at the given index to the given value, adding new phi inputs as
132 * needed.
133 *
134 * @param node The phi node whose input should be changed.
135 * @param index The index of the phi input to be changed.
136 * @param value The new value for the phi input.
137 */
138 public void initializePhiInput(PhiNode node, int index, ValueNode value) {
139 add("set phi input", (graph, obsoleteNodes) -> {
140 assert node.isAlive() && index >= 0;
141 node.initializeValueAt(index, graph.addOrUniqueWithInputs(value));
142 });
143 }
144
145 /**
146 * Adds a virtual object's state to the given frame state. If the given reusedVirtualObjects set
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package org.graalvm.compiler.virtual.phases.ea;
24
25 import java.util.ArrayList;
26
27 import org.graalvm.compiler.debug.DebugContext;
28 import org.graalvm.compiler.graph.Node;
29 import org.graalvm.compiler.nodes.ControlSinkNode;
30 import org.graalvm.compiler.nodes.FixedNode;
31 import org.graalvm.compiler.nodes.FixedWithNextNode;
32 import org.graalvm.compiler.nodes.FrameState;
33 import org.graalvm.compiler.nodes.IfNode;
34 import org.graalvm.compiler.nodes.NodeView;
35 import org.graalvm.compiler.nodes.PhiNode;
36 import org.graalvm.compiler.nodes.PiNode;
37 import org.graalvm.compiler.nodes.StructuredGraph;
38 import org.graalvm.compiler.nodes.ValueNode;
39 import org.graalvm.compiler.nodes.debug.DynamicCounterNode;
40 import org.graalvm.compiler.nodes.debug.WeakCounterNode;
41 import org.graalvm.compiler.nodes.util.GraphUtil;
42 import org.graalvm.compiler.nodes.virtual.EscapeObjectState;
43 import org.graalvm.compiler.phases.common.DeadCodeEliminationPhase;
44
45 public final class GraphEffectList extends EffectList {
46
47 public GraphEffectList(DebugContext debug) {
48 super(debug);
49 }
50
51 /**
52 * Determines how many objects are virtualized (positive) or materialized (negative) by this
53 * effect.
54 */
55 private int virtualizationDelta;
56
98 }
99 }
100 });
101 }
102
103 public void addVirtualizationDelta(int delta) {
104 virtualizationDelta += delta;
105 }
106
107 public int getVirtualizationDelta() {
108 return virtualizationDelta;
109 }
110
111 /**
112 * Add the given floating node to the graph.
113 *
114 * @param node The floating node to be added.
115 */
116 public void addFloatingNode(ValueNode node, @SuppressWarnings("unused") String cause) {
117 add("add floating node", graph -> {
118 graph.addWithoutUniqueWithInputs(node);
119 });
120 }
121
122 /**
123 * Sets the phi node's input at the given index to the given value, adding new phi inputs as
124 * needed.
125 *
126 * @param node The phi node whose input should be changed.
127 * @param index The index of the phi input to be changed.
128 * @param value The new value for the phi input.
129 */
130 public void initializePhiInput(PhiNode node, int index, ValueNode value) {
131 add("set phi input", (graph, obsoleteNodes) -> {
132 assert node.isAlive() && index >= 0;
133 node.initializeValueAt(index, graph.addOrUniqueWithInputs(value));
134 });
135 }
136
137 /**
138 * Adds a virtual object's state to the given frame state. If the given reusedVirtualObjects set
|