comparison src/share/vm/runtime/os.hpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents 7432b9db36ff
children 65906dc96aa1
comparison
equal deleted inserted replaced
6174:74533f63b116 6197:d2a62e0f25eb
97 static void init_page_sizes(size_t default_page_size) { 97 static void init_page_sizes(size_t default_page_size) {
98 _page_sizes[0] = default_page_size; 98 _page_sizes[0] = default_page_size;
99 _page_sizes[1] = 0; // sentinel 99 _page_sizes[1] = 0; // sentinel
100 } 100 }
101 101
102 static char* pd_reserve_memory(size_t bytes, char* addr = 0,
103 size_t alignment_hint = 0);
104 static char* pd_attempt_reserve_memory_at(size_t bytes, char* addr);
105 static void pd_split_reserved_memory(char *base, size_t size,
106 size_t split, bool realloc);
107 static bool pd_commit_memory(char* addr, size_t bytes, bool executable = false);
108 static bool pd_commit_memory(char* addr, size_t size, size_t alignment_hint,
109 bool executable = false);
110 static bool pd_uncommit_memory(char* addr, size_t bytes);
111 static bool pd_release_memory(char* addr, size_t bytes);
112
113 static char* pd_map_memory(int fd, const char* file_name, size_t file_offset,
114 char *addr, size_t bytes, bool read_only = false,
115 bool allow_exec = false);
116 static char* pd_remap_memory(int fd, const char* file_name, size_t file_offset,
117 char *addr, size_t bytes, bool read_only,
118 bool allow_exec);
119 static bool pd_unmap_memory(char *addr, size_t bytes);
120 static void pd_free_memory(char *addr, size_t bytes, size_t alignment_hint);
121 static void pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint);
122
123
102 public: 124 public:
103 static void init(void); // Called before command line parsing 125 static void init(void); // Called before command line parsing
104 static jint init_2(void); // Called after command line parsing 126 static jint init_2(void); // Called after command line parsing
105 static void init_globals(void) { // Called from init_globals() in init.cpp 127 static void init_globals(void) { // Called from init_globals() in init.cpp
106 init_globals_ext(); 128 init_globals_ext();
234 static char* reserve_memory(size_t bytes, char* addr = 0, 256 static char* reserve_memory(size_t bytes, char* addr = 0,
235 size_t alignment_hint = 0); 257 size_t alignment_hint = 0);
236 static char* attempt_reserve_memory_at(size_t bytes, char* addr); 258 static char* attempt_reserve_memory_at(size_t bytes, char* addr);
237 static void split_reserved_memory(char *base, size_t size, 259 static void split_reserved_memory(char *base, size_t size,
238 size_t split, bool realloc); 260 size_t split, bool realloc);
239 static bool commit_memory(char* addr, size_t bytes, 261 static bool commit_memory(char* addr, size_t bytes, bool executable = false);
240 bool executable = false);
241 static bool commit_memory(char* addr, size_t size, size_t alignment_hint, 262 static bool commit_memory(char* addr, size_t size, size_t alignment_hint,
242 bool executable = false); 263 bool executable = false);
243 static bool uncommit_memory(char* addr, size_t bytes); 264 static bool uncommit_memory(char* addr, size_t bytes);
244 static bool release_memory(char* addr, size_t bytes); 265 static bool release_memory(char* addr, size_t bytes);
245 266
248 bool is_committed = true); 269 bool is_committed = true);
249 270
250 static bool guard_memory(char* addr, size_t bytes); 271 static bool guard_memory(char* addr, size_t bytes);
251 static bool unguard_memory(char* addr, size_t bytes); 272 static bool unguard_memory(char* addr, size_t bytes);
252 static bool create_stack_guard_pages(char* addr, size_t bytes); 273 static bool create_stack_guard_pages(char* addr, size_t bytes);
274 static bool pd_create_stack_guard_pages(char* addr, size_t bytes);
253 static bool remove_stack_guard_pages(char* addr, size_t bytes); 275 static bool remove_stack_guard_pages(char* addr, size_t bytes);
254 276
255 static char* map_memory(int fd, const char* file_name, size_t file_offset, 277 static char* map_memory(int fd, const char* file_name, size_t file_offset,
256 char *addr, size_t bytes, bool read_only = false, 278 char *addr, size_t bytes, bool read_only = false,
257 bool allow_exec = false); 279 bool allow_exec = false);
571 static int allocate_thread_local_storage(); 593 static int allocate_thread_local_storage();
572 static void thread_local_storage_at_put(int index, void* value); 594 static void thread_local_storage_at_put(int index, void* value);
573 static void* thread_local_storage_at(int index); 595 static void* thread_local_storage_at(int index);
574 static void free_thread_local_storage(int index); 596 static void free_thread_local_storage(int index);
575 597
598 // Stack walk
599 static address get_caller_pc(int n = 0);
600
576 // General allocation (must be MT-safe) 601 // General allocation (must be MT-safe)
577 static void* malloc (size_t size); 602 static void* malloc (size_t size, MEMFLAGS flags, address caller_pc = 0);
578 static void* realloc (void *memblock, size_t size); 603 static void* realloc (void *memblock, size_t size, MEMFLAGS flags, address caller_pc = 0);
579 static void free (void *memblock); 604 static void free (void *memblock, MEMFLAGS flags = mtNone);
580 static bool check_heap(bool force = false); // verify C heap integrity 605 static bool check_heap(bool force = false); // verify C heap integrity
581 static char* strdup(const char *); // Like strdup 606 static char* strdup(const char *, MEMFLAGS flags = mtInternal); // Like strdup
582 607
583 #ifndef PRODUCT 608 #ifndef PRODUCT
584 static julong num_mallocs; // # of calls to malloc/realloc 609 static julong num_mallocs; // # of calls to malloc/realloc
585 static julong alloc_bytes; // # of bytes allocated 610 static julong alloc_bytes; // # of bytes allocated
586 static julong num_frees; // # of calls to free 611 static julong num_frees; // # of calls to free