comparison src/share/vm/services/memTracker.hpp @ 6882:716c64bda5ba

7199092: NMT: NMT needs to deal overlapped virtual memory ranges Summary: Enhanced virtual memory tracking to track committed regions as well as reserved regions, so NMT now can generate virtual memory map. Reviewed-by: acorn, coleenp
author zgu
date Fri, 19 Oct 2012 21:40:07 -0400
parents fb19af007ffc
children fb3190e77d3c
comparison
equal deleted inserted replaced
6879:8ebcedb7604d 6882:716c64bda5ba
111 111
112 #ifdef SOLARIS 112 #ifdef SOLARIS
113 #include "thread_solaris.inline.hpp" 113 #include "thread_solaris.inline.hpp"
114 #endif 114 #endif
115 115
116 #ifdef _DEBUG 116 extern bool NMT_track_callsite;
117 #define DEBUG_CALLER_PC os::get_caller_pc(3) 117
118 #ifdef ASSERT
119 #define DEBUG_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
118 #else 120 #else
119 #define DEBUG_CALLER_PC 0 121 #define DEBUG_CALLER_PC 0
120 #endif 122 #endif
121 123
122 // The thread closure walks threads to collect per-thread 124 // The thread closure walks threads to collect per-thread
259 static void start(); 261 static void start();
260 262
261 // record a 'malloc' call 263 // record a 'malloc' call
262 static inline void record_malloc(address addr, size_t size, MEMFLAGS flags, 264 static inline void record_malloc(address addr, size_t size, MEMFLAGS flags,
263 address pc = 0, Thread* thread = NULL) { 265 address pc = 0, Thread* thread = NULL) {
264 if (NMT_CAN_TRACK(flags)) { 266 if (is_on() && NMT_CAN_TRACK(flags)) {
265 assert(size > 0, "Sanity check"); 267 assert(size > 0, "Sanity check");
266 create_memory_record(addr, (flags|MemPointerRecord::malloc_tag()), size, pc, thread); 268 create_memory_record(addr, (flags|MemPointerRecord::malloc_tag()), size, pc, thread);
267 } 269 }
268 } 270 }
269 // record a 'free' call 271 // record a 'free' call
273 } 275 }
274 } 276 }
275 // record a 'realloc' call 277 // record a 'realloc' call
276 static inline void record_realloc(address old_addr, address new_addr, size_t size, 278 static inline void record_realloc(address old_addr, address new_addr, size_t size,
277 MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { 279 MEMFLAGS flags, address pc = 0, Thread* thread = NULL) {
278 if (is_on()) { 280 if (is_on() && NMT_CAN_TRACK(flags)) {
279 assert(size > 0, "Sanity check"); 281 assert(size > 0, "Sanity check");
280 record_free(old_addr, flags, thread); 282 record_free(old_addr, flags, thread);
281 record_malloc(new_addr, size, flags, pc, thread); 283 record_malloc(new_addr, size, flags, pc, thread);
282 } 284 }
283 } 285 }
315 } 317 }
316 318
317 static inline void release_thread_stack(address addr, size_t size, Thread* thr) { 319 static inline void release_thread_stack(address addr, size_t size, Thread* thr) {
318 if (is_on()) { 320 if (is_on()) {
319 assert(size > 0 && thr != NULL, "Sanity check"); 321 assert(size > 0 && thr != NULL, "Sanity check");
322 assert(!thr->is_Java_thread(), "too early");
320 create_memory_record(addr, MemPointerRecord::virtual_memory_uncommit_tag() | mtThreadStack, 323 create_memory_record(addr, MemPointerRecord::virtual_memory_uncommit_tag() | mtThreadStack,
321 size, DEBUG_CALLER_PC, thr); 324 size, DEBUG_CALLER_PC, thr);
322 create_memory_record(addr, MemPointerRecord::virtual_memory_release_tag() | mtThreadStack, 325 create_memory_record(addr, MemPointerRecord::virtual_memory_release_tag() | mtThreadStack,
323 size, DEBUG_CALLER_PC, thr); 326 size, DEBUG_CALLER_PC, thr);
324 } 327 }
325 } 328 }
326 329
327 // record a virtual memory 'commit' call 330 // record a virtual memory 'commit' call
328 static inline void record_virtual_memory_commit(address addr, size_t size, 331 static inline void record_virtual_memory_commit(address addr, size_t size,
329 address pc = 0, Thread* thread = NULL) { 332 address pc, Thread* thread = NULL) {
330 if (is_on()) { 333 if (is_on()) {
331 assert(size > 0, "Sanity check"); 334 assert(size > 0, "Sanity check");
332 create_memory_record(addr, MemPointerRecord::virtual_memory_commit_tag(), 335 create_memory_record(addr, MemPointerRecord::virtual_memory_commit_tag(),
333 size, DEBUG_CALLER_PC, thread); 336 size, pc, thread);
334 } 337 }
335 } 338 }
336 339
337 // record a virtual memory 'uncommit' call 340 // record a virtual memory 'uncommit' call
338 static inline void record_virtual_memory_uncommit(address addr, size_t size, 341 static inline void record_virtual_memory_uncommit(address addr, size_t size,