changeset 22149:1bd5caa41faf

[SPARC] Load safepoint polling address into a register, instead of constructing it each time
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Fri, 03 Jul 2015 09:56:16 +0200
parents 7ae8ad713862
children 18480847a17b
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.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java
diffstat 4 files changed, 55 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Thu Jul 02 17:37:22 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Fri Jul 03 09:56:16 2015 +0200
@@ -82,6 +82,11 @@
      */
     private StackSlot deoptimizationRescueSlot;
 
+    /**
+     * Value where the address for safepoint poll is kept.
+     */
+    private AllocatableValue safepointAddressValue;
+
     @Override
     public StackSlotValue getLockSlot(int lockDepth) {
         return getLockStack().makeLockSlot(lockDepth);
@@ -154,12 +159,11 @@
             operand = resultOperandFor(input.getLIRKind());
             emitMove(operand, input);
         }
-        append(new SPARCHotSpotReturnOp(operand, getStub() != null, runtime().getConfig()));
+        append(new SPARCHotSpotReturnOp(operand, getStub() != null, runtime().getConfig(), getSafepointAddressValue()));
     }
 
     @Override
     public void emitTailcall(Value[] args, Value address) {
-        // append(new AMD64TailcallOp(args, address));
         throw JVMCIError.unimplemented();
     }
 
@@ -477,4 +481,11 @@
             return null;
         }
     }
+
+    public AllocatableValue getSafepointAddressValue() {
+        if (this.safepointAddressValue == null) {
+            this.safepointAddressValue = newVariable(LIRKind.value(target().wordKind));
+        }
+        return this.safepointAddressValue;
+    }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Thu Jul 02 17:37:22 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Fri Jul 03 09:56:16 2015 +0200
@@ -132,6 +132,13 @@
     }
 
     @Override
+    protected void emitPrologue(StructuredGraph graph) {
+        super.emitPrologue(graph);
+        AllocatableValue var = getGen().getSafepointAddressValue();
+        append(new SPARCHotSpotSafepointOp.SPARCLoadSafepointPollAddress(var, getGen().config));
+    }
+
+    @Override
     public void visitFullInfopointNode(FullInfopointNode i) {
         if (i.getState() != null && i.getState().bci == BytecodeFrame.AFTER_BCI) {
             Debug.log("Ignoring InfopointNode for AFTER_BCI");
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java	Thu Jul 02 17:37:22 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java	Fri Jul 03 09:56:16 2015 +0200
@@ -23,9 +23,9 @@
 package com.oracle.graal.hotspot.sparc;
 
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+import static jdk.internal.jvmci.code.ValueUtil.*;
 import jdk.internal.jvmci.hotspot.*;
 import jdk.internal.jvmci.meta.*;
-import jdk.internal.jvmci.sparc.*;
 
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.lir.*;
@@ -41,23 +41,23 @@
     public static final SizeEstimate SIZE = SizeEstimate.create(2);
 
     @Use({REG, ILLEGAL}) protected Value value;
+    @Use({REG}) protected Value safepointPollAddress;
     private final boolean isStub;
     private final HotSpotVMConfig config;
 
-    SPARCHotSpotReturnOp(Value value, boolean isStub, HotSpotVMConfig config) {
+    SPARCHotSpotReturnOp(Value value, boolean isStub, HotSpotVMConfig config, Value safepointPoll) {
         super(TYPE, SIZE);
         this.value = value;
         this.isStub = isStub;
         this.config = config;
+        this.safepointPollAddress = safepointPoll;
     }
 
     @Override
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
         if (!isStub) {
             // Every non-stub compile method must have a poll before the return.
-            // Using the same scratch register as LIR_Assembler::return_op
-            // in c1_LIRAssembler_sparc.cpp
-            SPARCHotSpotSafepointOp.emitCode(crb, masm, config, true, null, SPARC.l0);
+            SPARCHotSpotSafepointOp.emitCode(crb, masm, config, true, null, asRegister(safepointPollAddress));
         }
         ReturnOp.emitCodeHelper(crb, masm);
     }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Thu Jul 02 17:37:22 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Fri Jul 03 09:56:16 2015 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
+import static jdk.internal.jvmci.code.ValueUtil.*;
 import static jdk.internal.jvmci.sparc.SPARC.*;
 import jdk.internal.jvmci.code.*;
 import jdk.internal.jvmci.hotspot.*;
@@ -43,30 +44,47 @@
     public static final SizeEstimate SIZE = SizeEstimate.create(9);
 
     @State protected LIRFrameState state;
-    @SuppressFBWarnings(value = "BC_IMPOSSIBLE_CAST", justification = "changed by the register allocator") @Temp({OperandFlag.REG}) private AllocatableValue temp;
-
+    @Use({OperandFlag.REG}) AllocatableValue safepointPollAddress;
     private final HotSpotVMConfig config;
 
     public SPARCHotSpotSafepointOp(LIRFrameState state, HotSpotVMConfig config, LIRGeneratorTool tool) {
         super(TYPE, SIZE);
         this.state = state;
         this.config = config;
-        this.temp = tool.newVariable(LIRKind.value(tool.target().wordKind));
+        SPARCHotSpotLIRGenerator lirGen = (SPARCHotSpotLIRGenerator) tool;
+        safepointPollAddress = lirGen.getSafepointAddressValue();
     }
 
     @Override
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-        Register scratch = ((RegisterValue) temp).getRegister();
-        emitCode(crb, masm, config, false, state, scratch);
+        emitCode(crb, masm, config, false, state, asRegister(safepointPollAddress));
+    }
+
+    public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register safepointPollAddress) {
+        crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
+        if (state != null) {
+            final int pos = masm.position();
+            crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
+        }
+        masm.ldx(new SPARCAddress(safepointPollAddress, 0), g0);
     }
 
-    public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
-        new Setx(config.safepointPollingAddress, scratch).emit(masm);
-        crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
-        final int pos = masm.position();
-        masm.ldx(new SPARCAddress(scratch, 0), g0);
-        if (state != null) {
-            crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
+    public static class SPARCLoadSafepointPollAddress extends SPARCLIRInstruction {
+        public static final LIRInstructionClass<SPARCLoadSafepointPollAddress> TYPE = LIRInstructionClass.create(SPARCLoadSafepointPollAddress.class);
+        public static final SizeEstimate SIZE = SizeEstimate.create(2);
+
+        @Def({OperandFlag.REG}) protected AllocatableValue result;
+        private final HotSpotVMConfig config;
+
+        public SPARCLoadSafepointPollAddress(AllocatableValue result, HotSpotVMConfig config) {
+            super(TYPE, SIZE);
+            this.result = result;
+            this.config = config;
+        }
+
+        @Override
+        public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
+            new Setx(config.safepointPollingAddress, ValueUtil.asRegister(result)).emit(masm);
         }
     }
 }