diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java @ 6710:6db6881c1270

add Virtualizable and VirtualizerTool, refactor PEA to use it
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 12 Nov 2012 17:49:06 +0100
parents 73124ee1ee37
children 94f032472c28
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Mon Nov 12 17:48:51 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Mon Nov 12 17:49:06 2012 +0100
@@ -26,14 +26,16 @@
 import com.oracle.graal.graph.Node.ValueNumberable;
 import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.nodes.virtual.*;
 
 /**
  * A value proxy that is inserted in the frame state of a loop exit for any value that is
  * created inside the loop (i.e. was not live on entry to the loop) and is (potentially)
  * used after the loop.
  */
-public class ValueProxyNode extends FloatingNode implements Node.IterableNodeType, ValueNumberable {
+public class ValueProxyNode extends FloatingNode implements Node.IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable {
     @Input(notDataflow = true) private BeginNode proxyPoint;
     @Input private ValueNode value;
     private final PhiType type;
@@ -74,4 +76,20 @@
         assert proxyPoint != null;
         return super.verify();
     }
+
+    @Override
+    public ValueNode canonical(CanonicalizerTool tool) {
+        if (value.isConstant()) {
+            return value;
+        }
+        return this;
+    }
+
+    @Override
+    public void virtualize(VirtualizerTool tool) {
+        VirtualObjectNode virtual = tool.getVirtualState(value());
+        if (virtual != null) {
+            tool.replaceWithVirtual(virtual);
+        }
+    }
 }