changeset 5151:b69b779a26df ppc-aix-port-b03

Turned off ImplicitNullChecks on AIX by default because it requires UseSIGTRAP which isn't currently implemented on AIX
author simonis
date Thu, 13 Dec 2012 16:21:01 +0100
parents a3bcdfe8674c
children 00aaa21b62b1
files src/cpu/ppc/vm/globals_ppc.hpp src/os/aix/vm/os_aix.cpp
diffstat 2 files changed, 73 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/ppc/vm/globals_ppc.hpp	Wed Dec 12 18:11:27 2012 +0100
+++ b/src/cpu/ppc/vm/globals_ppc.hpp	Thu Dec 13 16:21:01 2012 +0100
@@ -37,7 +37,7 @@
 define_pd_global(bool, NeedsDeoptSuspend,     false); // only register window machines need this
 
 
-define_pd_global(bool, ImplicitNullChecks,    true);  // Generate code for implicit null checks
+define_pd_global(bool, ImplicitNullChecks,    AIX_ONLY(false) NOT_AIX(true));  // Generate code for implicit null checks
 define_pd_global(bool, UncommonNullCast,      true);  // Uncommon-trap NULLs past to check cast
 
 // use large code-entry alignment.
--- a/src/os/aix/vm/os_aix.cpp	Wed Dec 12 18:11:27 2012 +0100
+++ b/src/os/aix/vm/os_aix.cpp	Thu Dec 13 16:21:01 2012 +0100
@@ -1303,9 +1303,80 @@
   return false;
 }
 
+static int getModuleName(codeptr_t pc,                    // [in] program counter
+                         char* p_name, size_t namelen,    // [out] optional: function name
+                         char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages
+                         ) {
+
+  // initialize output parameters
+  if (p_name && namelen > 0) {
+    *p_name = '\0';
+  }
+  if (p_errmsg && errmsglen > 0) {
+    *p_errmsg = '\0';
+  }
+
+  const LoadedLibraryModule* const lib = LoadedLibraries::find_for_text_address((address)pc);
+  if (lib) {
+    if (p_name && namelen > 0) {
+      sprintf(p_name, "%.*s", namelen, lib->get_shortname());
+    }
+    return 0;
+  }
+
+  if (Verbose) {
+    fprintf(stderr, "pc outside any module");
+  }
+
+  return -1;
+
+}
+
+// resolve an AIX function descriptor literal to a code pointer.
+// If the input is a valid code pointer to a text segment of a loaded module,
+//   it is returned unchanged.
+// If the input is a valid AIX function descriptor, it is resolved to the
+//   code entry point.
+// If the input is neither a valid function descriptor nor a valid code pointer,
+//   NULL is returned.
+static address resolve_function_descriptor_to_code_pointer(address p) {
+
+  const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(p);
+  if (lib) {
+    // its a real code pointer
+    return p;
+  } else {
+    lib = LoadedLibraries::find_for_data_address(p);
+    if (lib) {
+      // pointer to data segment, potential function descriptor
+      address code_entry = (address)(((FunctionDescriptor*)p)->entry());
+      if (LoadedLibraries::find_for_text_address(code_entry)) {
+        // Its a function descriptor
+        return code_entry;
+      }
+    }
+  }
+  return NULL;
+}
+
 bool os::dll_address_to_library_name(address addr, char* buf,
                                      int buflen, int* offset) {
-  Unimplemented();
+  if (offset) {
+    *offset = -1;
+  }
+  if (buf) {
+      buf[0] = '\0';
+  }
+
+  // resolve function ptr literals first
+  addr = resolve_function_descriptor_to_code_pointer(addr);
+  if (!addr) {
+    return false;
+  }
+
+  if (::getModuleName((codeptr_t) addr, buf, buflen, 0, 0) == 0) {
+    return true;
+  }
   return false;
 }
 
@@ -4414,35 +4485,6 @@
   return s;
 }
 
-// resolve an AIX function descriptor literal to a code pointer.
-// If the input is a valid code pointer to a text segment of a loaded module,
-//   it is returned unchanged.
-// If the input is a valid AIX function descriptor, it is resolved to the
-//   code entry point.
-// If the input is neither a valid function descriptor nor a valid code pointer,
-//   NULL is returned.
-static address resolve_function_descriptor_to_code_pointer(address p) {
-
-  const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(p);
-  if (lib) {
-    // its a real code pointer
-    return p;
-  } else {
-    lib = LoadedLibraries::find_for_data_address(p);
-    if (lib) {
-      // pointer to data segment, potential function descriptor
-      address code_entry = (address)(((FunctionDescriptor*)p)->entry());
-      if (LoadedLibraries::find_for_text_address(code_entry)) {
-        // Its a function descriptor
-        return code_entry;
-      }
-    }
-  }
-  return NULL;
-}
-
-
-
 // Refer to the comments in os_solaris.cpp park-unpark.
 //
 // Beware -- Some versions of NPTL embody a flaw where pthread_cond_timedwait() can