changeset 13513:64a23ce736a0

added support for ImmutabelCode safepoints (GRAAL-283)
author Doug Simon <doug.simon@oracle.com>
date Mon, 06 Jan 2014 14:21:39 +0100
parents 8085ce95b6f5
children 0fbee3eb71f0
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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();