changeset 49470:4881673579b7

8199698: Change 8199275 breaks template instantiation for xlC (and potentially other compliers) Reviewed-by: stefank, coleenp
author simonis
date Fri, 16 Mar 2018 19:13:13 +0100
parents 7ea4724a959c
children 6ce398fe53fd
files src/hotspot/share/memory/allocation.cpp src/hotspot/share/memory/allocation.hpp src/hotspot/share/memory/allocation.inline.hpp src/hotspot/share/utilities/globalDefinitions_xlc.hpp
diffstat 4 files changed, 99 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/memory/allocation.cpp	Tue Mar 20 13:40:03 2018 +0530
+++ b/src/hotspot/share/memory/allocation.cpp	Fri Mar 16 19:13:13 2018 +0100
@@ -37,6 +37,39 @@
 #include "services/memTracker.hpp"
 #include "utilities/ostream.hpp"
 
+// allocate using malloc; will fail if no memory available
+char* AllocateHeap(size_t size,
+                   MEMFLAGS flags,
+                   const NativeCallStack& stack,
+                   AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
+  char* p = (char*) os::malloc(size, flags, stack);
+  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
+  }
+  return p;
+}
+
+char* AllocateHeap(size_t size,
+                   MEMFLAGS flags,
+                   AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
+  return AllocateHeap(size, flags, CALLER_PC);
+}
+
+char* ReallocateHeap(char *old,
+                     size_t size,
+                     MEMFLAGS flag,
+                     AllocFailType alloc_failmode) {
+  char* p = (char*) os::realloc(old, size, flag, CALLER_PC);
+  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
+  }
+  return p;
+}
+
+void FreeHeap(void* p) {
+  os::free(p);
+}
+
 void* MetaspaceObj::_shared_metaspace_base = NULL;
 void* MetaspaceObj::_shared_metaspace_top  = NULL;
 
--- a/src/hotspot/share/memory/allocation.hpp	Tue Mar 20 13:40:03 2018 +0530
+++ b/src/hotspot/share/memory/allocation.hpp	Fri Mar 16 19:13:13 2018 +0100
@@ -154,22 +154,61 @@
 class NativeCallStack;
 
 
+char* AllocateHeap(size_t size,
+                   MEMFLAGS flags,
+                   const NativeCallStack& stack,
+                   AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+char* AllocateHeap(size_t size,
+                   MEMFLAGS flags,
+                   AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+
+char* ReallocateHeap(char *old,
+                     size_t size,
+                     MEMFLAGS flag,
+                     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+
+void FreeHeap(void* p);
+
 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
  public:
-  NOINLINE void* operator new(size_t size, const NativeCallStack& stack) throw();
-  NOINLINE void* operator new(size_t size) throw();
-  NOINLINE void* operator new (size_t size, const std::nothrow_t&  nothrow_constant,
-                               const NativeCallStack& stack) throw();
-  NOINLINE void* operator new (size_t size, const std::nothrow_t&  nothrow_constant)
-                               throw();
-  NOINLINE void* operator new [](size_t size, const NativeCallStack& stack) throw();
-  NOINLINE void* operator new [](size_t size) throw();
-  NOINLINE void* operator new [](size_t size, const std::nothrow_t&  nothrow_constant,
-                               const NativeCallStack& stack) throw();
-  NOINLINE void* operator new [](size_t size, const std::nothrow_t&  nothrow_constant)
-                               throw();
-  void  operator delete(void* p);
-  void  operator delete [] (void* p);
+  ALWAYSINLINE void* operator new(size_t size) throw() {
+    return (void*)AllocateHeap(size, F);
+  }
+
+  ALWAYSINLINE void* operator new(size_t size,
+                                  const NativeCallStack& stack) throw() {
+    return (void*)AllocateHeap(size, F, stack);
+  }
+
+  ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&,
+                                  const NativeCallStack& stack) throw() {
+    return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
+  }
+
+  ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&) throw() {
+    return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
+  }
+
+  ALWAYSINLINE void* operator new[](size_t size) throw() {
+    return (void*)AllocateHeap(size, F);
+  }
+
+  ALWAYSINLINE void* operator new[](size_t size,
+                                  const NativeCallStack& stack) throw() {
+    return (void*)AllocateHeap(size, F, stack);
+  }
+
+  ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&,
+                                    const NativeCallStack& stack) throw() {
+    return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
+  }
+
+  ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&) throw() {
+    return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
+  }
+
+  void  operator delete(void* p)     { FreeHeap(p); }
+  void  operator delete [] (void* p) { FreeHeap(p); }
 };
 
 // Base class for objects allocated on the stack only.
--- a/src/hotspot/share/memory/allocation.inline.hpp	Tue Mar 20 13:40:03 2018 +0530
+++ b/src/hotspot/share/memory/allocation.inline.hpp	Fri Mar 16 19:13:13 2018 +0100
@@ -48,83 +48,6 @@
 }
 #endif
 
-// allocate using malloc; will fail if no memory available
-inline char* AllocateHeap(size_t size, MEMFLAGS flags,
-    const NativeCallStack& stack,
-    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
-  char* p = (char*) os::malloc(size, flags, stack);
-  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
-    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
-  }
-  return p;
-}
-
-ALWAYSINLINE char* AllocateHeap(size_t size, MEMFLAGS flags,
-    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
-  return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
-}
-
-ALWAYSINLINE char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
-    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
-  char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
-  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
-    vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
-  }
-  return p;
-}
-
-inline void FreeHeap(void* p) {
-  os::free(p);
-}
-
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
-      const NativeCallStack& stack) throw() {
-  return (void*)AllocateHeap(size, F, stack);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size) throw() {
-  return CHeapObj<F>::operator new(size, CALLER_PC);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
-      const std::nothrow_t&  nothrow_constant, const NativeCallStack& stack) throw() {
-  return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
-  const std::nothrow_t& nothrow_constant) throw() {
-  return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
-      const NativeCallStack& stack) throw() {
-  return CHeapObj<F>::operator new(size, stack);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size)
-  throw() {
-  return CHeapObj<F>::operator new(size, CALLER_PC);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
-  const std::nothrow_t&  nothrow_constant, const NativeCallStack& stack) throw() {
-  return CHeapObj<F>::operator new(size, nothrow_constant, stack);
-}
-
-template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
-  const std::nothrow_t& nothrow_constant) throw() {
-  return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
-}
-
-template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
-    FreeHeap(p);
-}
-
-template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
-    FreeHeap(p);
-}
-
 template <class E>
 size_t MmapArrayAllocator<E>::size_for(size_t length) {
   size_t size = length * sizeof(E);
--- a/src/hotspot/share/utilities/globalDefinitions_xlc.hpp	Tue Mar 20 13:40:03 2018 +0530
+++ b/src/hotspot/share/utilities/globalDefinitions_xlc.hpp	Fri Mar 16 19:13:13 2018 +0100
@@ -152,7 +152,18 @@
 #endif
 
 // Inlining support
-#define NOINLINE
-#define ALWAYSINLINE inline __attribute__((always_inline))
+//
+// Be aware that for function/method declarations, xlC only supports the following
+// syntax (i.e. the attribute must be placed AFTER the function/method declarator):
+//
+//   void* operator new(size_t size) throw() NOINLINE;
+//
+// For function/method defintions, the more common placement BEFORE the
+// function/method declarator seems to be supported as well:
+//
+//   NOINLINE void* CHeapObj<F>::operator new(size_t size) throw() {...}
+
+#define NOINLINE     __attribute__((__noinline__))
+#define ALWAYSINLINE inline __attribute__((__always_inline__))
 
 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP