inlining AllocateHeap()

Yasumasa Suenaga yasuenag at gmail.com
Thu Mar 12 11:58:15 UTC 2015


Hi all,

I tried to use NMT with details option on OpenJDK7 on RHEL6.6, but I got
address at AllocateHeap() as malloc() caller.

I checked symbol in libjvm.so in OracleJDK8u40 Linux x64, it has
AllocateHeap()
symbol.

AllocateHeap() is defined as inline function, and it gives CURRENT_PC to
os::malloc(). I guess that implementation expects AllocateHeap() will be
inlined.

It may occur with GCC (g++) optimization only, however I want to fix it to
analyze native memory with NMT on Linux.

I applied patch as below. This patch makes AllocateHeap() as inline
function.
--------------
diff -r af3b0db91659 src/share/vm/memory/allocation.inline.hpp
--- a/src/share/vm/memory/allocation.inline.hpp Mon Mar 09 09:30:16 2015
-0700
+++ b/src/share/vm/memory/allocation.inline.hpp Thu Mar 12 20:45:57 2015
+0900
@@ -62,11 +62,18 @@
   }
   return p;
}
+
+#ifdef __GNUC__
+__attribute__((always_inline))
+#endif
inline char* AllocateHeap(size_t size, MEMFLAGS flags,
     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
   return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
}

+#ifdef __GNUC__
+__attribute__((always_inline))
+#endif
inline 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 this patch is accepted, I will file it to JBS and will upload webrev.

Thanks,

Yasumasa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20150312/3367f162/attachment.html>


More information about the serviceability-dev mailing list