8166560: [s390] Basic enablement of s390 port.
authorgoetz
Thu, 22 Sep 2016 18:23:15 +0200
changeset 42062 473286891dd8
parent 42061 67176803a846
child 42063 dca9294d9f59
8166560: [s390] Basic enablement of s390 port. Summary: Also fix problem with ARM Elf configuration. Reviewed-by: dholmes, coleenp
hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp
hotspot/src/cpu/ppc/vm/globals_ppc.hpp
hotspot/src/cpu/sparc/vm/globals_sparc.hpp
hotspot/src/cpu/x86/vm/globals_x86.hpp
hotspot/src/cpu/zero/vm/globals_zero.hpp
hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h
hotspot/src/os/linux/vm/os_linux.cpp
hotspot/src/share/tools/hsdis/hsdis.c
hotspot/src/share/vm/code/codeCache.cpp
hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
hotspot/src/share/vm/runtime/globals.hpp
hotspot/src/share/vm/runtime/vm_version.cpp
hotspot/src/share/vm/utilities/macros.hpp
--- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -39,6 +39,7 @@
 define_pd_global(bool, TrapBasedNullChecks,  false);
 define_pd_global(bool, UncommonNullCast,         true);  // Uncommon-trap NULLs past to check cast
 
+define_pd_global(uintx, CodeCacheSegmentSize,    64 TIERED_ONLY(+64)); // Tiered compilation has large code-entry alignment.
 define_pd_global(intx, CodeEntryAlignment,       64);
 define_pd_global(intx, OptoLoopAlignment,        16);
 define_pd_global(intx, InlineFrequencyCount,     100);
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -56,10 +56,11 @@
 define_pd_global(intx, StackReservedPages,    DEFAULT_STACK_RESERVED_PAGES);
 
 // Use large code-entry alignment.
-define_pd_global(intx, CodeEntryAlignment,    128);
-define_pd_global(intx, OptoLoopAlignment,     16);
-define_pd_global(intx, InlineFrequencyCount,  100);
-define_pd_global(intx, InlineSmallCode,       1500);
+define_pd_global(uintx, CodeCacheSegmentSize,  128);
+define_pd_global(intx,  CodeEntryAlignment,    128);
+define_pd_global(intx,  OptoLoopAlignment,     16);
+define_pd_global(intx,  InlineFrequencyCount,  100);
+define_pd_global(intx,  InlineSmallCode,       1500);
 
 // Flags for template interpreter.
 define_pd_global(bool, RewriteBytecodes,      true);
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -44,6 +44,7 @@
 define_pd_global(bool, TrapBasedNullChecks,         false); // Not needed on sparc.
 define_pd_global(bool, UncommonNullCast,            true);  // Uncommon-trap NULLs passed to check cast
 
+define_pd_global(uintx, CodeCacheSegmentSize, 64 TIERED_ONLY(+64)); // Tiered compilation has large code-entry alignment.
 define_pd_global(intx, CodeEntryAlignment,    32);
 // The default setting 16/16 seems to work best.
 // (For _228_jack 16/16 is 2% better than 4/4, 16/4, 32/32, 32/16, or 16/32.)
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -38,6 +38,7 @@
 define_pd_global(bool, TrapBasedNullChecks,      false); // Not needed on x86.
 define_pd_global(bool, UncommonNullCast,         true);  // Uncommon-trap NULLs passed to check cast
 
+define_pd_global(uintx, CodeCacheSegmentSize,    64 TIERED_ONLY(+64)); // Tiered compilation has large code-entry alignment.
 // See 4827828 for this change. There is no globals_core_i486.hpp. I can't
 // assign a different value for C2 without touching a number of files. Use
 // #ifdef to minimize the change as it's late in Mantis. -- FIXME.
--- a/hotspot/src/cpu/zero/vm/globals_zero.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -39,6 +39,7 @@
 define_pd_global(bool,  TrapBasedNullChecks,  false);
 define_pd_global(bool,  UncommonNullCast,     true);
 
+define_pd_global(uintx, CodeCacheSegmentSize, 64 TIERED_ONLY(+64)); // Tiered compilation has large code-entry alignment.
 define_pd_global(intx,  CodeEntryAlignment,   32);
 define_pd_global(intx,  OptoLoopAlignment,    16);
 define_pd_global(intx,  InlineFrequencyCount, 100);
--- a/hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h	Thu Sep 22 18:23:15 2016 +0200
@@ -76,6 +76,9 @@
 #include <asm/ptrace.h>
 #define user_regs_struct user_pt_regs
 #endif
+#if defined(s390x)
+#include <asm/ptrace.h>
+#endif
 
 // This C bool type must be int for compatibility with Linux calls and
 // it would be a mistake to equivalence it to C++ bool on many platforms
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Thu Sep 22 18:23:15 2016 +0200
@@ -291,7 +291,7 @@
   //        1: ...
   //        ...
   //        7: The default directories, normally /lib and /usr/lib.
-#if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
+#if defined(AMD64) || (defined(_LP64) && defined(SPARC)) || defined(PPC64) || defined(S390)
   #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
 #else
   #define DEFAULT_LIBPATH "/lib:/usr/lib"
@@ -1212,8 +1212,8 @@
 }
 
 #ifndef SYS_clock_getres
-  #if defined(IA32) || defined(AMD64)
-    #define SYS_clock_getres IA32_ONLY(266)  AMD64_ONLY(229)
+  #if defined(X86) || defined(PPC64) || defined(S390)
+    #define SYS_clock_getres AMD64_ONLY(229) IA32_ONLY(266) PPC64_ONLY(247) S390_ONLY(261)
     #define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
   #else
     #warning "SYS_clock_getres not defined for this platform, disabling fast_thread_cpu_time"
@@ -1766,6 +1766,8 @@
   static  Elf32_Half running_arch_code=EM_PPC64;
 #elif  (defined __powerpc__)
   static  Elf32_Half running_arch_code=EM_PPC;
+#elif  (defined AARCH64)
+  static  Elf32_Half running_arch_code=EM_AARCH64;
 #elif  (defined ARM)
   static  Elf32_Half running_arch_code=EM_ARM;
 #elif  (defined S390)
@@ -1780,11 +1782,9 @@
   static  Elf32_Half running_arch_code=EM_MIPS;
 #elif  (defined M68K)
   static  Elf32_Half running_arch_code=EM_68K;
-#elif  (defined AARCH64)
-  static  Elf32_Half running_arch_code=EM_AARCH64;
 #else
     #error Method os::dll_load requires that one of following is defined:\
-         IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K, AARCH64
+        AARCH64, ALPHA, ARM, AMD64, IA32, IA64, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, S390, __sparc
 #endif
 
   // Identify compatability class for VM's architecture and library's architecture
@@ -2192,9 +2192,11 @@
 
 #if defined(AMD64) || defined(IA32) || defined(X32)
 const char* search_string = "model name";
-#elif defined(SPARC)
+#elif defined(PPC64)
 const char* search_string = "cpu";
-#elif defined(PPC64)
+#elif defined(S390)
+const char* search_string = "processor";
+#elif defined(SPARC)
 const char* search_string = "cpu";
 #else
 const char* search_string = "Processor";
@@ -2233,20 +2235,22 @@
   }
   // cpuinfo not found or parsing failed, just print generic string.  The entire
   // /proc/cpuinfo file will be printed later in the file (or enough of it for x86)
-#if defined(AMD64)
+#if   defined(AARCH64)
+  strncpy(cpuinfo, "AArch64", length);
+#elif defined(AMD64)
   strncpy(cpuinfo, "x86_64", length);
+#elif defined(ARM)  // Order wrt. AARCH64 is relevant!
+  strncpy(cpuinfo, "ARM", length);
 #elif defined(IA32)
   strncpy(cpuinfo, "x86_32", length);
 #elif defined(IA64)
   strncpy(cpuinfo, "IA64", length);
+#elif defined(PPC)
+  strncpy(cpuinfo, "PPC64", length);
+#elif defined(S390)
+  strncpy(cpuinfo, "S390", length);
 #elif defined(SPARC)
   strncpy(cpuinfo, "sparcv9", length);
-#elif defined(AARCH64)
-  strncpy(cpuinfo, "AArch64", length);
-#elif defined(ARM)
-  strncpy(cpuinfo, "ARM", length);
-#elif defined(PPC)
-  strncpy(cpuinfo, "PPC64", length);
 #elif defined(ZERO_LIBARCH)
   strncpy(cpuinfo, ZERO_LIBARCH, length);
 #else
@@ -3242,8 +3246,15 @@
   // the processor.
 
 #ifndef ZERO
-  large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M)
-                     ARM32_ONLY(2 * M) PPC_ONLY(4 * M) AARCH64_ONLY(2 * M);
+  large_page_size =
+    AARCH64_ONLY(2 * M)
+    AMD64_ONLY(2 * M)
+    ARM32_ONLY(2 * M)
+    IA32_ONLY(4 * M)
+    IA64_ONLY(256 * M)
+    PPC_ONLY(4 * M)
+    S390_ONLY(1 * M)
+    SPARC_ONLY(4 * M);
 #endif // ZERO
 
   FILE *fp = fopen("/proc/meminfo", "r");
--- a/hotspot/src/share/tools/hsdis/hsdis.c	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/tools/hsdis/hsdis.c	Thu Sep 22 18:23:15 2016 +0200
@@ -468,6 +468,9 @@
 #ifdef LIBARCH_aarch64
   res = "aarch64";
 #endif
+#ifdef LIBARCH_s390x
+  res = "s390:64-bit";
+#endif
   if (res == NULL)
     res = "architecture not set in Makefile!";
   return res;
--- a/hotspot/src/share/vm/code/codeCache.cpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Thu Sep 22 18:23:15 2016 +0200
@@ -547,7 +547,10 @@
 }
 
 bool CodeCache::contains(void *p) {
-  // It should be ok to call contains without holding a lock
+  // S390 uses contains() in current_frame(), which is used before
+  // code cache initialization if NativeMemoryTracking=detail is set.
+  S390_ONLY(if (_heaps == NULL) return false;)
+  // It should be ok to call contains without holding a lock.
   FOR_ALL_HEAPS(heap) {
     if ((*heap)->contains(p)) {
       return true;
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -221,7 +221,7 @@
   }
 
   static int expr_offset_in_bytes(int i) {
-#if !defined(ZERO) && (defined(PPC) || defined(SPARC))
+#if !defined(ZERO) && (defined(PPC) || defined(S390) || defined(SPARC))
     return stackElementSize * i + wordSize;  // both point to one word past TOS
 #else
     return stackElementSize * i;
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -3325,9 +3325,7 @@
           "Stack space (bytes) required for JVM_InvokeMethod to complete")  \
                                                                             \
   /* code cache parameters                                    */            \
-  /* ppc64/tiered compilation has large code-entry alignment. */            \
-  develop(uintx, CodeCacheSegmentSize,                                      \
-          64 PPC64_ONLY(+64) NOT_PPC64(TIERED_ONLY(+64)),                   \
+  develop_pd(uintx, CodeCacheSegmentSize,                                   \
           "Code cache segment size (in bytes) - smallest unit of "          \
           "allocation")                                                     \
           range(1, 1024)                                                    \
--- a/hotspot/src/share/vm/runtime/vm_version.cpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp	Thu Sep 22 18:23:15 2016 +0200
@@ -170,15 +170,16 @@
 #define CPU      "ppc64le"
 #else
 #define CPU      "ppc64"
-#endif
+#endif // PPC64
 #else
-#define CPU      IA32_ONLY("x86")                \
-                 IA64_ONLY("ia64")               \
+#define CPU      AARCH64_ONLY("aarch64")         \
                  AMD64_ONLY("amd64")             \
-                 AARCH64_ONLY("aarch64")         \
+                 IA32_ONLY("x86")                \
+                 IA64_ONLY("ia64")               \
+                 S390_ONLY("s390")               \
                  SPARC_ONLY("sparc")
-#endif //
-#endif
+#endif // !ZERO
+#endif // !CPU
 
 const char *Abstract_VM_Version::vm_platform_string() {
   return OS "-" CPU;
--- a/hotspot/src/share/vm/utilities/macros.hpp	Tue Oct 25 16:42:28 2016 +0200
+++ b/hotspot/src/share/vm/utilities/macros.hpp	Thu Sep 22 18:23:15 2016 +0200
@@ -386,6 +386,14 @@
 #define NOT_AMD64(code) code
 #endif
 
+#ifdef S390
+#define S390_ONLY(code) code
+#define NOT_S390(code)
+#else
+#define S390_ONLY(code)
+#define NOT_S390(code) code
+#endif
+
 #ifdef SPARC
 #define SPARC_ONLY(code) code
 #define NOT_SPARC(code)