# HG changeset patch # User Thomas Wuerthinger # Date 1362509256 -3600 # Node ID 24e93ac47e957b09e2ddb926eb63cad0c4ad8726 # Parent 29c2103630ef3a0f83a7e38e834b21bd30c5508c Allocate temporary register for safepoint operation instead of using scratch register. diff -r 29c2103630ef -r 24e93ac47e95 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Mar 05 19:32:06 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Mar 05 19:47:36 2013 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.amd64.AMD64.*; import static com.oracle.graal.api.code.CallingConvention.Type.*; import static com.oracle.graal.api.code.ValueUtil.*; -import static com.oracle.graal.phases.GraalOptions.*; import java.lang.reflect.*; @@ -105,7 +104,7 @@ @Override public void visitSafepointNode(SafepointNode i) { LIRFrameState info = state(); - append(new AMD64SafepointOp(info, runtime().config)); + append(new AMD64SafepointOp(info, runtime().config, this)); } @Override @@ -225,7 +224,6 @@ int frameSize = tasm.frameMap.frameSize(); AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; CalleeSaveLayout csl = tasm.frameMap.registerConfig.getCalleeSaveLayout(); - RegisterConfig regConfig = tasm.frameMap.registerConfig; if (csl != null && csl.size != 0) { tasm.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); diff -r 29c2103630ef -r 24e93ac47e95 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Tue Mar 05 19:32:06 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Tue Mar 05 19:47:36 2013 +0100 @@ -35,6 +35,7 @@ import com.oracle.graal.lir.LIRInstruction.Opcode; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; +import com.oracle.graal.nodes.spi.*; /** * Emits a safepoint poll. @@ -45,30 +46,32 @@ private static final Unsafe unsafe = Unsafe.getUnsafe(); @State protected LIRFrameState state; + @Temp({OperandFlag.REG}) private AllocatableValue temp; private final HotSpotVMConfig config; - public AMD64SafepointOp(LIRFrameState state, HotSpotVMConfig config) { + public AMD64SafepointOp(LIRFrameState state, HotSpotVMConfig config, LIRGeneratorTool tool) { this.state = state; this.config = config; + temp = tool.newVariable(tool.target().wordKind); } @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { - Register scratch = tasm.frameMap.registerConfig.getScratchRegister(); int pos = asm.codeBuffer.position(); int offset = SafepointPollOffset % unsafe.pageSize(); + RegisterValue scratch = (RegisterValue) temp; if (config.isPollingPageFar) { - asm.movq(scratch, config.safepointPollingAddress + offset); + asm.movq(scratch.getRegister(), config.safepointPollingAddress + offset); tasm.recordMark(Marks.MARK_POLL_FAR); tasm.recordSafepoint(pos, state); - asm.movq(scratch, new AMD64Address(tasm.target.wordKind, scratch.asValue())); + asm.movq(scratch.getRegister(), new AMD64Address(tasm.target.wordKind, scratch)); } else { tasm.recordMark(Marks.MARK_POLL_NEAR); tasm.recordSafepoint(pos, state); // The C++ code transforms the polling page offset into an RIP displacement // to the real address at that offset in the polling page. - asm.movq(scratch, new AMD64Address(tasm.target.wordKind, rip.asValue(), offset)); + asm.movq(scratch.getRegister(), new AMD64Address(tasm.target.wordKind, rip.asValue(), offset)); } } } diff -r 29c2103630ef -r 24e93ac47e95 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Tue Mar 05 19:32:06 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Tue Mar 05 19:47:36 2013 +0100 @@ -49,7 +49,7 @@ public abstract Value operand(ValueNode object); - public abstract Value newVariable(Kind kind); + public abstract AllocatableValue newVariable(Kind kind); public abstract Value setResult(ValueNode x, Value operand);