changeset 22455:ec2a1d0000dd

TraceRA: remove replacement hack from ShadowedRegisterValue.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 13 Aug 2015 13:33:34 +0200
parents 2f6d931cd4be
children 122c9802bcaa
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/ShadowedRegisterValue.java
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/ShadowedRegisterValue.java	Thu Aug 13 13:30:27 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/ShadowedRegisterValue.java	Thu Aug 13 13:33:34 2015 +0200
@@ -27,7 +27,6 @@
 import java.util.*;
 
 import jdk.internal.jvmci.code.*;
-import jdk.internal.jvmci.meta.*;
 
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
@@ -35,14 +34,8 @@
 
 /**
  * Represents a {@link #register} which has a shadow copy on the {@link #stackslot stack}.
- * <p>
- * Note: {@link ShadowedRegisterValue} does not follow the contract of {@link CompositeValue}, for
- * instance the {@link #forEachComponent} does not visit {@link #register} or {@link #stackslot} but
- * the {@link CompositeValue} itself. Therefore it should be only used in the context of the
- * {@link TraceRegisterAllocationPhase}.
  */
 final class ShadowedRegisterValue extends CompositeValue {
-    private static final EnumSet<OperandFlag> flags = EnumSet.of(COMPOSITE);
     private static final EnumSet<OperandFlag> registerFlags = EnumSet.of(REG);
     private static final EnumSet<OperandFlag> stackslotFlags = EnumSet.of(STACK);
 
@@ -65,9 +58,13 @@
     }
 
     @Override
-    public Value forEachComponent(LIRInstruction inst, OperandMode mode, InstructionValueProcedure proc) {
-        /* TODO(jeisl) This is a hack to be able to replace the composite value with the register. */
-        return proc.doValue(inst, this, mode, flags);
+    public CompositeValue forEachComponent(LIRInstruction inst, OperandMode mode, InstructionValueProcedure proc) {
+        RegisterValue newRegister = (RegisterValue) proc.doValue(inst, register, mode, registerFlags);
+        StackSlotValue newStackSlot = (StackSlotValue) proc.doValue(inst, stackslot, mode, stackslotFlags);
+        if (register.equals(newRegister) || stackslot.equals(newStackSlot)) {
+            return this;
+        }
+        return new ShadowedRegisterValue(newRegister, newStackSlot);
     }
 
     @Override