# HG changeset patch # User Doug Simon # Date 1389014499 -3600 # Node ID 64a23ce736a05045faf19aa84a88e9b9d6e6241f # Parent 8085ce95b6f53d168d8606c7c2d7eeb3bb49419b added support for ImmutabelCode safepoints (GRAAL-283) diff -r 8085ce95b6f5 -r 64a23ce736a0 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Mon Jan 06 13:41:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Mon Jan 06 14:21:39 2014 +0100 @@ -25,6 +25,7 @@ import static com.oracle.graal.amd64.AMD64.*; import static com.oracle.graal.asm.NumUtil.*; import static com.oracle.graal.hotspot.bridge.Marks.*; +import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -49,7 +50,7 @@ public AMD64HotSpotSafepointOp(LIRFrameState state, HotSpotVMConfig config, LIRGeneratorTool tool) { this.state = state; this.config = config; - if (isPollingPageFar(config)) { + if (isPollingPageFar(config) || ImmutableCode.getValue()) { temp = tool.newVariable(tool.target().wordKind); } else { // Don't waste a register if it's unneeded @@ -72,7 +73,20 @@ } public static void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { - if (isPollingPageFar(config)) { + if (ImmutableCode.getValue()) { + Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind(); + int alignment = hostWordKind.getBitCount() / Byte.SIZE; + Constant pollingPageAddress = Constant.forIntegerKind(hostWordKind, config.safepointPollingAddress, null); + // This move will be patched to load the safepoint page from a data segment + // co-located with the immutable code. + asm.movq(scratch, (AMD64Address) crb.recordDataReferenceInCode(pollingPageAddress, alignment, false)); + final int pos = asm.codeBuffer.position(); + crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); + if (state != null) { + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + } + asm.testl(rax, new AMD64Address(scratch)); + } else if (isPollingPageFar(config)) { asm.movq(scratch, config.safepointPollingAddress); crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); final int pos = asm.codeBuffer.position();