changeset 8423:86ef0438d1d3

Generalize FloatingReadPhase to support arbitrary floatable access nodes.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 21 Mar 2013 16:25:26 +0100
parents 1571adaf302b
children 695abf633f6d
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatableAccessNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java
diffstat 3 files changed, 65 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatableAccessNode.java	Thu Mar 21 16:25:26 2013 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.extended;
+
+import java.util.*;
+
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * An {@link AccessNode} that can be converted to a {@link FloatingAccessNode}.
+ */
+public abstract class FloatableAccessNode extends AccessNode {
+
+    public FloatableAccessNode(ValueNode object, ValueNode location, Stamp stamp) {
+        super(object, location, stamp);
+    }
+
+    public FloatableAccessNode(ValueNode object, ValueNode location, Stamp stamp, List<ValueNode> dependencies) {
+        super(object, location, stamp, dependencies);
+    }
+
+    public FloatableAccessNode(ValueNode object, ValueNode location, Stamp stamp, ValueNode... dependencies) {
+        super(object, location, stamp, dependencies);
+    }
+
+    public abstract FloatingAccessNode asFloatingNode(ValueNode lastLocationAccess);
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Thu Mar 21 12:30:44 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Thu Mar 21 16:25:26 2013 +0100
@@ -33,7 +33,7 @@
 /**
  * Reads an {@linkplain AccessNode accessed} value.
  */
-public final class ReadNode extends AccessNode implements Node.IterableNodeType, LIRLowerable, Canonicalizable {
+public final class ReadNode extends FloatableAccessNode implements Node.IterableNodeType, LIRLowerable, Canonicalizable {
 
     public ReadNode(ValueNode object, ValueNode location, Stamp stamp) {
         super(object, location, stamp);
@@ -65,6 +65,11 @@
         return canonicalizeRead(this, location(), object(), tool);
     }
 
+    @Override
+    public FloatingAccessNode asFloatingNode(ValueNode lastLocationAccess) {
+        return graph().unique(new FloatingReadNode(object(), location(), lastLocationAccess, stamp(), dependencies()));
+    }
+
     public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool) {
         MetaAccessProvider runtime = tool.runtime();
         if (runtime != null && object != null && object.isConstant()) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Thu Mar 21 12:30:44 2013 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Thu Mar 21 16:25:26 2013 +0100
@@ -126,8 +126,8 @@
 
         @Override
         protected void processNode(FixedNode node, MemoryMap state) {
-            if (node instanceof ReadNode) {
-                processRead((ReadNode) node, state);
+            if (node instanceof FloatableAccessNode) {
+                processFloatable((FloatableAccessNode) node, state);
             } else if (node instanceof MemoryCheckpoint) {
                 processCheckpoint((MemoryCheckpoint) node, state);
             }
@@ -142,23 +142,23 @@
             }
         }
 
-        private void processRead(ReadNode readNode, MemoryMap state) {
-            StructuredGraph graph = (StructuredGraph) readNode.graph();
-            assert readNode.getNullCheck() == false;
-            Object locationIdentity = readNode.location().locationIdentity();
+        private void processFloatable(FloatableAccessNode accessNode, MemoryMap state) {
+            StructuredGraph graph = (StructuredGraph) accessNode.graph();
+            assert accessNode.getNullCheck() == false;
+            Object locationIdentity = accessNode.location().locationIdentity();
             if (locationIdentity != LocationNode.UNKNOWN_LOCATION) {
                 ValueNode lastLocationAccess = state.getLastLocationAccess(locationIdentity);
-                FloatingReadNode floatingRead = graph.unique(new FloatingReadNode(readNode.object(), readNode.location(), lastLocationAccess, readNode.stamp(), readNode.dependencies()));
-                floatingRead.setNullCheck(readNode.getNullCheck());
+                FloatingAccessNode floatingNode = accessNode.asFloatingNode(lastLocationAccess);
+                floatingNode.setNullCheck(accessNode.getNullCheck());
                 ValueAnchorNode anchor = null;
-                for (GuardNode guard : readNode.dependencies().filter(GuardNode.class)) {
+                for (GuardNode guard : accessNode.dependencies().filter(GuardNode.class)) {
                     if (anchor == null) {
                         anchor = graph.add(new ValueAnchorNode());
-                        graph.addAfterFixed(readNode, anchor);
+                        graph.addAfterFixed(accessNode, anchor);
                     }
                     anchor.addAnchoredNode(guard);
                 }
-                graph.replaceFixedWithFloating(readNode, floatingRead);
+                graph.replaceFixedWithFloating(accessNode, floatingNode);
             }
         }