# HG changeset patch # User Josef Eisl # Date 1403721567 -7200 # Node ID 96a088675c48fa1477b34001fb6cfbd7be3bf6b5 # Parent d59e68286d602dc3c0d5c2d2c064994ebca46e6e Add ValuePosition.isCompositePosition(). diff -r d59e68286d60 -r 96a088675c48 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java Wed Jun 25 20:27:22 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java Wed Jun 25 20:39:27 2014 +0200 @@ -48,41 +48,42 @@ } private static CompositeValue getCompositeValue(LIRInstruction inst, ValuePosition pos) { - ValuePosition superPosition = pos.getSuperPosition(); Value value; - if (superPosition == ROOT_VALUE_POSITION) { - // At this point we are at the top of the ValuePosition tree + if (pos.isCompositePosition()) { + value = getCompositeValue(inst, pos.getSuperPosition()); + } else { value = inst.getLIRInstructionClass().getValue(inst, pos); - } else { - // Get the containing value - value = getCompositeValue(inst, superPosition); } assert value instanceof CompositeValue : "only CompositeValue can contain nested values " + value; return (CompositeValue) value; } + public boolean isCompositePosition() { + return superPosition != ROOT_VALUE_POSITION; + } + public Value get(LIRInstruction inst) { - if (this.getSuperPosition() == ROOT_VALUE_POSITION) { - return inst.getLIRInstructionClass().getValue(inst, this); + if (isCompositePosition()) { + CompositeValue compValue = getCompositeValue(inst, this); + return compValue.getValueClass().getValue(compValue, this); } - CompositeValue compValue = getCompositeValue(inst, this); - return compValue.getValueClass().getValue(compValue, this); + return inst.getLIRInstructionClass().getValue(inst, this); } public EnumSet getFlags(LIRInstruction inst) { - if (this.getSuperPosition() == ROOT_VALUE_POSITION) { - return inst.getLIRInstructionClass().getFlags(this); + if (isCompositePosition()) { + CompositeValue compValue = getCompositeValue(inst, this); + return compValue.getValueClass().getFlags(this); } - CompositeValue compValue = getCompositeValue(inst, this); - return compValue.getValueClass().getFlags(this); + return inst.getLIRInstructionClass().getFlags(this); } public void set(LIRInstruction inst, Value value) { - if (this.getSuperPosition() == ROOT_VALUE_POSITION) { - inst.getLIRInstructionClass().setValue(inst, this, value); + if (isCompositePosition()) { + CompositeValue compValue = getCompositeValue(inst, this); + compValue.getValueClass().setValue(compValue, this, value); } - CompositeValue compValue = getCompositeValue(inst, this); - compValue.getValueClass().setValue(compValue, this, value); + inst.getLIRInstructionClass().setValue(inst, this, value); } public int getSubIndex() {