changeset 16284:96a088675c48

Add ValuePosition.isCompositePosition().
author Josef Eisl <josef.eisl@jku.at>
date Wed, 25 Jun 2014 20:39:27 +0200
parents d59e68286d60
children ad197a92e25e
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValuePosition.java
diffstat 1 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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<OperandFlag> 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() {