changeset 21669:942793d2a513

Turn BoxNode from floating to fixed node.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 02 Jun 2015 21:07:25 +0200
parents ffe693cc427f
children 5731adc3a10a
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/NativeCallStubGraphBuilder.java
diffstat 3 files changed, 15 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Tue Jun 02 18:29:35 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Tue Jun 02 21:07:25 2015 +0200
@@ -26,10 +26,8 @@
 
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -41,13 +39,15 @@
  * methods in Integer, Long, etc.
  */
 @NodeInfo
-public final class BoxNode extends UnaryNode implements VirtualizableAllocation, Lowerable {
+public final class BoxNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable {
 
     public static final NodeClass<BoxNode> TYPE = NodeClass.create(BoxNode.class);
-    protected final Kind boxingKind;
+    @Input private ValueNode value;
+    private final Kind boxingKind;
 
     public BoxNode(ValueNode value, ResolvedJavaType resultType, Kind boxingKind) {
-        super(TYPE, StampFactory.exactNonNull(resultType), value);
+        super(TYPE, StampFactory.exactNonNull(resultType));
+        this.value = value;
         this.boxingKind = boxingKind;
     }
 
@@ -55,18 +55,13 @@
         return boxingKind;
     }
 
-    @Override
-    public void lower(LoweringTool tool) {
-        tool.getLowerer().lower(this, tool);
+    public ValueNode getValue() {
+        return value;
     }
 
     @Override
-    public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
-        /*
-         * Constant values are not canonicalized into their constant boxing objects because this
-         * would mean that the information that they came from a valueOf is lost.
-         */
-        return this;
+    public void lower(LoweringTool tool) {
+        tool.getLowerer().lower(this, tool);
     }
 
     @Override
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Tue Jun 02 18:29:35 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Tue Jun 02 21:07:25 2015 +0200
@@ -33,7 +33,6 @@
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
@@ -185,15 +184,14 @@
             FloatingNode canonical = canonicalizeBoxing(box, providers.getMetaAccess(), providers.getConstantReflection());
             // if in AOT mode, we don't want to embed boxed constants.
             if (canonical != null && !ImmutableCode.getValue()) {
-                box.graph().replaceFloating(box, canonical);
+                box.graph().replaceFixedWithFloating(box, canonical);
             } else {
                 Arguments args = new Arguments(boxSnippets.get(box.getBoxingKind()), box.graph().getGuardsStage(), tool.getLoweringStage());
                 args.add("value", box.getValue());
 
                 SnippetTemplate template = template(args);
                 Debug.log("Lowering integerValueOf in %s: node=%s, template=%s, arguments=%s", box.graph(), box, template, args);
-                template.instantiate(providers.getMetaAccess(), box, DEFAULT_REPLACER, tool, args);
-                GraphUtil.killWithUnusedFloatingInputs(box);
+                template.instantiate(providers.getMetaAccess(), box, DEFAULT_REPLACER, args);
             }
         }
 
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/NativeCallStubGraphBuilder.java	Tue Jun 02 18:29:35 2015 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/NativeCallStubGraphBuilder.java	Tue Jun 02 21:07:25 2015 +0200
@@ -90,13 +90,14 @@
                     throw new IllegalArgumentException("Return type not supported: " + returnType.getName());
                 }
                 ResolvedJavaType type = providers.getMetaAccess().lookupJavaType(callNode.getKind().toBoxedJavaClass());
-                boxedResult = g.unique(new BoxNode(callNode, type, callNode.getKind()));
+                boxedResult = g.add(new BoxNode(callNode, type, callNode.getKind()));
             } else {
-                boxedResult = g.unique(new BoxNode(ConstantNode.forLong(0, g), providers.getMetaAccess().lookupJavaType(Long.class), Kind.Long));
+                boxedResult = g.add(new BoxNode(ConstantNode.forLong(0, g), providers.getMetaAccess().lookupJavaType(Long.class), Kind.Long));
             }
 
+            callNode.setNext(boxedResult);
             ReturnNode returnNode = g.add(new ReturnNode(boxedResult));
-            callNode.setNext(returnNode);
+            boxedResult.setNext(returnNode);
             return g;
         } catch (NoSuchMethodException e) {
             throw JVMCIError.shouldNotReachHere("Call Stub method not found");