changeset 22866:1e5e5561ae64

Remove Setx and clean up SPARCMove
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Fri, 16 Oct 2015 10:47:19 +0200
parents 016ec4502b75
children 801aa3ecb166
files graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotStrategySwitchOp.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLoadConstantTableBaseOp.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java
diffstat 12 files changed, 78 insertions(+), 213 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Fri Oct 16 10:47:19 2015 +0200
@@ -33,9 +33,6 @@
 import static jdk.vm.ci.sparc.SPARC.g3;
 import static jdk.vm.ci.sparc.SPARC.i7;
 import static jdk.vm.ci.sparc.SPARC.o7;
-
-import java.util.function.Consumer;
-
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.RegisterConfig;
 import jdk.vm.ci.code.TargetDescription;
@@ -188,183 +185,63 @@
         jmpl(i7, 8, g0);
     }
 
-    /**
-     * This instruction is like sethi but for 64-bit values.
-     */
-    public static class Sethix {
-
-        private static final int INSTRUCTION_SIZE = 7;
-
-        private long value;
-        private Register dst;
-        private boolean forceRelocatable;
-        private boolean delayed = false;
-        private Consumer<SPARCAssembler> delayedInstructionEmitter;
-
-        public Sethix(long value, Register dst, boolean forceRelocatable, boolean delayed) {
-            this(value, dst, forceRelocatable);
-            assert !(forceRelocatable && delayed) : "Relocatable sethix cannot be delayed";
-            this.delayed = delayed;
-        }
-
-        public Sethix(long value, Register dst, boolean forceRelocatable) {
-            this.value = value;
-            this.dst = dst;
-            this.forceRelocatable = forceRelocatable;
-        }
-
-        public Sethix(long value, Register dst) {
-            this(value, dst, false);
-        }
-
-        private void emitInstruction(Consumer<SPARCAssembler> cb, SPARCMacroAssembler masm) {
-            if (delayed) {
-                if (this.delayedInstructionEmitter != null) {
-                    delayedInstructionEmitter.accept(masm);
-                }
-                delayedInstructionEmitter = cb;
-            } else {
-                cb.accept(masm);
-            }
-        }
-
-        public void emit(SPARCMacroAssembler masm) {
-            final int hi = (int) (value >> 32);
-            final int lo = (int) (value & ~0);
-
-            // This is the same logic as MacroAssembler::internal_set.
-            final int startPc = masm.position();
-
-            if (hi == 0 && lo >= 0) {
-                Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(lo), dst);
-                emitInstruction(cb, masm);
-            } else if (hi == -1) {
-                Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(~lo), dst);
-                emitInstruction(cb, masm);
-                cb = eMasm -> eMasm.xor(dst, ~lo10(~0), dst);
-                emitInstruction(cb, masm);
-            } else {
-                final int shiftcnt;
-                final int shiftcnt2;
-                Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(hi), dst);
-                emitInstruction(cb, masm);
-                if ((hi & 0x3ff) != 0) {                                  // Any bits?
-                    // msb 32-bits are now in lsb 32
-                    cb = eMasm -> eMasm.or(dst, hi & 0x3ff, dst);
-                    emitInstruction(cb, masm);
-                }
-                if ((lo & 0xFFFFFC00) != 0) {                             // done?
-                    if (((lo >> 20) & 0xfff) != 0) {                      // Any bits set?
-                        // Make room for next 12 bits
-                        cb = eMasm -> eMasm.sllx(dst, 12, dst);
-                        emitInstruction(cb, masm);
-                        // Or in next 12
-                        cb = eMasm -> eMasm.or(dst, (lo >> 20) & 0xfff, dst);
-                        emitInstruction(cb, masm);
-                        shiftcnt = 0;                                     // We already shifted
-                    } else {
-                        shiftcnt = 12;
-                    }
-                    if (((lo >> 10) & 0x3ff) != 0) {
-                        // Make room for last 10 bits
-                        cb = eMasm -> eMasm.sllx(dst, shiftcnt + 10, dst);
-                        emitInstruction(cb, masm);
-                        // Or in next 10
-                        cb = eMasm -> eMasm.or(dst, (lo >> 10) & 0x3ff, dst);
-                        emitInstruction(cb, masm);
-                        shiftcnt2 = 0;
-                    } else {
-                        shiftcnt2 = 10;
-                    }
-                    // Shift leaving disp field 0'd
-                    cb = eMasm -> eMasm.sllx(dst, shiftcnt2 + 10, dst);
-                    emitInstruction(cb, masm);
-                } else {
-                    cb = eMasm -> eMasm.sllx(dst, 32, dst);
-                    emitInstruction(cb, masm);
-                }
-            }
-            // Pad out the instruction sequence so it can be patched later.
-            if (forceRelocatable) {
-                while (masm.position() < (startPc + (INSTRUCTION_SIZE * 4))) {
-                    Consumer<SPARCAssembler> cb = eMasm -> eMasm.nop();
-                    emitInstruction(cb, masm);
-                }
-            }
-        }
-
-        public void emitDelayed(SPARCMacroAssembler masm) {
-            assert delayedInstructionEmitter != null;
-            delayedInstructionEmitter.accept(masm);
+    public void setx(long value, Register dst, boolean forceRelocatable) {
+        int lo = (int) (value & ~0);
+        sethix(value, dst, forceRelocatable);
+        if (lo10(lo) != 0 || forceRelocatable) {
+            add(dst, lo10(lo), dst);
         }
     }
 
-    public static class Setx {
+    public void sethix(long value, Register dst, boolean forceRelocatable) {
+        final int hi = (int) (value >> 32);
+        final int lo = (int) (value & ~0);
 
-        private long value;
-        private Register dst;
-        private boolean forceRelocatable;
-        private boolean delayed = false;
-        private boolean delayedFirstEmitted = false;
-        private Sethix sethix;
-        private Consumer<SPARCMacroAssembler> delayedAdd;
-
-        public Setx(long value, Register dst, boolean forceRelocatable, boolean delayed) {
-            assert !(forceRelocatable && delayed) : "Cannot use relocatable setx as delayable";
-            this.value = value;
-            this.dst = dst;
-            this.forceRelocatable = forceRelocatable;
-            this.delayed = delayed;
-        }
-
-        public Setx(long value, Register dst, boolean forceRelocatable) {
-            this(value, dst, forceRelocatable, false);
-        }
-
-        public Setx(long value, Register dst) {
-            this(value, dst, false);
-        }
-
-        public void emit(SPARCMacroAssembler masm) {
-            assert !delayed;
-            doEmit(masm);
-        }
-
-        private void doEmit(SPARCMacroAssembler masm) {
-            sethix = new Sethix(value, dst, forceRelocatable, delayed);
-            sethix.emit(masm);
-            int lo = (int) (value & ~0);
-            if (lo10(lo) != 0 || forceRelocatable) {
-                Consumer<SPARCMacroAssembler> add = eMasm -> eMasm.add(dst, lo10(lo), dst);
-                if (delayed) {
-                    sethix.emitDelayed(masm);
-                    sethix = null;
-                    delayedAdd = add;
+        // This is the same logic as MacroAssembler::internal_set.
+        final int startPc = position();
+        if (hi == 0 && lo >= 0) {
+            sethi(hi22(lo), dst);
+        } else if (hi == -1) {
+            sethi(hi22(~lo), dst);
+            xor(dst, ~lo10(~0), dst);
+        } else {
+            final int shiftcnt;
+            final int shiftcnt2;
+            sethi(hi22(hi), dst);
+            if ((hi & 0x3ff) != 0) {                                  // Any bits?
+                // msb 32-bits are now in lsb 32
+                or(dst, hi & 0x3ff, dst);
+            }
+            if ((lo & 0xFFFFFC00) != 0) {                             // done?
+                if (((lo >> 20) & 0xfff) != 0) {                      // Any bits set?
+                    // Make room for next 12 bits
+                    sllx(dst, 12, dst);
+                    // Or in next 12
+                    or(dst, (lo >> 20) & 0xfff, dst);
+                    shiftcnt = 0;                                     // We already shifted
                 } else {
-                    sethix = null;
-                    add.accept(masm);
+                    shiftcnt = 12;
                 }
+                if (((lo >> 10) & 0x3ff) != 0) {
+                    // Make room for last 10 bits
+                    sllx(dst, shiftcnt + 10, dst);
+                    // Or in next 10
+                    or(dst, (lo >> 10) & 0x3ff, dst);
+                    shiftcnt2 = 0;
+                } else {
+                    shiftcnt2 = 10;
+                }
+                // Shift leaving disp field 0'd
+                sllx(dst, shiftcnt2 + 10, dst);
+            } else {
+                sllx(dst, 32, dst);
             }
         }
-
-        public void emitFirstPartOfDelayed(SPARCMacroAssembler masm) {
-            assert !forceRelocatable : "Cannot use delayed mode with relocatable setx";
-            assert delayed : "Can only be used in delayed mode";
-            doEmit(masm);
-            delayedFirstEmitted = true;
-        }
-
-        public void emitSecondPartOfDelayed(SPARCMacroAssembler masm) {
-            assert !forceRelocatable : "Cannot use delayed mode with relocatable setx";
-            assert delayed : "Can only be used in delayed mode";
-            assert delayedFirstEmitted : "First part has not been emitted so far.";
-            assert delayedAdd == null && sethix != null || delayedAdd != null && sethix == null : "Either add or sethix must be set";
-            if (delayedAdd != null) {
-                delayedAdd.accept(masm);
-            } else {
-                sethix.emitDelayed(masm);
+        // Pad out the instruction sequence so it can be patched later.
+        if (forceRelocatable) {
+            while (position() < (startPc + (INSTRUCTION_SIZE * 7))) {
+                nop();
             }
-
         }
     }
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Fri Oct 16 10:47:19 2015 +0200
@@ -61,7 +61,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig;
 import com.oracle.graal.compiler.common.cfg.AbstractBlockBase;
 import com.oracle.graal.compiler.sparc.SPARCArithmeticLIRGenerator;
@@ -176,7 +175,7 @@
                         try (ScratchRegister sc = masm.getScratchRegister()) {
                             Register scratch = sc.getRegister();
                             assert afterFrameInit || isGlobalRegister(scratch) : "Only global (g1-g7) registers are allowed if the frame was not initialized here. Got register " + scratch;
-                            new Setx(address.getDisplacement(), scratch).emit(masm);
+                            masm.setx(address.getDisplacement(), scratch, false);
                             masm.stx(g0, new SPARCAddress(sp, scratch));
                         }
                     }
@@ -212,7 +211,7 @@
                 try (ScratchRegister sc = masm.getScratchRegister()) {
                     Register scratch = sc.getRegister();
                     assert isGlobalRegister(scratch) : "Only global registers are allowed before save. Got register " + scratch;
-                    new Setx(stackpoinerChange, scratch).emit(masm);
+                    masm.setx(stackpoinerChange, scratch, false);
                     masm.save(sp, scratch, sp);
                 }
             }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -36,7 +36,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.hotspot.HotSpotCounterOp;
 import com.oracle.graal.hotspot.meta.HotSpotRegistersProvider;
 import com.oracle.graal.lir.LIRInstructionClass;
@@ -132,7 +131,7 @@
             } else {
                 try (ScratchRegister scratch = masm.getScratchRegister()) {
                     Register tempOffsetRegister = scratch.getRegister();
-                    new Setx(relativeDisplacement, tempOffsetRegister, false).emit(masm);
+                    masm.setx(relativeDisplacement, tempOffsetRegister, false);
                     masm.add(countersArrayReg, tempOffsetRegister, countersArrayReg);
                 }
                 lastDisplacement = displacement;
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -32,7 +32,6 @@
 
 import com.oracle.graal.asm.sparc.SPARCAddress;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.lir.LIRFrameState;
 import com.oracle.graal.lir.LIRInstructionClass;
 import com.oracle.graal.lir.Opcode;
@@ -89,7 +88,7 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-            new Setx(config.safepointPollingAddress, ValueUtil.asRegister(result)).emit(masm);
+            masm.setx(config.safepointPollingAddress, ValueUtil.asRegister(result), false);
         }
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotStrategySwitchOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotStrategySwitchOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -75,8 +75,7 @@
 
                 Register scratchRegister = asRegister(scratch);
                 final int byteCount = constant.isCompressed() ? 4 : 8;
-                Runnable recordReference = () -> crb.recordDataReferenceInCode(constant, byteCount);
-                loadFromConstantTable(crb, masm, byteCount, asRegister(constantTableBase), scratchRegister, SPARCDelayedControlTransfer.DUMMY, recordReference);
+                loadFromConstantTable(crb, masm, byteCount, asRegister(constantTableBase), constant, scratchRegister, SPARCDelayedControlTransfer.DUMMY);
 
                 if (canUseShortBranch) {
                     CBCOND.emit(masm, conditionFlag, conditionCode == CC.Xcc, keyRegister, scratchRegister, target);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -29,7 +29,6 @@
 import jdk.vm.ci.meta.Value;
 
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.lir.LIRFrameState;
 import com.oracle.graal.lir.LIRInstructionClass;
 import com.oracle.graal.lir.Opcode;
@@ -62,6 +61,6 @@
         // instruction that loads the Klass from the inline cache.
         crb.recordMark(invokeKind == InvokeKind.Virtual ? config.MARKID_INVOKEVIRTUAL : config.MARKID_INVOKEINTERFACE);
         Register scratchRegister = g5;
-        new Setx(config.nonOopBits, scratchRegister, true).emit(masm);
+        masm.setx(config.nonOopBits, scratchRegister, true);
     }
 }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Fri Oct 16 10:47:19 2015 +0200
@@ -42,9 +42,9 @@
 import static jdk.vm.ci.code.ValueUtil.isRegister;
 import static jdk.vm.ci.sparc.SPARC.g0;
 import static jdk.vm.ci.sparc.SPARCKind.DOUBLE;
-import static jdk.vm.ci.sparc.SPARCKind.XWORD;
 import static jdk.vm.ci.sparc.SPARCKind.SINGLE;
 import static jdk.vm.ci.sparc.SPARCKind.WORD;
+import static jdk.vm.ci.sparc.SPARCKind.XWORD;
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.AllocatableValue;
@@ -56,7 +56,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.lir.LIRFrameState;
 import com.oracle.graal.lir.LIRInstructionClass;
 import com.oracle.graal.lir.Opcode;
@@ -185,7 +184,7 @@
                 switch (opcode) {
                     case LUREM:
                         if (isJavaConstant(x)) {
-                            new Setx(crb.asLongConst(x), asRegister(scratch2, XWORD), false).emit(masm);
+                            masm.setx(crb.asLongConst(x), asRegister(scratch2, XWORD), false);
                             xLeft = scratch2;
                         }
                         assert !asRegister(xLeft, XWORD).equals(asRegister(scratch1, XWORD));
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -68,7 +68,7 @@
         SPARCMove.emitStore(input, addr, result.getPlatformKind(), SPARCDelayedControlTransfer.DUMMY, null, crb, masm);
         if (addr.getIndex().equals(Register.None)) {
             Register tempReg = ValueUtil.asRegister(tempIndex, XWORD);
-            new SPARCMacroAssembler.Setx(addr.getDisplacement(), tempReg, false).emit(masm);
+            masm.setx(addr.getDisplacement(), tempReg, false);
             addr = new SPARCAddress(addr.getBase(), tempReg);
         }
         getDelayedControlTransfer().emitControlTransfer(crb, masm);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java	Fri Oct 16 10:47:19 2015 +0200
@@ -37,7 +37,6 @@
 import com.oracle.graal.asm.sparc.SPARCAddress;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Sethix;
 import com.oracle.graal.compiler.common.spi.ForeignCallLinkage;
 import com.oracle.graal.lir.LIRFrameState;
 import com.oracle.graal.lir.LIRInstructionClass;
@@ -202,7 +201,7 @@
             // offset might not fit a 30-bit displacement, generate an
             // indirect call with a 64-bit immediate
             before = masm.position();
-            new Sethix(0L, scratch, true).emit(masm);
+            masm.sethix(0L, scratch, true);
             masm.jmpl(scratch, 0, o7);
         } else {
             before = masm.call(0);
@@ -216,7 +215,7 @@
 
     public static void indirectJmp(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget target) {
         int before = masm.position();
-        new Sethix(0L, dst, true).emit(masm);
+        masm.sethix(0L, dst, true);
         masm.jmp(new SPARCAddress(dst, 0));
         masm.nop();  // delay slot
         int after = masm.position();
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Fri Oct 16 10:47:19 2015 +0200
@@ -68,8 +68,8 @@
 import static jdk.vm.ci.code.ValueUtil.asRegister;
 import static jdk.vm.ci.sparc.SPARC.CPU;
 import static jdk.vm.ci.sparc.SPARC.g0;
+import static jdk.vm.ci.sparc.SPARCKind.WORD;
 import static jdk.vm.ci.sparc.SPARCKind.XWORD;
-import static jdk.vm.ci.sparc.SPARCKind.WORD;
 
 import java.util.ArrayList;
 import java.util.EnumSet;
@@ -98,7 +98,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.compiler.common.calc.Condition;
 import com.oracle.graal.lir.LIRInstructionClass;
 import com.oracle.graal.lir.LabelRef;
@@ -597,7 +596,7 @@
             } else {
                 try (ScratchRegister sc = masm.getScratchRegister()) {
                     Register scratch2 = sc.getRegister();
-                    new Setx(lowKey, scratch2).emit(masm);
+                    masm.setx(lowKey, scratch2, false);
                     masm.sub(value, scratch2, scratchReg);
                 }
             }
@@ -607,7 +606,7 @@
                 if (isSimm13(upperLimit)) {
                     masm.cmp(scratchReg, upperLimit);
                 } else {
-                    new Setx(upperLimit, scratch2).emit(masm);
+                    masm.setx(upperLimit, scratch2, false);
                     masm.cmp(scratchReg, upperLimit);
                 }
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLoadConstantTableBaseOp.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLoadConstantTableBaseOp.java	Fri Oct 16 10:47:19 2015 +0200
@@ -55,7 +55,7 @@
  * CodeInstaller::pd_patch_DataSectionReference
  *
  * @see SPARCMove#loadFromConstantTable(CompilationResultBuilder, SPARCMacroAssembler, int,
- *      Register, Register, SPARCDelayedControlTransfer, Runnable)
+ *      Register, jdk.vm.ci.meta.Constant, Register, SPARCDelayedControlTransfer)
  */
 public class SPARCLoadConstantTableBaseOp extends SPARCLIRInstruction {
     public static final LIRInstructionClass<SPARCLoadConstantTableBaseOp> TYPE = LIRInstructionClass.create(SPARCLoadConstantTableBaseOp.class);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Wed Oct 21 21:38:13 2015 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Fri Oct 16 10:47:19 2015 +0200
@@ -65,8 +65,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Sethix;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.lir.LIRFrameState;
 import com.oracle.graal.lir.LIRInstructionClass;
 import com.oracle.graal.lir.Opcode;
@@ -129,15 +127,14 @@
         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
             final int byteCount = result.getPlatformKind().getSizeInBytes();
             assert byteCount > 1 : "Byte values must not be loaded via constant table";
-            final Runnable recordReference = () -> crb.recordDataReferenceInCode(constant, byteCount);
             Register baseRegister = asRegister(constantTableBase);
             if (isRegister(result)) {
                 Register resultRegister = asRegister(result);
-                loadFromConstantTable(crb, masm, byteCount, baseRegister, resultRegister, getDelayedControlTransfer(), recordReference);
+                loadFromConstantTable(crb, masm, byteCount, baseRegister, constant, resultRegister, getDelayedControlTransfer());
             } else if (isStackSlot(result)) {
                 try (ScratchRegister scratch = masm.getScratchRegister()) {
                     Register scratchRegister = scratch.getRegister();
-                    loadFromConstantTable(crb, masm, byteCount, baseRegister, scratchRegister, getDelayedControlTransfer(), recordReference);
+                    loadFromConstantTable(crb, masm, byteCount, baseRegister, constant, scratchRegister, getDelayedControlTransfer());
                     StackSlot slot = asStackSlot(result);
                     reg2stack(crb, masm, slot, scratchRegister.asValue(), getDelayedControlTransfer());
                 }
@@ -346,7 +343,7 @@
             assert addr == masm.getPlaceholder();
             final boolean forceRelocatable = true;
             Register dstReg = asRegister(result);
-            new Setx(0, dstReg, forceRelocatable).emit(masm);
+            masm.setx(0, dstReg, forceRelocatable);
         }
 
         @Override
@@ -463,7 +460,7 @@
                 masm.add(address.getBase(), address.getDisplacement(), result);
             } else {
                 assert result.encoding() != address.getBase().encoding();
-                new Setx(address.getDisplacement(), result).emit(masm);
+                masm.setx(address.getDisplacement(), result, false);
                 // No relocation, therefore, the add can be delayed as well
                 delaySlotHolder.emitControlTransfer(crb, masm);
                 masm.add(address.getBase(), result, result);
@@ -621,7 +618,7 @@
     public static SPARCAddress generateSimm13OffsetLoad(SPARCAddress addr, SPARCMacroAssembler masm, Register scratch) {
         boolean displacementOutOfBound = addr.getIndex().equals(Register.None) && !SPARCAssembler.isSimm13(addr.getDisplacement());
         if (displacementOutOfBound) {
-            new Setx(addr.getDisplacement(), scratch, false).emit(masm);
+            masm.setx(addr.getDisplacement(), scratch, false);
             return new SPARCAddress(addr.getBase(), scratch);
         } else {
             return addr;
@@ -636,7 +633,6 @@
             boolean hasVIS3 = cpuFeatures.contains(CPUFeature.VIS3);
             Register resultRegister = asRegister(result);
             int byteCount = result.getPlatformKind().getSizeInBytes();
-            Runnable recordReference = () -> crb.recordDataReferenceInCode(input, byteCount);
             switch (input.getJavaKind().getStackKind()) {
                 case Int:
                     if (input.isDefaultForKind()) {
@@ -649,7 +645,7 @@
                         if (constantTableBase.equals(g0)) {
                             throw JVMCIError.shouldNotReachHere();
                         } else {
-                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, resultRegister, delaySlotLir, recordReference);
+                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, input, resultRegister, delaySlotLir);
                         }
                     }
                     break;
@@ -661,7 +657,7 @@
                         delaySlotLir.emitControlTransfer(crb, masm);
                         masm.or(g0, (int) input.asLong(), resultRegister);
                     } else {
-                        loadFromConstantTable(crb, masm, byteCount, constantTableBase, resultRegister, delaySlotLir, recordReference);
+                        loadFromConstantTable(crb, masm, byteCount, constantTableBase, input, resultRegister, delaySlotLir);
                     }
                     break;
                 case Float: {
@@ -677,7 +673,7 @@
                             masm.movwtos(scratch, resultRegister);
                         } else {
                             // First load the address into the scratch register
-                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, resultRegister, delaySlotLir, recordReference);
+                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, input, resultRegister, delaySlotLir);
                         }
                     }
                     break;
@@ -694,7 +690,7 @@
                             delaySlotLir.emitControlTransfer(crb, masm);
                             masm.movxtod(scratch, resultRegister);
                         } else {
-                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, resultRegister, delaySlotLir, recordReference);
+                            loadFromConstantTable(crb, masm, byteCount, constantTableBase, input, resultRegister, delaySlotLir);
                         }
                     }
                     break;
@@ -704,7 +700,7 @@
                         delaySlotLir.emitControlTransfer(crb, masm);
                         masm.clr(resultRegister);
                     } else {
-                        loadFromConstantTable(crb, masm, byteCount, constantTableBase, resultRegister, delaySlotLir, recordReference);
+                        loadFromConstantTable(crb, masm, byteCount, constantTableBase, input, resultRegister, delaySlotLir);
                     }
                     break;
                 default:
@@ -763,8 +759,8 @@
      * generated patterns by this method must be understood by
      * CodeInstaller::pd_patch_DataSectionReference (jvmciCodeInstaller_sparc.cpp).
      */
-    public static void loadFromConstantTable(CompilationResultBuilder crb, SPARCMacroAssembler masm, int byteCount, Register constantTableBase, Register dest,
-                    SPARCDelayedControlTransfer delaySlotInstruction, Runnable recordReference) {
+    public static void loadFromConstantTable(CompilationResultBuilder crb, SPARCMacroAssembler masm, int byteCount, Register constantTableBase, Constant input, Register dest,
+                    SPARCDelayedControlTransfer delaySlotInstruction) {
         SPARCAddress address;
         ScratchRegister scratch = null;
         try {
@@ -772,12 +768,12 @@
                 address = new SPARCAddress(constantTableBase, 0);
                 // Make delayed only, when using immediate constant load.
                 delaySlotInstruction.emitControlTransfer(crb, masm);
-                recordReference.run();
+                crb.recordDataReferenceInCode(input, byteCount);
             } else {
                 scratch = masm.getScratchRegister();
                 Register sr = scratch.getRegister();
-                recordReference.run();
-                new Sethix(0, sr, true).emit(masm);
+                crb.recordDataReferenceInCode(input, byteCount);
+                masm.sethix(0, sr, true);
                 address = new SPARCAddress(sr, 0);
             }
             masm.ld(address, dest, byteCount, false);