Mercurial > hg > graal-jvmci-8
comparison src/share/vm/services/memSnapshot.cpp @ 6937:69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
Summary: NMT should allow overlapping committed regions as long as they belong to the same reserved region
Reviewed-by: dholmes, coleenp
author | zgu |
---|---|
date | Mon, 05 Nov 2012 15:30:22 -0500 |
parents | 716c64bda5ba |
children | ed8b1e39ff4f fb3190e77d3c |
comparison
equal
deleted
inserted
replaced
6917:e81fbc04a942 | 6937:69ad7823b1ca |
---|---|
29 #include "services/memPtr.hpp" | 29 #include "services/memPtr.hpp" |
30 #include "services/memPtrArray.hpp" | 30 #include "services/memPtrArray.hpp" |
31 #include "services/memSnapshot.hpp" | 31 #include "services/memSnapshot.hpp" |
32 #include "services/memTracker.hpp" | 32 #include "services/memTracker.hpp" |
33 | 33 |
34 #ifdef ASSERT | |
35 | |
36 void decode_pointer_record(MemPointerRecord* rec) { | |
37 tty->print("Pointer: [" PTR_FORMAT " - " PTR_FORMAT "] size = %d bytes", rec->addr(), | |
38 rec->addr() + rec->size(), (int)rec->size()); | |
39 tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); | |
40 if (rec->is_vm_pointer()) { | |
41 if (rec->is_allocation_record()) { | |
42 tty->print_cr(" (reserve)"); | |
43 } else if (rec->is_commit_record()) { | |
44 tty->print_cr(" (commit)"); | |
45 } else if (rec->is_uncommit_record()) { | |
46 tty->print_cr(" (uncommit)"); | |
47 } else if (rec->is_deallocation_record()) { | |
48 tty->print_cr(" (release)"); | |
49 } else { | |
50 tty->print_cr(" (tag)"); | |
51 } | |
52 } else { | |
53 if (rec->is_arena_size_record()) { | |
54 tty->print_cr(" (arena size)"); | |
55 } else if (rec->is_allocation_record()) { | |
56 tty->print_cr(" (malloc)"); | |
57 } else { | |
58 tty->print_cr(" (free)"); | |
59 } | |
60 } | |
61 if (MemTracker::track_callsite()) { | |
62 char buf[1024]; | |
63 address pc = ((MemPointerRecordEx*)rec)->pc(); | |
64 if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { | |
65 tty->print_cr("\tfrom %s", buf); | |
66 } else { | |
67 tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); | |
68 } | |
69 } | |
70 } | |
71 | |
72 void decode_vm_region_record(VMMemRegion* rec) { | |
73 tty->print("VM Region [" PTR_FORMAT " - " PTR_FORMAT "]", rec->addr(), | |
74 rec->addr() + rec->size()); | |
75 tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); | |
76 if (rec->is_allocation_record()) { | |
77 tty->print_cr(" (reserved)"); | |
78 } else if (rec->is_commit_record()) { | |
79 tty->print_cr(" (committed)"); | |
80 } else { | |
81 ShouldNotReachHere(); | |
82 } | |
83 if (MemTracker::track_callsite()) { | |
84 char buf[1024]; | |
85 address pc = ((VMMemRegionEx*)rec)->pc(); | |
86 if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { | |
87 tty->print_cr("\tfrom %s", buf); | |
88 } else { | |
89 tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); | |
90 } | |
91 | |
92 } | |
93 } | |
94 | |
95 #endif | |
96 | |
34 | 97 |
35 bool VMMemPointerIterator::insert_record(MemPointerRecord* rec) { | 98 bool VMMemPointerIterator::insert_record(MemPointerRecord* rec) { |
36 VMMemRegionEx new_rec; | 99 VMMemRegionEx new_rec; |
37 assert(rec->is_allocation_record() || rec->is_commit_record(), | 100 assert(rec->is_allocation_record() || rec->is_commit_record(), |
38 "Sanity check"); | 101 "Sanity check"); |
71 // duplicated records | 134 // duplicated records |
72 if (cur->is_same_region(rec)) { | 135 if (cur->is_same_region(rec)) { |
73 return true; | 136 return true; |
74 } | 137 } |
75 assert(cur->base() > rec->addr(), "Just check: locate()"); | 138 assert(cur->base() > rec->addr(), "Just check: locate()"); |
76 assert(rec->addr() + rec->size() <= cur->base(), "Can not overlap"); | 139 assert(!cur->overlaps_region(rec), "overlapping reserved regions"); |
77 return insert_record(rec); | 140 return insert_record(rec); |
78 } | 141 } |
79 | 142 |
80 // we do consolidate committed regions | 143 // we do consolidate committed regions |
81 bool VMMemPointerIterator::add_committed_region(MemPointerRecord* rec) { | 144 bool VMMemPointerIterator::add_committed_region(MemPointerRecord* rec) { |
82 assert(rec->is_commit_record(), "Sanity check"); | 145 assert(rec->is_commit_record(), "Sanity check"); |
83 VMMemRegion* cur; | 146 VMMemRegion* reserved_rgn = (VMMemRegion*)current(); |
84 cur = (VMMemRegion*)current(); | 147 assert(reserved_rgn->is_reserved_region() && reserved_rgn->contains_region(rec), |
85 assert(cur->is_reserved_region() && cur->contains_region(rec), | |
86 "Sanity check"); | 148 "Sanity check"); |
87 | 149 |
88 // thread's native stack is always marked as "committed", ignore | 150 // thread's native stack is always marked as "committed", ignore |
89 // the "commit" operation for creating stack guard pages | 151 // the "commit" operation for creating stack guard pages |
90 if (FLAGS_TO_MEMORY_TYPE(cur->flags()) == mtThreadStack && | 152 if (FLAGS_TO_MEMORY_TYPE(reserved_rgn->flags()) == mtThreadStack && |
91 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { | 153 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { |
92 return true; | 154 return true; |
93 } | 155 } |
94 | 156 |
95 cur = (VMMemRegion*)next(); | 157 // if the reserved region has any committed regions |
96 while (cur != NULL && cur->is_committed_region()) { | 158 VMMemRegion* committed_rgn = (VMMemRegion*)next(); |
159 while (committed_rgn != NULL && committed_rgn->is_committed_region()) { | |
97 // duplicated commit records | 160 // duplicated commit records |
98 if(cur->contains_region(rec)) { | 161 if(committed_rgn->contains_region(rec)) { |
99 return true; | 162 return true; |
100 } | 163 } else if (committed_rgn->overlaps_region(rec)) { |
101 if (cur->base() > rec->addr()) { | 164 // overlaps front part |
102 // committed regions can not overlap | 165 if (rec->addr() < committed_rgn->addr()) { |
103 assert(rec->addr() + rec->size() <= cur->base(), "Can not overlap"); | 166 committed_rgn->expand_region(rec->addr(), |
104 if (rec->addr() + rec->size() == cur->base()) { | 167 committed_rgn->addr() - rec->addr()); |
105 cur->expand_region(rec->addr(), rec->size()); | |
106 return true; | |
107 } else { | 168 } else { |
108 return insert_record(rec); | 169 // overlaps tail part |
109 } | 170 address committed_rgn_end = committed_rgn->addr() + |
110 } else if (cur->base() + cur->size() == rec->addr()) { | 171 committed_rgn->size(); |
111 cur->expand_region(rec->addr(), rec->size()); | 172 assert(committed_rgn_end < rec->addr() + rec->size(), |
173 "overlap tail part"); | |
174 committed_rgn->expand_region(committed_rgn_end, | |
175 (rec->addr() + rec->size()) - committed_rgn_end); | |
176 } | |
177 } else if (committed_rgn->base() + committed_rgn->size() == rec->addr()) { | |
178 // adjunct each other | |
179 committed_rgn->expand_region(rec->addr(), rec->size()); | |
112 VMMemRegion* next_reg = (VMMemRegion*)next(); | 180 VMMemRegion* next_reg = (VMMemRegion*)next(); |
113 // see if we can consolidate next committed region | 181 // see if we can consolidate next committed region |
114 if (next_reg != NULL && next_reg->is_committed_region() && | 182 if (next_reg != NULL && next_reg->is_committed_region() && |
115 next_reg->base() == cur->base() + cur->size()) { | 183 next_reg->base() == committed_rgn->base() + committed_rgn->size()) { |
116 cur->expand_region(next_reg->base(), next_reg->size()); | 184 committed_rgn->expand_region(next_reg->base(), next_reg->size()); |
185 // delete merged region | |
117 remove(); | 186 remove(); |
118 } | 187 } |
119 return true; | 188 return true; |
120 } | 189 } else if (committed_rgn->base() > rec->addr()) { |
121 cur = (VMMemRegion*)next(); | 190 // found the location, insert this committed region |
191 return insert_record(rec); | |
192 } | |
193 committed_rgn = (VMMemRegion*)next(); | |
122 } | 194 } |
123 return insert_record(rec); | 195 return insert_record(rec); |
124 } | 196 } |
125 | 197 |
126 bool VMMemPointerIterator::remove_uncommitted_region(MemPointerRecord* rec) { | 198 bool VMMemPointerIterator::remove_uncommitted_region(MemPointerRecord* rec) { |