43972
|
1 |
/*
|
58877
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
43972
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
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 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.nodes;
|
|
26 |
|
|
27 |
import static org.graalvm.compiler.nodeinfo.InputType.Association;
|
|
28 |
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
|
|
29 |
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
|
|
30 |
|
|
31 |
import org.graalvm.compiler.core.common.type.Stamp;
|
58877
|
32 |
import org.graalvm.compiler.graph.Node;
|
43972
|
33 |
import org.graalvm.compiler.graph.Node.ValueNumberable;
|
58877
|
34 |
import org.graalvm.compiler.graph.spi.Canonicalizable;
|
|
35 |
import org.graalvm.compiler.graph.spi.CanonicalizerTool;
|
43972
|
36 |
import org.graalvm.compiler.graph.NodeClass;
|
|
37 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
38 |
import org.graalvm.compiler.nodes.calc.FloatingNode;
|
|
39 |
import org.graalvm.compiler.nodes.extended.GuardingNode;
|
58877
|
40 |
import org.graalvm.compiler.nodes.memory.MemoryNode;
|
|
41 |
import org.graalvm.compiler.nodes.spi.Proxy;
|
|
42 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
43972
|
43 |
|
|
44 |
/**
|
|
45 |
* A proxy is inserted at loop exits for any value that is created inside the loop (i.e. was not
|
|
46 |
* live on entry to the loop) and is (potentially) used after the loop.
|
|
47 |
*/
|
|
48 |
@NodeInfo(cycles = CYCLES_0, size = SIZE_0)
|
58877
|
49 |
public abstract class ProxyNode extends FloatingNode implements Proxy, ValueNumberable, Canonicalizable {
|
43972
|
50 |
|
|
51 |
public static final NodeClass<ProxyNode> TYPE = NodeClass.create(ProxyNode.class);
|
|
52 |
@Input(Association) LoopExitNode loopExit;
|
|
53 |
|
|
54 |
protected ProxyNode(NodeClass<? extends ProxyNode> c, Stamp stamp, LoopExitNode proxyPoint) {
|
|
55 |
super(c, stamp);
|
|
56 |
assert proxyPoint != null;
|
|
57 |
this.loopExit = proxyPoint;
|
|
58 |
}
|
|
59 |
|
|
60 |
public abstract ValueNode value();
|
|
61 |
|
51436
|
62 |
public void setProxyPoint(LoopExitNode newProxyPoint) {
|
|
63 |
this.updateUsages(loopExit, newProxyPoint);
|
|
64 |
this.loopExit = newProxyPoint;
|
|
65 |
}
|
|
66 |
|
43972
|
67 |
public LoopExitNode proxyPoint() {
|
|
68 |
return loopExit;
|
|
69 |
}
|
|
70 |
|
|
71 |
@Override
|
58877
|
72 |
public ValueNode getOriginalNode() {
|
|
73 |
return value();
|
|
74 |
}
|
|
75 |
|
|
76 |
@Override
|
43972
|
77 |
public boolean verify() {
|
|
78 |
assert !(value() instanceof ProxyNode) || ((ProxyNode) value()).loopExit != loopExit;
|
|
79 |
return super.verify();
|
|
80 |
}
|
|
81 |
|
58877
|
82 |
public static ValueProxyNode forValue(ValueNode value, LoopExitNode exit) {
|
|
83 |
return exit.graph().unique(new ValueProxyNode(value, exit));
|
|
84 |
}
|
|
85 |
|
|
86 |
public static GuardProxyNode forGuard(GuardingNode value, LoopExitNode exit) {
|
|
87 |
return exit.graph().unique(new GuardProxyNode(value, exit));
|
43972
|
88 |
}
|
|
89 |
|
58877
|
90 |
public static MemoryProxyNode forMemory(MemoryNode value, LoopExitNode exit, LocationIdentity locationIdentity) {
|
|
91 |
return exit.graph().unique(new MemoryProxyNode(value, exit, locationIdentity));
|
|
92 |
}
|
|
93 |
|
|
94 |
@Override
|
|
95 |
public Node canonical(CanonicalizerTool tool) {
|
|
96 |
if (value() == null) {
|
|
97 |
return null;
|
|
98 |
}
|
|
99 |
return this;
|
43972
|
100 |
}
|
57537
|
101 |
|
|
102 |
public abstract PhiNode createPhi(AbstractMergeNode merge);
|
43972
|
103 |
}
|