annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java @ 13941:a55d85c207be

Move stamp inference in its own class, and make it extensible via the ValueAndStampProxy interface
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 12 Feb 2014 10:25:16 -0800
parents 640516a8ca6b
children e302df8bf51c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
23 package com.oracle.graal.nodes;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5631
diff changeset
25 import com.oracle.graal.graph.*;
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5631
diff changeset
26 import com.oracle.graal.graph.Node.ValueNumberable;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11880
diff changeset
27 import com.oracle.graal.graph.spi.*;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28 import com.oracle.graal.nodes.PhiNode.PhiType;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
29 import com.oracle.graal.nodes.calc.*;
11334
7f713aad89de Allow ProxyNode as a GuardingNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10765
diff changeset
30 import com.oracle.graal.nodes.extended.*;
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
31 import com.oracle.graal.nodes.spi.*;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
32
5377
9a5608ce6743 added javadoc to ValueProxyNode
Doug Simon <doug.simon@oracle.com>
parents: 5299
diff changeset
33 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
34 * A value proxy that is inserted in the frame state of a loop exit for any value that is created
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
35 * inside the loop (i.e. was not live on entry to the loop) and is (potentially) used after the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
36 * loop.
5377
9a5608ce6743 added javadoc to ValueProxyNode
Doug Simon <doug.simon@oracle.com>
parents: 5299
diff changeset
37 */
7897
a58851061377 rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7896
diff changeset
38 @NodeInfo(nameTemplate = "{p#type/s}Proxy")
13941
a55d85c207be Move stamp inference in its own class, and make it extensible via the ValueAndStampProxy interface
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13152
diff changeset
39 public class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable, ValueAndStampProxy, GuardingNode {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7394
diff changeset
40
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8551
diff changeset
41 @Input(notDataflow = true) private AbstractBeginNode proxyPoint;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
42 @Input private ValueNode value;
5299
0ebd9cfdc11f removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents: 5210
diff changeset
43 private final PhiType type;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
44
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 12721
diff changeset
45 public ProxyNode(ValueNode value, AbstractBeginNode exit, PhiType type) {
7896
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
46 super(type == PhiType.Value ? value.stamp() : type.stamp);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
47 this.type = type;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
48 assert exit != null;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
49 this.proxyPoint = exit;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
50 this.value = value;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
53 public ValueNode value() {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
54 return value;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
56
5631
f2d228de28d7 Make the value proxy node use the stamp of the proxied value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5377
diff changeset
57 @Override
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5631
diff changeset
58 public boolean inferStamp() {
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5631
diff changeset
59 return updateStamp(value.stamp());
5631
f2d228de28d7 Make the value proxy node use the stamp of the proxied value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5377
diff changeset
60 }
f2d228de28d7 Make the value proxy node use the stamp of the proxied value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5377
diff changeset
61
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8551
diff changeset
62 public AbstractBeginNode proxyPoint() {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 return proxyPoint;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66 public PhiType type() {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 return type;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70 @Override
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
71 public boolean verify() {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72 assert value != null;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
73 assert proxyPoint != null;
11416
bcb4ce5bd27e don't create multiple value proxies in PEAReadEliminationClosure
Lukas Stadler <lukas.stadler@jku.at>
parents: 11335
diff changeset
74 assert !(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint != proxyPoint;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
75 return super.verify();
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
76 }
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
77
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
78 @Override
11880
9a747d8e0d0f broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
79 public Node canonical(CanonicalizerTool tool) {
7896
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
80 if (type == PhiType.Value && value.isConstant()) {
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
81 return value;
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
82 }
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
83 return this;
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
84 }
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
85
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
86 @Override
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
87 public void virtualize(VirtualizerTool tool) {
7896
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
88 if (type == PhiType.Value) {
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
89 State state = tool.getObjectState(value);
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
90 if (state != null && state.getState() == EscapeState.Virtual) {
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
91 tool.replaceWithVirtual(state.getVirtualObject());
649379d3f88d don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
92 }
6710
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
93 }
6db6881c1270 add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents: 5659
diff changeset
94 }
8551
0f6dd67470d9 location identity on PhiNodes and ProxyNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7897
diff changeset
95
11335
ccbbb7dbca69 Make sure the created ProxyNode is of PhiType.Guard.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11334
diff changeset
96 public static ProxyNode forGuard(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 12721
diff changeset
97 return graph.unique(new ProxyNode(value, exit, PhiType.Guard));
11335
ccbbb7dbca69 Make sure the created ProxyNode is of PhiType.Guard.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11334
diff changeset
98 }
ccbbb7dbca69 Make sure the created ProxyNode is of PhiType.Guard.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11334
diff changeset
99
9436
ae815a4c112a Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8551
diff changeset
100 public static ProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 12721
diff changeset
101 return graph.unique(new ProxyNode(value, exit, PhiType.Value));
8551
0f6dd67470d9 location identity on PhiNodes and ProxyNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7897
diff changeset
102 }
0f6dd67470d9 location identity on PhiNodes and ProxyNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 7897
diff changeset
103
10762
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 9436
diff changeset
104 @Override
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 9436
diff changeset
105 public ValueNode getOriginalValue() {
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 9436
diff changeset
106 return value;
c483912aaf70 add ValueProxy interface and infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents: 9436
diff changeset
107 }
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
108 }