changeset 19157:3a2fce66fda0

[SPARC] make CompareAndSwapOp side-effect free.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 05 Feb 2015 13:16:09 +0100
parents 247419385312
children 7a300e47cec3
files graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java
diffstat 3 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Thu Feb 05 10:34:13 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Thu Feb 05 13:16:09 2015 +0100
@@ -221,15 +221,14 @@
     }
 
     public Variable emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
-        Variable newValueTemp = newVariable(newValue.getLIRKind());
-        emitMove(newValueTemp, newValue);
 
         LIRKind kind = newValue.getLIRKind();
         assert kind.equals(expectedValue.getLIRKind());
         Kind memKind = (Kind) kind.getPlatformKind();
         SPARCAddressValue addressValue = asAddressValue(address);
-        append(new CompareAndSwapOp(asAllocatable(addressValue), asAllocatable(expectedValue), asAllocatable(newValueTemp)));
-        return emitConditionalMove(memKind, expectedValue, newValueTemp, Condition.EQ, true, trueValue, falseValue);
+        Variable result = newVariable(newValue.getLIRKind());
+        append(new CompareAndSwapOp(result, asAllocatable(addressValue), asAllocatable(expectedValue), asAllocatable(newValue)));
+        return emitConditionalMove(memKind, expectedValue, result, Condition.EQ, true, trueValue, falseValue);
     }
 
     public StackSlot getDeoptimizationRescueSlot() {
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Thu Feb 05 10:34:13 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Thu Feb 05 13:16:09 2015 +0100
@@ -76,8 +76,6 @@
         Value offset = operand(x.offset());
         Variable cmpValue = (Variable) gen.loadNonConst(operand(x.expectedValue()));
         Variable newValue = gen.load(operand(x.newValue()));
-        Variable newValueTemp = gen.newVariable(newValue.getLIRKind());
-        getGen().emitMove(newValueTemp, newValue);
         LIRKind kind = cmpValue.getLIRKind();
         assert kind.equals(newValue.getLIRKind());
 
@@ -92,8 +90,9 @@
             }
         }
 
-        append(new CompareAndSwapOp(address, cmpValue, newValueTemp));
-        setResult(x, gen.emitMove(newValueTemp));
+        Variable result = gen.newVariable(newValue.getLIRKind());
+        append(new CompareAndSwapOp(result, address, cmpValue, newValue));
+        setResult(x, result);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Thu Feb 05 10:34:13 2015 +0100
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Thu Feb 05 13:16:09 2015 +0100
@@ -436,12 +436,13 @@
     @Opcode("CAS")
     public static class CompareAndSwapOp extends SPARCLIRInstruction {
 
-        // @Def protected AllocatableValue result;
-        @Use protected AllocatableValue address;
-        @Use protected AllocatableValue cmpValue;
-        @Use protected AllocatableValue newValue;
+        @Def({REG, HINT}) protected AllocatableValue result;
+        @Alive({REG}) protected AllocatableValue address;
+        @Alive({REG}) protected AllocatableValue cmpValue;
+        @Use({REG}) protected AllocatableValue newValue;
 
-        public CompareAndSwapOp(AllocatableValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+        public CompareAndSwapOp(AllocatableValue result, AllocatableValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+            this.result = result;
             this.address = address;
             this.cmpValue = cmpValue;
             this.newValue = newValue;
@@ -449,7 +450,8 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-            compareAndSwap(masm, address, cmpValue, newValue);
+            move(crb, masm, result, newValue, delayedControlTransfer);
+            compareAndSwap(masm, address, cmpValue, result);
         }
     }