changeset 22802:aa321bfb2a65

NodeLIRBuilder: add option to create new variables for object constants that are used in PHIs.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 12 Oct 2015 17:24:28 +0200
parents 7b33db06a951
children f67bef7309ad
files graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java	Fri Oct 09 13:36:05 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java	Mon Oct 12 17:24:28 2015 +0200
@@ -43,6 +43,8 @@
         public static final OptionValue<Boolean> TraceRA = new OptionValue<>(false);
         @Option(help = "Never spill constant intervals.", type = OptionType.Debug)
         public static final OptionValue<Boolean> NeverSpillConstants = new OptionValue<>(false);
+        @Option(help = "Support object constant to stack move.", type = OptionType.Debug)
+        public static final OptionValue<Boolean> AllowObjectConstantToStackMove = new OptionValue<>(true);
         // @formatter:on
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Fri Oct 09 13:36:05 2015 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Mon Oct 12 17:24:28 2015 +0200
@@ -48,6 +48,7 @@
 import jdk.vm.ci.meta.PlatformKind;
 import jdk.vm.ci.meta.Value;
 
+import com.oracle.graal.compiler.common.BackendOptions;
 import com.oracle.graal.compiler.common.calc.Condition;
 import com.oracle.graal.compiler.common.cfg.BlockMap;
 import com.oracle.graal.compiler.common.type.Stamp;
@@ -78,6 +79,7 @@
 import com.oracle.graal.nodes.AbstractBeginNode;
 import com.oracle.graal.nodes.AbstractEndNode;
 import com.oracle.graal.nodes.AbstractMergeNode;
+import com.oracle.graal.nodes.ConstantNode;
 import com.oracle.graal.nodes.DeoptimizingNode;
 import com.oracle.graal.nodes.DirectCallTargetNode;
 import com.oracle.graal.nodes.FixedNode;
@@ -115,6 +117,7 @@
  */
 public abstract class NodeLIRBuilder implements NodeLIRBuilderTool, LIRGenerationDebugContext {
 
+    private final boolean allowObjectConstantToStackMove;
     private final NodeMap<Value> nodeOperands;
     private final DebugInfoBuilder debugInfoBuilder;
 
@@ -137,6 +140,7 @@
 
         assert nodeMatchRules.lirBuilder == null;
         nodeMatchRules.lirBuilder = this;
+        allowObjectConstantToStackMove = BackendOptions.UserOptions.AllowObjectConstantToStackMove.getValue();
     }
 
     public NodeMatchRules getNodeMatchRules() {
@@ -279,7 +283,8 @@
     private Value[] createPhiOut(AbstractMergeNode merge, AbstractEndNode pred) {
         List<Value> values = new ArrayList<>();
         for (PhiNode phi : merge.valuePhis()) {
-            Value value = operand(phi.valueAt(pred));
+            ValueNode node = phi.valueAt(pred);
+            Value value = operand(node);
             assert value != null;
             if (isRegister(value)) {
                 /*
@@ -287,6 +292,14 @@
                  * new Variable.
                  */
                 value = gen.emitMove(value);
+            } else if (!allowObjectConstantToStackMove && node instanceof ConstantNode && !value.getLIRKind().isValue()) {
+                /*
+                 * Object constants are not allowed as inputs for PHIs. Explicitly create a copy of
+                 * this value to force it into a register. The new variable is only used in the PHI.
+                 */
+                Variable result = gen.newVariable(value.getLIRKind());
+                gen.emitMove(result, value);
+                value = result;
             }
             values.add(value);
         }