# HG changeset patch # User Tom Rodriguez # Date 1410255307 -7200 # Node ID 8456194ca311724850f29eaa7551a9001c5569b7 # Parent 2bc092f3d574e3c887ac26d81be805b192962189 Unproxy constant usages in FrameState diff -r 2bc092f3d574 -r 8456194ca311 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Mon Sep 08 22:21:47 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Tue Sep 09 11:35:07 2014 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.util.*; import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.virtual.nodes.*; @@ -203,20 +204,24 @@ STATE_VIRTUAL_OBJECTS.increment(); return vobject; } - } else if (value instanceof ConstantNode) { - STATE_CONSTANTS.increment(); - return ((ConstantNode) value).getValue(); + } else { + // Remove proxies from constants so the constant can be directly embedded. + ValueNode unproxied = GraphUtil.unproxify(value); + if (unproxied instanceof ConstantNode) { + STATE_CONSTANTS.increment(); + return ((ConstantNode) unproxied).getValue(); - } else if (value != null) { - STATE_VARIABLES.increment(); - Value operand = nodeOperands.get(value); - assert operand != null && (operand instanceof Variable || operand instanceof Constant) : operand + " for " + value; - return operand; + } else if (value != null) { + STATE_VARIABLES.increment(); + Value operand = nodeOperands.get(value); + assert operand != null && (operand instanceof Variable || operand instanceof Constant) : operand + " for " + value; + return operand; - } else { - // return a dummy value because real value not needed - STATE_ILLEGALS.increment(); - return Value.ILLEGAL; + } else { + // return a dummy value because real value not needed + STATE_ILLEGALS.increment(); + return Value.ILLEGAL; + } } } catch (GraalInternalError e) { throw e.addContext("toValue: ", value); diff -r 2bc092f3d574 -r 8456194ca311 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Mon Sep 08 22:21:47 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Tue Sep 09 11:35:07 2014 +0200 @@ -107,12 +107,36 @@ // insert moves, delete null instructions and reset instruction ids lir.getControlFlowGraph().getBlocks().forEach(this::rewriteBlock); + + assert verifyStates(); } catch (Throwable e) { throw Debug.handle(e); } } } + private boolean verifyStates() { + map.forEach(this::verifyStateUsage); + return true; + } + + private void verifyStateUsage(DefUseTree tree) { + Variable var = tree.getVariable(); + ValueConsumer stateConsumer = new ValueConsumer() { + + @Override + public void visitValue(Value operand) { + assert !operand.equals(var) : "constant usage through variable in frame state " + var; + } + }; + for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + for (LIRInstruction inst : lir.getLIRforBlock(block)) { + // set instruction id to the index in the lir instruction list + inst.visitEachState(stateConsumer); + } + } + } + private static boolean isConstantLoad(LIRInstruction inst) { if (!(inst instanceof MoveOp)) { return false;