Mercurial > hg > graal-compiler
changeset 17025:b23172dcb8f7
[SPARC] Giving now two scratch registers
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Tue, 02 Sep 2014 17:17:56 -0700 |
parents | 4e2d34d7715b |
children | 8adf60d5ce73 |
files | graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARCScratchRegister.java |
diffstat | 2 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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<Boolean> locked = new ThreadLocal<>(); + private final ThreadLocal<Exception> 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; + } + } }