Mercurial > hg > graal-jvmci-8
annotate src/share/vm/services/memSnapshot.cpp @ 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 | 33143ee07800 |
children | 69ad7823b1ca |
rev | line source |
---|---|
6197 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #include "precompiled.hpp" | |
26 #include "runtime/mutexLocker.hpp" | |
27 #include "utilities/decoder.hpp" | |
28 #include "services/memBaseline.hpp" | |
29 #include "services/memPtr.hpp" | |
30 #include "services/memPtrArray.hpp" | |
31 #include "services/memSnapshot.hpp" | |
32 #include "services/memTracker.hpp" | |
33 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
34 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
35 bool VMMemPointerIterator::insert_record(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
36 VMMemRegionEx new_rec; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
37 assert(rec->is_allocation_record() || rec->is_commit_record(), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
38 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
39 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
40 new_rec.init((MemPointerRecordEx*)rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
41 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
42 new_rec.init(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
43 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
44 return insert(&new_rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
45 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
46 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
47 bool VMMemPointerIterator::insert_record_after(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
48 VMMemRegionEx new_rec; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
49 assert(rec->is_allocation_record() || rec->is_commit_record(), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
50 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
51 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
52 new_rec.init((MemPointerRecordEx*)rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
53 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
54 new_rec.init(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
55 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
56 return insert_after(&new_rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
57 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
58 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
59 // we don't consolidate reserved regions, since they may be categorized |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
60 // in different types. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
61 bool VMMemPointerIterator::add_reserved_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
62 assert(rec->is_allocation_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
63 VMMemRegion* cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
64 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
65 // we don't have anything yet |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
66 if (cur == NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
67 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
68 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
69 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
70 assert(cur->is_reserved_region(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
71 // duplicated records |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
72 if (cur->is_same_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
73 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
74 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
75 assert(cur->base() > rec->addr(), "Just check: locate()"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
76 assert(rec->addr() + rec->size() <= cur->base(), "Can not overlap"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
77 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
78 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
79 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
80 // we do consolidate committed regions |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
81 bool VMMemPointerIterator::add_committed_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
82 assert(rec->is_commit_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
83 VMMemRegion* cur; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
84 cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
85 assert(cur->is_reserved_region() && cur->contains_region(rec), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
86 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
87 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
88 // thread's native stack is always marked as "committed", ignore |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
89 // the "commit" operation for creating stack guard pages |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
90 if (FLAGS_TO_MEMORY_TYPE(cur->flags()) == mtThreadStack && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
91 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
92 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
93 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
94 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
95 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
96 while (cur != NULL && cur->is_committed_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
97 // duplicated commit records |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
98 if(cur->contains_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
99 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
100 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
101 if (cur->base() > rec->addr()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
102 // committed regions can not overlap |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
103 assert(rec->addr() + rec->size() <= cur->base(), "Can not overlap"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
104 if (rec->addr() + rec->size() == cur->base()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
105 cur->expand_region(rec->addr(), rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
106 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
107 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
108 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
109 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
110 } else if (cur->base() + cur->size() == rec->addr()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
111 cur->expand_region(rec->addr(), rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
112 VMMemRegion* next_reg = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
113 // see if we can consolidate next committed region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
114 if (next_reg != NULL && next_reg->is_committed_region() && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
115 next_reg->base() == cur->base() + cur->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
116 cur->expand_region(next_reg->base(), next_reg->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
117 remove(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
118 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
119 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
120 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
121 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
122 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
123 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
124 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
125 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
126 bool VMMemPointerIterator::remove_uncommitted_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
127 assert(rec->is_uncommit_record(), "sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
128 VMMemRegion* cur; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
129 cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
130 assert(cur->is_reserved_region() && cur->contains_region(rec), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
131 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
132 // thread's native stack is always marked as "committed", ignore |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
133 // the "commit" operation for creating stack guard pages |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
134 if (FLAGS_TO_MEMORY_TYPE(cur->flags()) == mtThreadStack && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
135 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
136 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
137 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
138 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
139 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
140 while (cur != NULL && cur->is_committed_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
141 // region already uncommitted, must be due to duplicated record |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
142 if (cur->addr() >= rec->addr() + rec->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
143 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
144 } else if (cur->contains_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
145 // uncommit whole region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
146 if (cur->is_same_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
147 remove(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
148 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
149 } else if (rec->addr() == cur->addr() || |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
150 rec->addr() + rec->size() == cur->addr() + cur->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
151 // uncommitted from either end of current memory region. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
152 cur->exclude_region(rec->addr(), rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
153 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
154 } else { // split the committed region and release the middle |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
155 address high_addr = cur->addr() + cur->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
156 size_t sz = high_addr - rec->addr(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
157 cur->exclude_region(rec->addr(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
158 sz = high_addr - (rec->addr() + rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
159 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
160 MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz, |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
161 ((VMMemRegionEx*)cur)->pc()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
162 return insert_record_after(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
163 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
164 MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
165 return insert_record_after(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
166 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
167 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
168 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
169 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
170 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
171 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
172 // we may not find committed record due to duplicated records |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
173 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
174 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
175 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
176 bool VMMemPointerIterator::remove_released_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
177 assert(rec->is_deallocation_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
178 VMMemRegion* cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
179 assert(cur->is_reserved_region() && cur->contains_region(rec), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
180 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
181 #ifdef ASSERT |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
182 VMMemRegion* next_reg = (VMMemRegion*)peek_next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
183 // should not have any committed memory in this reserved region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
184 assert(next_reg == NULL || !next_reg->is_committed_region(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
185 #endif |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
186 if (rec->is_same_region(cur)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
187 remove(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
188 } else if (rec->addr() == cur->addr() || |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
189 rec->addr() + rec->size() == cur->addr() + cur->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
190 // released region is at either end of this region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
191 cur->exclude_region(rec->addr(), rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
192 } else { // split the reserved region and release the middle |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
193 address high_addr = cur->addr() + cur->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
194 size_t sz = high_addr - rec->addr(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
195 cur->exclude_region(rec->addr(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
196 sz = high_addr - rec->addr() - rec->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
197 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
198 MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz, |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
199 ((VMMemRegionEx*)cur)->pc()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
200 return insert_reserved_region(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
201 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
202 MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
203 return insert_reserved_region(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
204 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
205 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
206 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
207 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
208 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
209 bool VMMemPointerIterator::insert_reserved_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
210 // skip all 'commit' records associated with previous reserved region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
211 VMMemRegion* p = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
212 while (p != NULL && p->is_committed_region() && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
213 p->base() + p->size() < rec->addr()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
214 p = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
215 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
216 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
217 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
218 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
219 bool VMMemPointerIterator::split_reserved_region(VMMemRegion* rgn, address new_rgn_addr, size_t new_rgn_size) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
220 assert(rgn->contains_region(new_rgn_addr, new_rgn_size), "Not fully contained"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
221 address pc = (MemTracker::track_callsite() ? ((VMMemRegionEx*)rgn)->pc() : NULL); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
222 if (rgn->base() == new_rgn_addr) { // new region is at the beginning of the region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
223 size_t sz = rgn->size() - new_rgn_size; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
224 // the original region becomes 'new' region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
225 rgn->exclude_region(new_rgn_addr + new_rgn_size, sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
226 // remaining becomes next region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
227 MemPointerRecordEx next_rgn(new_rgn_addr + new_rgn_size, rgn->flags(), sz, pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
228 return insert_reserved_region(&next_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
229 } else if (rgn->base() + rgn->size() == new_rgn_addr + new_rgn_size) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
230 rgn->exclude_region(new_rgn_addr, new_rgn_size); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
231 MemPointerRecordEx next_rgn(new_rgn_addr, rgn->flags(), new_rgn_size, pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
232 return insert_reserved_region(&next_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
233 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
234 // the orginal region will be split into three |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
235 address rgn_high_addr = rgn->base() + rgn->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
236 // first region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
237 rgn->exclude_region(new_rgn_addr, (rgn_high_addr - new_rgn_addr)); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
238 // the second region is the new region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
239 MemPointerRecordEx new_rgn(new_rgn_addr, rgn->flags(), new_rgn_size, pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
240 if (!insert_reserved_region(&new_rgn)) return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
241 // the remaining region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
242 MemPointerRecordEx rem_rgn(new_rgn_addr + new_rgn_size, rgn->flags(), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
243 rgn_high_addr - (new_rgn_addr + new_rgn_size), pc); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
244 return insert_reserved_region(&rem_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
245 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
246 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
247 |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
248 static int sort_in_seq_order(const void* p1, const void* p2) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
249 assert(p1 != NULL && p2 != NULL, "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
250 const MemPointerRecord* mp1 = (MemPointerRecord*)p1; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
251 const MemPointerRecord* mp2 = (MemPointerRecord*)p2; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
252 return (mp1->seq() - mp2->seq()); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
253 } |
6197 | 254 |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
255 bool StagingArea::init() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
256 if (MemTracker::track_callsite()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
257 _malloc_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecordEx>(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
258 _vm_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecordEx>(); |
6197 | 259 } else { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
260 _malloc_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecord>(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
261 _vm_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecord>(); |
6197 | 262 } |
263 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
264 if (_malloc_data != NULL && _vm_data != NULL && |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
265 !_malloc_data->out_of_memory() && |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
266 !_vm_data->out_of_memory()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
267 return true; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
268 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
269 if (_malloc_data != NULL) delete _malloc_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
270 if (_vm_data != NULL) delete _vm_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
271 _malloc_data = NULL; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
272 _vm_data = NULL; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
273 return false; |
6197 | 274 } |
275 } | |
276 | |
277 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
278 VMRecordIterator StagingArea::virtual_memory_record_walker() { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
279 MemPointerArray* arr = vm_data(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
280 // sort into seq number order |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
281 arr->sort((FN_SORT)sort_in_seq_order); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
282 return VMRecordIterator(arr); |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
283 } |
6197 | 284 |
285 | |
286 MemSnapshot::MemSnapshot() { | |
287 if (MemTracker::track_callsite()) { | |
288 _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl<MemPointerRecordEx>(); | |
289 _vm_ptrs = new (std::nothrow)MemPointerArrayImpl<VMMemRegionEx>(64, true); | |
290 } else { | |
291 _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl<MemPointerRecord>(); | |
292 _vm_ptrs = new (std::nothrow)MemPointerArrayImpl<VMMemRegion>(64, true); | |
293 } | |
294 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
295 _staging_area.init(); |
6232
f1f45dddb0bd
7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents:
6197
diff
changeset
|
296 _lock = new (std::nothrow) Mutex(Monitor::max_nonleaf - 1, "memSnapshotLock"); |
6197 | 297 NOT_PRODUCT(_untracked_count = 0;) |
298 } | |
299 | |
300 MemSnapshot::~MemSnapshot() { | |
301 assert(MemTracker::shutdown_in_progress(), "native memory tracking still on"); | |
302 { | |
303 MutexLockerEx locker(_lock); | |
304 if (_alloc_ptrs != NULL) { | |
305 delete _alloc_ptrs; | |
306 _alloc_ptrs = NULL; | |
307 } | |
308 | |
309 if (_vm_ptrs != NULL) { | |
310 delete _vm_ptrs; | |
311 _vm_ptrs = NULL; | |
312 } | |
313 } | |
314 | |
315 if (_lock != NULL) { | |
316 delete _lock; | |
317 _lock = NULL; | |
318 } | |
319 } | |
320 | |
321 void MemSnapshot::copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src) { | |
322 assert(dest != NULL && src != NULL, "Just check"); | |
323 assert(dest->addr() == src->addr(), "Just check"); | |
324 | |
325 MEMFLAGS flags = dest->flags(); | |
326 | |
327 if (MemTracker::track_callsite()) { | |
328 *(MemPointerRecordEx*)dest = *(MemPointerRecordEx*)src; | |
329 } else { | |
330 *dest = *src; | |
331 } | |
332 } | |
333 | |
334 | |
335 // merge a per-thread memory recorder to the staging area | |
336 bool MemSnapshot::merge(MemRecorder* rec) { | |
337 assert(rec != NULL && !rec->out_of_memory(), "Just check"); | |
338 | |
339 SequencedRecordIterator itr(rec->pointer_itr()); | |
340 | |
341 MutexLockerEx lock(_lock, true); | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
342 MemPointerIterator malloc_staging_itr(_staging_area.malloc_data()); |
6197 | 343 MemPointerRecord *p1, *p2; |
344 p1 = (MemPointerRecord*) itr.current(); | |
345 while (p1 != NULL) { | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
346 if (p1->is_vm_pointer()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
347 // we don't do anything with virtual memory records during merge |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
348 if (!_staging_area.vm_data()->append(p1)) { |
6197 | 349 return false; |
350 } | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
351 } else { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
352 // locate matched record and/or also position the iterator to proper |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
353 // location for this incoming record. |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
354 p2 = (MemPointerRecord*)malloc_staging_itr.locate(p1->addr()); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
355 // we have not seen this memory block, so just add to staging area |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
356 if (p2 == NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
357 if (!malloc_staging_itr.insert(p1)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
358 return false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
359 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
360 } else if (p1->addr() == p2->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
361 MemPointerRecord* staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
362 // a memory block can have many tagging records, find right one to replace or |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
363 // right position to insert |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
364 while (staging_next != NULL && staging_next->addr() == p1->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
365 if ((staging_next->flags() & MemPointerRecord::tag_masks) <= |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
366 (p1->flags() & MemPointerRecord::tag_masks)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
367 p2 = (MemPointerRecord*)malloc_staging_itr.next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
368 staging_next = (MemPointerRecord*)malloc_staging_itr.peek_next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
369 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
370 break; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
371 } |
6197 | 372 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
373 int df = (p1->flags() & MemPointerRecord::tag_masks) - |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
374 (p2->flags() & MemPointerRecord::tag_masks); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
375 if (df == 0) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
376 assert(p1->seq() > 0, "not sequenced"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
377 assert(p2->seq() > 0, "not sequenced"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
378 if (p1->seq() > p2->seq()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
379 copy_pointer(p2, p1); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
380 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
381 } else if (df < 0) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
382 if (!malloc_staging_itr.insert(p1)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
383 return false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
384 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
385 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
386 if (!malloc_staging_itr.insert_after(p1)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
387 return false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
388 } |
6197 | 389 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
390 } else if (p1->addr() < p2->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
391 if (!malloc_staging_itr.insert(p1)) { |
6197 | 392 return false; |
393 } | |
394 } else { | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
395 if (!malloc_staging_itr.insert_after(p1)) { |
6197 | 396 return false; |
397 } | |
398 } | |
399 } | |
400 p1 = (MemPointerRecord*)itr.next(); | |
401 } | |
402 NOT_PRODUCT(void check_staging_data();) | |
403 return true; | |
404 } | |
405 | |
406 | |
407 | |
408 // promote data to next generation | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
409 bool MemSnapshot::promote() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
410 assert(_alloc_ptrs != NULL && _vm_ptrs != NULL, "Just check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
411 assert(_staging_area.malloc_data() != NULL && _staging_area.vm_data() != NULL, |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
412 "Just check"); |
6197 | 413 MutexLockerEx lock(_lock, true); |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
414 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
415 MallocRecordIterator malloc_itr = _staging_area.malloc_record_walker(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
416 bool promoted = false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
417 if (promote_malloc_records(&malloc_itr)) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
418 VMRecordIterator vm_itr = _staging_area.virtual_memory_record_walker(); |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
419 if (promote_virtual_memory_records(&vm_itr)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
420 promoted = true; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
421 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
422 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
423 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
424 NOT_PRODUCT(check_malloc_pointers();) |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
425 _staging_area.clear(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
426 return promoted; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
427 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
428 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
429 bool MemSnapshot::promote_malloc_records(MemPointerArrayIterator* itr) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
430 MemPointerIterator malloc_snapshot_itr(_alloc_ptrs); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
431 MemPointerRecord* new_rec = (MemPointerRecord*)itr->current(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
432 MemPointerRecord* matched_rec; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
433 while (new_rec != NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
434 matched_rec = (MemPointerRecord*)malloc_snapshot_itr.locate(new_rec->addr()); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
435 // found matched memory block |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
436 if (matched_rec != NULL && new_rec->addr() == matched_rec->addr()) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
437 // snapshot already contains 'live' records |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
438 assert(matched_rec->is_allocation_record() || matched_rec->is_arena_size_record(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
439 "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
440 // update block states |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
441 if (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
442 copy_pointer(matched_rec, new_rec); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
443 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
444 // a deallocation record |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
445 assert(new_rec->is_deallocation_record(), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
446 // an arena record can be followed by a size record, we need to remove both |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
447 if (matched_rec->is_arena_record()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
448 MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
449 if (next->is_arena_size_record()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
450 // it has to match the arena record |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
451 assert(next->is_size_record_of_arena(matched_rec), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
452 malloc_snapshot_itr.remove(); |
6197 | 453 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
454 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
455 // the memory is deallocated, remove related record(s) |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
456 malloc_snapshot_itr.remove(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
457 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
458 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
459 // it is a new record, insert into snapshot |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
460 if (new_rec->is_arena_size_record()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
461 MemPointerRecord* prev = (MemPointerRecord*)malloc_snapshot_itr.peek_prev(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
462 if (prev == NULL || !prev->is_arena_record() || !new_rec->is_size_record_of_arena(prev)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
463 // no matched arena record, ignore the size record |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
464 new_rec = NULL; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
465 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
466 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
467 // only 'live' record can go into snapshot |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
468 if (new_rec != NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
469 if (new_rec->is_allocation_record() || new_rec->is_arena_size_record()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
470 if (matched_rec != NULL && new_rec->addr() > matched_rec->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
471 if (!malloc_snapshot_itr.insert_after(new_rec)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
472 return false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
473 } |
6197 | 474 } else { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
475 if (!malloc_snapshot_itr.insert(new_rec)) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
476 return false; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
477 } |
6197 | 478 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
479 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
480 #ifndef PRODUCT |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
481 else if (!has_allocation_record(new_rec->addr())) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
482 // NMT can not track some startup memory, which is allocated before NMT is on |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
483 _untracked_count ++; |
6197 | 484 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
485 #endif |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
486 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
487 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
488 new_rec = (MemPointerRecord*)itr->next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
489 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
490 return true; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
491 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
492 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
493 bool MemSnapshot::promote_virtual_memory_records(MemPointerArrayIterator* itr) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
494 VMMemPointerIterator vm_snapshot_itr(_vm_ptrs); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
495 MemPointerRecord* new_rec = (MemPointerRecord*)itr->current(); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
496 VMMemRegion* reserved_rec; |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
497 while (new_rec != NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
498 assert(new_rec->is_vm_pointer(), "Sanity check"); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
499 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
500 // locate a reserved region that contains the specified address, or |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
501 // the nearest reserved region has base address just above the specified |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
502 // address |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
503 reserved_rec = (VMMemRegion*)vm_snapshot_itr.locate(new_rec->addr()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
504 if (reserved_rec != NULL && reserved_rec->contains_region(new_rec)) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
505 // snapshot can only have 'live' records |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
506 assert(reserved_rec->is_reserved_region(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
507 if (new_rec->is_allocation_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
508 if (!reserved_rec->is_same_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
509 // only deal with split a bigger reserved region into smaller regions. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
510 // So far, CDS is the only use case. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
511 if (!vm_snapshot_itr.split_reserved_region(reserved_rec, new_rec->addr(), new_rec->size())) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
512 return false; |
6197 | 513 } |
514 } | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
515 } else if (new_rec->is_uncommit_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
516 if (!vm_snapshot_itr.remove_uncommitted_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
517 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
518 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
519 } else if (new_rec->is_commit_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
520 // insert or expand existing committed region to cover this |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
521 // newly committed region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
522 if (!vm_snapshot_itr.add_committed_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
523 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
524 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
525 } else if (new_rec->is_deallocation_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
526 // release part or all memory region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
527 if (!vm_snapshot_itr.remove_released_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
528 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
529 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
530 } else if (new_rec->is_type_tagging_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
531 // tag this reserved virtual memory range to a memory type. Can not re-tag a memory range |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
532 // to different type. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
533 assert(FLAGS_TO_MEMORY_TYPE(reserved_rec->flags()) == mtNone || |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
534 FLAGS_TO_MEMORY_TYPE(reserved_rec->flags()) == FLAGS_TO_MEMORY_TYPE(new_rec->flags()), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
535 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
536 reserved_rec->tag(new_rec->flags()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
537 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
538 ShouldNotReachHere(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
539 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
540 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
541 /* |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
542 * The assertion failure indicates mis-matched virtual memory records. The likely |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
543 * scenario is, that some virtual memory operations are not going through os::xxxx_memory() |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
544 * api, which have to be tracked manually. (perfMemory is an example). |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
545 */ |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
546 assert(new_rec->is_allocation_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
547 if (!vm_snapshot_itr.add_reserved_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
548 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
549 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
550 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
551 new_rec = (MemPointerRecord*)itr->next(); |
6197 | 552 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
553 return true; |
6197 | 554 } |
555 | |
6607
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
556 #ifndef PRODUCT |
6197 | 557 void MemSnapshot::print_snapshot_stats(outputStream* st) { |
558 st->print_cr("Snapshot:"); | |
559 st->print_cr("\tMalloced: %d/%d [%5.2f%%] %dKB", _alloc_ptrs->length(), _alloc_ptrs->capacity(), | |
560 (100.0 * (float)_alloc_ptrs->length()) / (float)_alloc_ptrs->capacity(), _alloc_ptrs->instance_size()/K); | |
561 | |
562 st->print_cr("\tVM: %d/%d [%5.2f%%] %dKB", _vm_ptrs->length(), _vm_ptrs->capacity(), | |
563 (100.0 * (float)_vm_ptrs->length()) / (float)_vm_ptrs->capacity(), _vm_ptrs->instance_size()/K); | |
564 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
565 st->print_cr("\tMalloc staging Area: %d/%d [%5.2f%%] %dKB", _staging_area.malloc_data()->length(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
566 _staging_area.malloc_data()->capacity(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
567 (100.0 * (float)_staging_area.malloc_data()->length()) / (float)_staging_area.malloc_data()->capacity(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
568 _staging_area.malloc_data()->instance_size()/K); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
569 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
570 st->print_cr("\tVirtual memory staging Area: %d/%d [%5.2f%%] %dKB", _staging_area.vm_data()->length(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
571 _staging_area.vm_data()->capacity(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
572 (100.0 * (float)_staging_area.vm_data()->length()) / (float)_staging_area.vm_data()->capacity(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
573 _staging_area.vm_data()->instance_size()/K); |
6197 | 574 |
575 st->print_cr("\tUntracked allocation: %d", _untracked_count); | |
576 } | |
577 | |
578 void MemSnapshot::check_malloc_pointers() { | |
579 MemPointerArrayIteratorImpl mItr(_alloc_ptrs); | |
580 MemPointerRecord* p = (MemPointerRecord*)mItr.current(); | |
581 MemPointerRecord* prev = NULL; | |
582 while (p != NULL) { | |
583 if (prev != NULL) { | |
584 assert(p->addr() >= prev->addr(), "sorting order"); | |
585 } | |
586 prev = p; | |
587 p = (MemPointerRecord*)mItr.next(); | |
588 } | |
589 } | |
590 | |
6607
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
591 bool MemSnapshot::has_allocation_record(address addr) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
592 MemPointerArrayIteratorImpl itr(_staging_area.malloc_data()); |
6607
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
593 MemPointerRecord* cur = (MemPointerRecord*)itr.current(); |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
594 while (cur != NULL) { |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
595 if (cur->addr() == addr && cur->is_allocation_record()) { |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
596 return true; |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
597 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
598 cur = (MemPointerRecord*)itr.next(); |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
599 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
600 return false; |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
601 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
602 #endif // PRODUCT |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
603 |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
604 #ifdef ASSERT |
6197 | 605 void MemSnapshot::check_staging_data() { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
606 MemPointerArrayIteratorImpl itr(_staging_area.malloc_data()); |
6197 | 607 MemPointerRecord* cur = (MemPointerRecord*)itr.current(); |
608 MemPointerRecord* next = (MemPointerRecord*)itr.next(); | |
609 while (next != NULL) { | |
610 assert((next->addr() > cur->addr()) || | |
611 ((next->flags() & MemPointerRecord::tag_masks) > | |
612 (cur->flags() & MemPointerRecord::tag_masks)), | |
613 "sorting order"); | |
614 cur = next; | |
615 next = (MemPointerRecord*)itr.next(); | |
616 } | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
617 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
618 MemPointerArrayIteratorImpl vm_itr(_staging_area.vm_data()); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
619 cur = (MemPointerRecord*)vm_itr.current(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
620 while (cur != NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
621 assert(cur->is_vm_pointer(), "virtual memory pointer only"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
622 cur = (MemPointerRecord*)vm_itr.next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
623 } |
6197 | 624 } |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
625 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
626 void MemSnapshot::dump_all_vm_pointers() { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
627 MemPointerArrayIteratorImpl itr(_vm_ptrs); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
628 VMMemRegion* ptr = (VMMemRegion*)itr.current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
629 tty->print_cr("dump virtual memory pointers:"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
630 while (ptr != NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
631 if (ptr->is_committed_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
632 tty->print("\t"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
633 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
634 tty->print("[" PTR_FORMAT " - " PTR_FORMAT "] [%x]", ptr->addr(), |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
635 (ptr->addr() + ptr->size()), ptr->flags()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
636 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
637 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
638 VMMemRegionEx* ex = (VMMemRegionEx*)ptr; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
639 if (ex->pc() != NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
640 char buf[1024]; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
641 if (os::dll_address_to_function_name(ex->pc(), buf, sizeof(buf), NULL)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
642 tty->print_cr("\t%s", buf); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
643 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
644 tty->print_cr(""); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
645 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
646 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
647 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
648 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
649 ptr = (VMMemRegion*)itr.next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
650 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
651 tty->flush(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
652 } |
6607
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
653 #endif // ASSERT |
6197 | 654 |