# HG changeset patch # User Stefan Anzinger # Date 1409703476 25200 # Node ID b23172dcb8f79057fc1126ba50140893b2c6d026 # Parent 4e2d34d7715b591a38405ae4732643ecb4fed6c6 [SPARC] Giving now two scratch registers diff -r 4e2d34d7715b -r b23172dcb8f7 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 Tue Sep 02 17:16:26 2014 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Sep 02 17:17:56 2014 -0700 @@ -411,14 +411,16 @@ if (isRegister(result)) { const2reg(crb, masm, result, (Constant) input); } else if (isStackSlot(result)) { - Register scratch = g1; - Constant constant = asConstant(input); - if (constant.isNull()) { - new Clr(scratch).emit(masm); - } else { - new Setx(constant.asLong(), scratch).emit(masm); + try (SPARCScratchRegister sc = SPARCScratchRegister.get()) { + Register scratch = sc.getRegister(); + Constant constant = asConstant(input); + if (constant.isNull()) { + new Clr(scratch).emit(masm); + } else { + new Setx(constant.asLong(), scratch).emit(masm); + } + reg2stack(crb, masm, result, scratch.asValue(LIRKind.derive(input))); } - reg2stack(crb, masm, result, scratch.asValue(LIRKind.derive(input))); } else { throw GraalInternalError.shouldNotReachHere("Result is a: " + result); } diff -r 4e2d34d7715b -r b23172dcb8f7 graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARCScratchRegister.java --- a/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARCScratchRegister.java Tue Sep 02 17:16:26 2014 -0700 +++ b/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARCScratchRegister.java Tue Sep 02 17:17:56 2014 -0700 @@ -4,8 +4,10 @@ public class SPARCScratchRegister implements AutoCloseable { private final ThreadLocal locked = new ThreadLocal<>(); + private final ThreadLocal where = new ThreadLocal<>(); private final Register register; - private static final SPARCScratchRegister scratch = new SPARCScratchRegister(SPARC.g3); + private static final SPARCScratchRegister scratch1 = new SPARCScratchRegister(SPARC.g3); + private static final SPARCScratchRegister scratch2 = new SPARCScratchRegister(SPARC.g1); private SPARCScratchRegister(Register register) { super(); @@ -18,8 +20,10 @@ } boolean isLocked = locked.get(); if (isLocked) { + where.get().printStackTrace(); throw new RuntimeException("Temp Register is already taken!"); } else { + where.set(new Exception()); locked.set(true); return register; } @@ -35,7 +39,19 @@ } public static SPARCScratchRegister get() { - return scratch; + if (scratch1.isLocked()) { + return scratch2; + } else { + return scratch1; + } } + public boolean isLocked() { + Boolean isLocked = locked.get(); + if (isLocked == null) { + return false; + } else { + return isLocked; + } + } }