Mercurial > hg > graal-compiler
changeset 17068:8456194ca311
Unproxy constant usages in FrameState
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 09 Sep 2014 11:35:07 +0200 |
parents | 2bc092f3d574 |
children | 2740dad59eb7 |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java |
diffstat | 2 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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;