# HG changeset patch # User Josef Eisl # Date 1444663468 -7200 # Node ID aa321bfb2a65e9edc72cfff668517d70475ea303 # Parent 7b33db06a9517683de14935afb37bd3c36bf2265 NodeLIRBuilder: add option to create new variables for object constants that are used in PHIs. diff -r 7b33db06a951 -r aa321bfb2a65 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java --- 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 TraceRA = new OptionValue<>(false); @Option(help = "Never spill constant intervals.", type = OptionType.Debug) public static final OptionValue NeverSpillConstants = new OptionValue<>(false); + @Option(help = "Support object constant to stack move.", type = OptionType.Debug) + public static final OptionValue AllowObjectConstantToStackMove = new OptionValue<>(true); // @formatter:on } diff -r 7b33db06a951 -r aa321bfb2a65 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- 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 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 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); }