# HG changeset patch # User Josef Eisl # Date 1423138569 -3600 # Node ID 3a2fce66fda0522ffdac7ba82a557d88210a751a # Parent 247419385312b92c6bf1bbd80656d89093371cf4 [SPARC] make CompareAndSwapOp side-effect free. diff -r 247419385312 -r 3a2fce66fda0 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- 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() { diff -r 247419385312 -r 3a2fce66fda0 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java --- 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 diff -r 247419385312 -r 3a2fce66fda0 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java --- 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); } }