changeset 13870:d04be74665fb

GNFI: add comments
author Matthias Grimmer <grimmer@ssw.jku.at>
date Wed, 05 Feb 2014 09:32:30 +0100
parents e2db5c351ef3
children 0d91d64b88f8 c2000a61fb9a 042a2d972174 ff3136ecb5a7
files graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeFunctionInterface.java graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeLibraryHandle.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeFunctionInterface.java	Wed Feb 05 09:26:36 2014 +0100
+++ b/graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeFunctionInterface.java	Wed Feb 05 09:32:30 2014 +0100
@@ -99,7 +99,7 @@
 
     @Override
     public AMD64NativeFunctionHandle getFunctionHandle(String functionName, Class returnType, Class[] argumentTypes) {
-        if (rtldDefault.asRawValue() == AMD64NativeLibraryHandle.INVALID_HANDLE) {
+        if (rtldDefault.asRawValue() == AMD64NativeLibraryHandle.INVALID_RTLD_DEFAULT_HANDLE) {
             throw new AssertionError("No library provided or RTLD_DEFAULT not supported!");
         }
         return getFunctionHandle(rtldDefault, functionName, returnType, argumentTypes);
--- a/graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeLibraryHandle.java	Wed Feb 05 09:26:36 2014 +0100
+++ b/graal/com.oracle.graal.ffi.amd64/src/com/oracle/graal/ffi/amd64/AMD64NativeLibraryHandle.java	Wed Feb 05 09:32:30 2014 +0100
@@ -27,7 +27,12 @@
 public class AMD64NativeLibraryHandle implements NativeLibraryHandle {
 
     private final long handle;
-    public static final long INVALID_HANDLE = 0xDEADFACE;
+    // The native side (graalCompilerToVM.cpp) sets the rtldDefault handle to 0xDEADFACE if the
+    // platform is Windows.
+    // AMD64NativeFunctionInterface checks if rtld_default handle is valid.
+    // Windows is currently not supported.
+    // Using 0 is not possible as it is a valid value for rtldDefault on some platforms.
+    public static final long INVALID_RTLD_DEFAULT_HANDLE = 0xDEADFACE;
 
     public AMD64NativeLibraryHandle(long handle) {
         this.handle = handle;
@@ -38,6 +43,6 @@
     }
 
     public boolean isValid() {
-        return handle != 0 && handle != INVALID_HANDLE;
+        return handle != 0;
     }
 }
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Feb 05 09:26:36 2014 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Feb 05 09:32:30 2014 +0100
@@ -563,7 +563,10 @@
   #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux)
   set_long("rtldDefault", (jlong) RTLD_DEFAULT);
   #else 
-  set_long("rtldDefault", (jlong) 0xDEADFACE); //TODO(mg): will crash on java side, not supported!  
+  // Windows is not supported at the moment. 
+  // On Java-side we do a check on 0xDEADFACE and crash if rtldDefault == 0xDEADFACE. 
+  // Using 0 is not possible as it is a valid value for rtldDefault on some platforms.
+  set_long("rtldDefault", (jlong) 0xDEADFACE);
   #endif
 
 #undef set_boolean