diff graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java @ 12559:ae412befde21

read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
author twisti
date Wed, 23 Oct 2013 19:50:14 -0700
parents ce0b00597980
children 1a66453f73db
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Tue Oct 22 23:16:03 2013 -0700
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Wed Oct 23 19:50:14 2013 -0700
@@ -27,6 +27,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.lir.*;
@@ -57,9 +58,19 @@
         emitCode(tasm, asm, config, false, state, scratch.getRegister());
     }
 
+    /**
+     * Tests if the polling page address can be reached from the code cache with 32-bit
+     * displacements.
+     */
+    private static boolean isPollingPageFar(HotSpotVMConfig config) {
+        final long pollingPageAddress = config.safepointPollingAddress;
+        // TODO return ForceUnreachable ||
+        return !NumUtil.isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !NumUtil.isInt(pollingPageAddress - config.codeCacheHighBoundary());
+    }
+
     public static void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
         final int pos = asm.codeBuffer.position();
-        if (config.isPollingPageFar) {
+        if (isPollingPageFar(config)) {
             asm.movq(scratch, config.safepointPollingAddress);
             tasm.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR);
             if (state != null) {