Mercurial > hg > truffle
comparison src/share/vm/services/memBaseline.cpp @ 6979:fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
Summary: Fixed NMT that miscounted arena memory when it is used as value or stack object.
Reviewed-by: acorn, coleenp
author | zgu |
---|---|
date | Fri, 09 Nov 2012 19:24:31 -0500 |
parents | 716c64bda5ba |
children | ecd24264898b |
comparison
equal
deleted
inserted
replaced
6938:8940ddc1036f | 6979:fb3190e77d3c |
---|---|
113 size_t used_arena_size = 0; | 113 size_t used_arena_size = 0; |
114 int index; | 114 int index; |
115 while (malloc_ptr != NULL) { | 115 while (malloc_ptr != NULL) { |
116 index = flag2index(FLAGS_TO_MEMORY_TYPE(malloc_ptr->flags())); | 116 index = flag2index(FLAGS_TO_MEMORY_TYPE(malloc_ptr->flags())); |
117 size_t size = malloc_ptr->size(); | 117 size_t size = malloc_ptr->size(); |
118 _total_malloced += size; | 118 if (malloc_ptr->is_arena_memory_record()) { |
119 _malloc_data[index].inc(size); | 119 // We do have anonymous arenas, they are either used as value objects, |
120 if (MemPointerRecord::is_arena_record(malloc_ptr->flags())) { | 120 // which are embedded inside other objects, or used as stack objects. |
121 // see if arena size record present | 121 _arena_data[index].inc(size); |
122 MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next(); | 122 used_arena_size += size; |
123 if (MemPointerRecord::is_arena_size_record(next_malloc_ptr->flags())) { | 123 } else { |
124 assert(next_malloc_ptr->is_size_record_of_arena(malloc_ptr), "arena records do not match"); | 124 _total_malloced += size; |
125 size = next_malloc_ptr->size(); | 125 _malloc_data[index].inc(size); |
126 _arena_data[index].inc(size); | 126 if (malloc_ptr->is_arena_record()) { |
127 used_arena_size += size; | 127 // see if arena memory record present |
128 malloc_itr.next(); | 128 MemPointerRecord* next_malloc_ptr = (MemPointerRecordEx*)malloc_itr.peek_next(); |
129 if (next_malloc_ptr->is_arena_memory_record()) { | |
130 assert(next_malloc_ptr->is_memory_record_of_arena(malloc_ptr), | |
131 "Arena records do not match"); | |
132 size = next_malloc_ptr->size(); | |
133 _arena_data[index].inc(size); | |
134 used_arena_size += size; | |
135 malloc_itr.next(); | |
136 } | |
129 } | 137 } |
130 } | 138 } |
131 malloc_ptr = (MemPointerRecordEx*)malloc_itr.next(); | 139 malloc_ptr = (MemPointerRecordEx*)malloc_itr.next(); |
132 } | 140 } |
133 | 141 |
191 malloc_data->sort((FN_SORT)malloc_sort_by_pc); | 199 malloc_data->sort((FN_SORT)malloc_sort_by_pc); |
192 bool ret = true; | 200 bool ret = true; |
193 | 201 |
194 // baseline memory that is totaled over 1 KB | 202 // baseline memory that is totaled over 1 KB |
195 while (malloc_ptr != NULL) { | 203 while (malloc_ptr != NULL) { |
196 if (!MemPointerRecord::is_arena_size_record(malloc_ptr->flags())) { | 204 if (!MemPointerRecord::is_arena_memory_record(malloc_ptr->flags())) { |
197 // skip thread stacks | 205 // skip thread stacks |
198 if (!IS_MEMORY_TYPE(malloc_ptr->flags(), mtThreadStack)) { | 206 if (!IS_MEMORY_TYPE(malloc_ptr->flags(), mtThreadStack)) { |
199 if (malloc_callsite.addr() != malloc_ptr->pc()) { | 207 if (malloc_callsite.addr() != malloc_ptr->pc()) { |
200 if ((malloc_callsite.amount()/K) > 0) { | 208 if ((malloc_callsite.amount()/K) > 0) { |
201 if (!_malloc_cs->append(&malloc_callsite)) { | 209 if (!_malloc_cs->append(&malloc_callsite)) { |