Mercurial > hg > truffle
annotate src/share/vm/services/memSnapshot.cpp @ 17925:45e59fae8f2b
8041481: JVM crashes with collect_args_for_profiling
Summary: method handle call to c1 intrinsic tries to profile popped argument
Reviewed-by: kvn, twisti
author | roland |
---|---|
date | Fri, 25 Apr 2014 09:22:16 +0200 |
parents | c18152e0554e |
children | 78bbf4d43a14 |
rev | line source |
---|---|
6197 | 1 /* |
10221
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
6197 | 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 | |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
34 #ifdef ASSERT |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
35 |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
36 void decode_pointer_record(MemPointerRecord* rec) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
37 tty->print("Pointer: [" PTR_FORMAT " - " PTR_FORMAT "] size = %d bytes", rec->addr(), |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
38 rec->addr() + rec->size(), (int)rec->size()); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
39 tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
40 if (rec->is_vm_pointer()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
41 if (rec->is_allocation_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
42 tty->print_cr(" (reserve)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
43 } else if (rec->is_commit_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
44 tty->print_cr(" (commit)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
45 } else if (rec->is_uncommit_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
46 tty->print_cr(" (uncommit)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
47 } else if (rec->is_deallocation_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
48 tty->print_cr(" (release)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
49 } else { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
50 tty->print_cr(" (tag)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
51 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
52 } else { |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
53 if (rec->is_arena_memory_record()) { |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
54 tty->print_cr(" (arena size)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
55 } else if (rec->is_allocation_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
56 tty->print_cr(" (malloc)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
57 } else { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
58 tty->print_cr(" (free)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
59 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
60 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
61 if (MemTracker::track_callsite()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
62 char buf[1024]; |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
63 address pc = ((MemPointerRecordEx*)rec)->pc(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
64 if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
65 tty->print_cr("\tfrom %s", buf); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
66 } else { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
67 tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
68 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
69 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
70 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
71 |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
72 void decode_vm_region_record(VMMemRegion* rec) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
73 tty->print("VM Region [" PTR_FORMAT " - " PTR_FORMAT "]", rec->addr(), |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
74 rec->addr() + rec->size()); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
75 tty->print(" type = %s", MemBaseline::type2name(FLAGS_TO_MEMORY_TYPE(rec->flags()))); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
76 if (rec->is_allocation_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
77 tty->print_cr(" (reserved)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
78 } else if (rec->is_commit_record()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
79 tty->print_cr(" (committed)"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
80 } else { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
81 ShouldNotReachHere(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
82 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
83 if (MemTracker::track_callsite()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
84 char buf[1024]; |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
85 address pc = ((VMMemRegionEx*)rec)->pc(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
86 if (pc != NULL && os::dll_address_to_function_name(pc, buf, sizeof(buf), NULL)) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
87 tty->print_cr("\tfrom %s", buf); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
88 } else { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
89 tty->print_cr("\tcould not decode pc = " PTR_FORMAT "", pc); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
90 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
91 |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
92 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
93 } |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
94 |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
95 #endif |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
96 |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
97 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
98 bool VMMemPointerIterator::insert_record(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
99 VMMemRegionEx new_rec; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
100 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
|
101 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
102 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
103 new_rec.init((MemPointerRecordEx*)rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
104 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
105 new_rec.init(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
106 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
107 return insert(&new_rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
108 } |
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 bool VMMemPointerIterator::insert_record_after(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
111 VMMemRegionEx new_rec; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
112 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
|
113 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
114 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
115 new_rec.init((MemPointerRecordEx*)rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
116 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
117 new_rec.init(rec); |
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 insert_after(&new_rec); |
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 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
122 // 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
|
123 // in different types. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
124 bool VMMemPointerIterator::add_reserved_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
125 assert(rec->is_allocation_record(), "Sanity check"); |
6977
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
126 VMMemRegion* reserved_region = (VMMemRegion*)current(); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
127 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
128 // we don't have anything yet |
6977
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
129 if (reserved_region == NULL) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
130 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
131 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
132 |
6977
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
133 assert(reserved_region->is_reserved_region(), "Sanity check"); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
134 // duplicated records |
6977
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
135 if (reserved_region->is_same_region(rec)) { |
6882
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 } |
6977
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
138 // Overlapping stack regions indicate that a JNI thread failed to |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
139 // detach from the VM before exiting. This leaks the JavaThread object. |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
140 if (CheckJNICalls) { |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
141 guarantee(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) != mtThreadStack || |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
142 !reserved_region->overlaps_region(rec), |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
143 "Attached JNI thread exited without being detached"); |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
144 } |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
145 // otherwise, we should not have overlapping reserved regions |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
146 assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
147 reserved_region->base() > rec->addr(), "Just check: locate()"); |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
148 assert(FLAGS_TO_MEMORY_TYPE(reserved_region->flags()) == mtThreadStack || |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
149 !reserved_region->overlaps_region(rec), "overlapping reserved regions"); |
ed8b1e39ff4f
8002273: NMT to report JNI memory leaks when -Xcheck:jni is on
zgu
parents:
6937
diff
changeset
|
150 |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
151 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
152 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
153 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
154 // we do consolidate committed regions |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
155 bool VMMemPointerIterator::add_committed_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
156 assert(rec->is_commit_record(), "Sanity check"); |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
157 VMMemRegion* reserved_rgn = (VMMemRegion*)current(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
158 assert(reserved_rgn->is_reserved_region() && reserved_rgn->contains_region(rec), |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
159 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
160 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
161 // 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
|
162 // the "commit" operation for creating stack guard pages |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
163 if (FLAGS_TO_MEMORY_TYPE(reserved_rgn->flags()) == mtThreadStack && |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
164 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
165 return true; |
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 |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
168 // if the reserved region has any committed regions |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
169 VMMemRegion* committed_rgn = (VMMemRegion*)next(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
170 while (committed_rgn != NULL && committed_rgn->is_committed_region()) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
171 // duplicated commit records |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
172 if(committed_rgn->contains_region(rec)) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
173 return true; |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
174 } else if (committed_rgn->overlaps_region(rec)) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
175 // overlaps front part |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
176 if (rec->addr() < committed_rgn->addr()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
177 committed_rgn->expand_region(rec->addr(), |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
178 committed_rgn->addr() - rec->addr()); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
179 } else { |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
180 // overlaps tail part |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
181 address committed_rgn_end = committed_rgn->addr() + |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
182 committed_rgn->size(); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
183 assert(committed_rgn_end < rec->addr() + rec->size(), |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
184 "overlap tail part"); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
185 committed_rgn->expand_region(committed_rgn_end, |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
186 (rec->addr() + rec->size()) - committed_rgn_end); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
187 } |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
188 } else if (committed_rgn->base() + committed_rgn->size() == rec->addr()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
189 // adjunct each other |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
190 committed_rgn->expand_region(rec->addr(), rec->size()); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
191 VMMemRegion* next_reg = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
192 // see if we can consolidate next committed region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
193 if (next_reg != NULL && next_reg->is_committed_region() && |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
194 next_reg->base() == committed_rgn->base() + committed_rgn->size()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
195 committed_rgn->expand_region(next_reg->base(), next_reg->size()); |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
196 // delete merged region |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
197 remove(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
198 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
199 return true; |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
200 } else if (committed_rgn->base() > rec->addr()) { |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
201 // found the location, insert this committed region |
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
202 return insert_record(rec); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
203 } |
6937
69ad7823b1ca
8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
zgu
parents:
6882
diff
changeset
|
204 committed_rgn = (VMMemRegion*)next(); |
6882
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 insert_record(rec); |
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::remove_uncommitted_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
210 assert(rec->is_uncommit_record(), "sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
211 VMMemRegion* cur; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
212 cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
213 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
|
214 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
215 // 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
|
216 // the "commit" operation for creating stack guard pages |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
217 if (FLAGS_TO_MEMORY_TYPE(cur->flags()) == mtThreadStack && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
218 FLAGS_TO_MEMORY_TYPE(rec->flags()) != mtThreadStack) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
219 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
220 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
221 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
222 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
223 while (cur != NULL && cur->is_committed_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
224 // 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
|
225 if (cur->addr() >= rec->addr() + rec->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
226 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
227 } else if (cur->contains_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
228 // uncommit whole region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
229 if (cur->is_same_region(rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
230 remove(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
231 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
232 } else if (rec->addr() == cur->addr() || |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
233 rec->addr() + rec->size() == cur->addr() + cur->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
234 // uncommitted from either end of current memory region. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
235 cur->exclude_region(rec->addr(), rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
236 break; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
237 } 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
|
238 address high_addr = cur->addr() + cur->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
239 size_t sz = high_addr - rec->addr(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
240 cur->exclude_region(rec->addr(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
241 sz = high_addr - (rec->addr() + rec->size()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
242 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
243 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
|
244 ((VMMemRegionEx*)cur)->pc()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
245 return insert_record_after(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
246 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
247 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
|
248 return insert_record_after(&tmp); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
249 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
250 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
251 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
252 cur = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
253 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
254 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
255 // 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
|
256 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
257 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
258 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
259 bool VMMemPointerIterator::remove_released_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
260 assert(rec->is_deallocation_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
261 VMMemRegion* cur = (VMMemRegion*)current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
262 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
|
263 "Sanity check"); |
7166
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
264 if (rec->is_same_region(cur)) { |
10221
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
265 |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
266 // In snapshot, the virtual memory records are sorted in following orders: |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
267 // 1. virtual memory's base address |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
268 // 2. virtual memory reservation record, followed by commit records within this reservation. |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
269 // The commit records are also in base address order. |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
270 // When a reserved region is released, we want to remove the reservation record and all |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
271 // commit records following it. |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
272 #ifdef ASSERT |
10221
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
273 address low_addr = cur->addr(); |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
274 address high_addr = low_addr + cur->size(); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
275 #endif |
10221
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
276 // remove virtual memory reservation record |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
277 remove(); |
10221
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
278 // remove committed regions within above reservation |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
279 VMMemRegion* next_region = (VMMemRegion*)current(); |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
280 while (next_region != NULL && next_region->is_committed_region()) { |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
281 assert(next_region->addr() >= low_addr && |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
282 next_region->addr() + next_region->size() <= high_addr, |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
283 "Range check"); |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
284 remove(); |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
285 next_region = (VMMemRegion*)current(); |
c18152e0554e
8013120: NMT: Kitchensink crashes with assert(next_region == NULL || !next_region->is_committed_region()) failed: Sanity check
zgu
parents:
8102
diff
changeset
|
286 } |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
287 } else if (rec->addr() == cur->addr() || |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
288 rec->addr() + rec->size() == cur->addr() + cur->size()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
289 // 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
|
290 cur->exclude_region(rec->addr(), rec->size()); |
7166
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
291 assert(check_reserved_region(), "Integrity check"); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
292 } 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
|
293 address high_addr = cur->addr() + cur->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
294 size_t sz = high_addr - rec->addr(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
295 cur->exclude_region(rec->addr(), sz); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
296 sz = high_addr - rec->addr() - rec->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
297 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
298 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
|
299 ((VMMemRegionEx*)cur)->pc()); |
7166
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
300 bool ret = insert_reserved_region(&tmp); |
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
301 assert(!ret || check_reserved_region(), "Integrity check"); |
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
302 return ret; |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
303 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
304 MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); |
7166
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
305 bool ret = insert_reserved_region(&tmp); |
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
306 assert(!ret || check_reserved_region(), "Integrity check"); |
49cbd3e25ba9
8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp)
zgu
parents:
6981
diff
changeset
|
307 return ret; |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
308 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
309 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
310 return true; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
311 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
312 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
313 bool VMMemPointerIterator::insert_reserved_region(MemPointerRecord* rec) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
314 // 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
|
315 VMMemRegion* p = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
316 while (p != NULL && p->is_committed_region() && |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
317 p->base() + p->size() < rec->addr()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
318 p = (VMMemRegion*)next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
319 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
320 return insert_record(rec); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
321 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
322 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
323 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
|
324 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
|
325 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
|
326 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
|
327 size_t sz = rgn->size() - new_rgn_size; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
328 // the original region becomes 'new' region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
329 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
|
330 // remaining becomes next region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
331 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
|
332 return insert_reserved_region(&next_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
333 } 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
|
334 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
|
335 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
|
336 return insert_reserved_region(&next_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
337 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
338 // the orginal region will be split into three |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
339 address rgn_high_addr = rgn->base() + rgn->size(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
340 // first region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
341 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
|
342 // the second region is the new region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
343 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
|
344 if (!insert_reserved_region(&new_rgn)) return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
345 // the remaining region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
346 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
|
347 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
|
348 return insert_reserved_region(&rem_rgn); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
349 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
350 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
351 |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 } |
6197 | 358 |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
359 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
|
360 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
|
361 _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
|
362 _vm_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecordEx>(); |
6197 | 363 } 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
|
364 _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
|
365 _vm_data = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecord>(); |
6197 | 366 } |
367 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
368 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
|
369 !_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
|
370 !_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
|
371 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
|
372 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
373 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
|
374 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
|
375 _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
|
376 _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
|
377 return false; |
6197 | 378 } |
379 } | |
380 | |
381 | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
382 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
|
383 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
|
384 // 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
|
385 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
|
386 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
|
387 } |
6197 | 388 |
389 | |
390 MemSnapshot::MemSnapshot() { | |
391 if (MemTracker::track_callsite()) { | |
392 _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl<MemPointerRecordEx>(); | |
393 _vm_ptrs = new (std::nothrow)MemPointerArrayImpl<VMMemRegionEx>(64, true); | |
394 } else { | |
395 _alloc_ptrs = new (std::nothrow) MemPointerArrayImpl<MemPointerRecord>(); | |
396 _vm_ptrs = new (std::nothrow)MemPointerArrayImpl<VMMemRegion>(64, true); | |
397 } | |
398 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
399 _staging_area.init(); |
6232
f1f45dddb0bd
7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents:
6197
diff
changeset
|
400 _lock = new (std::nothrow) Mutex(Monitor::max_nonleaf - 1, "memSnapshotLock"); |
6197 | 401 NOT_PRODUCT(_untracked_count = 0;) |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
7166
diff
changeset
|
402 _number_of_classes = 0; |
6197 | 403 } |
404 | |
405 MemSnapshot::~MemSnapshot() { | |
406 assert(MemTracker::shutdown_in_progress(), "native memory tracking still on"); | |
407 { | |
408 MutexLockerEx locker(_lock); | |
409 if (_alloc_ptrs != NULL) { | |
410 delete _alloc_ptrs; | |
411 _alloc_ptrs = NULL; | |
412 } | |
413 | |
414 if (_vm_ptrs != NULL) { | |
415 delete _vm_ptrs; | |
416 _vm_ptrs = NULL; | |
417 } | |
418 } | |
419 | |
420 if (_lock != NULL) { | |
421 delete _lock; | |
422 _lock = NULL; | |
423 } | |
424 } | |
425 | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
426 |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
427 void MemSnapshot::copy_seq_pointer(MemPointerRecord* dest, const MemPointerRecord* src) { |
6197 | 428 assert(dest != NULL && src != NULL, "Just check"); |
429 assert(dest->addr() == src->addr(), "Just check"); | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
430 assert(dest->seq() > 0 && src->seq() > 0, "not sequenced"); |
6197 | 431 |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
432 if (MemTracker::track_callsite()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
433 *(SeqMemPointerRecordEx*)dest = *(SeqMemPointerRecordEx*)src; |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
434 } else { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
435 *(SeqMemPointerRecord*)dest = *(SeqMemPointerRecord*)src; |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
436 } |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
437 } |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
438 |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
439 void MemSnapshot::assign_pointer(MemPointerRecord*dest, const MemPointerRecord* src) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
440 assert(src != NULL && dest != NULL, "Just check"); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
441 assert(dest->seq() == 0 && src->seq() >0, "cast away sequence"); |
6197 | 442 |
443 if (MemTracker::track_callsite()) { | |
444 *(MemPointerRecordEx*)dest = *(MemPointerRecordEx*)src; | |
445 } else { | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
446 *(MemPointerRecord*)dest = *(MemPointerRecord*)src; |
6197 | 447 } |
448 } | |
449 | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
450 // merge a recorder to the staging area |
6197 | 451 bool MemSnapshot::merge(MemRecorder* rec) { |
452 assert(rec != NULL && !rec->out_of_memory(), "Just check"); | |
453 | |
454 SequencedRecordIterator itr(rec->pointer_itr()); | |
455 | |
456 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
|
457 MemPointerIterator malloc_staging_itr(_staging_area.malloc_data()); |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
458 MemPointerRecord* incoming_rec = (MemPointerRecord*) itr.current(); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
459 MemPointerRecord* matched_rec; |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
460 |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
461 while (incoming_rec != NULL) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
462 if (incoming_rec->is_vm_pointer()) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
463 // we don't do anything with virtual memory records during merge |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
464 if (!_staging_area.vm_data()->append(incoming_rec)) { |
6197 | 465 return false; |
466 } | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
467 } else { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
468 // 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
|
469 // location for this incoming record. |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
470 matched_rec = (MemPointerRecord*)malloc_staging_itr.locate(incoming_rec->addr()); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
471 // we have not seen this memory block in this generation, |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
472 // so just add to staging area |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
473 if (matched_rec == NULL) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
474 if (!malloc_staging_itr.insert(incoming_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
|
475 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
|
476 } |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
477 } else if (incoming_rec->addr() == matched_rec->addr()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
478 // whoever has higher sequence number wins |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
479 if (incoming_rec->seq() > matched_rec->seq()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
480 copy_seq_pointer(matched_rec, incoming_rec); |
6197 | 481 } |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
482 } else if (incoming_rec->addr() < matched_rec->addr()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
483 if (!malloc_staging_itr.insert(incoming_rec)) { |
6197 | 484 return false; |
485 } | |
486 } else { | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
487 ShouldNotReachHere(); |
6197 | 488 } |
489 } | |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
490 incoming_rec = (MemPointerRecord*)itr.next(); |
6197 | 491 } |
492 NOT_PRODUCT(void check_staging_data();) | |
493 return true; | |
494 } | |
495 | |
496 | |
497 // promote data to next generation | |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
7166
diff
changeset
|
498 bool MemSnapshot::promote(int number_of_classes) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
499 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
|
500 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
|
501 "Just check"); |
6197 | 502 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
|
503 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
504 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
|
505 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
|
506 if (promote_malloc_records(&malloc_itr)) { |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
507 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
|
508 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
|
509 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
|
510 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
511 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
512 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
513 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
|
514 _staging_area.clear(); |
7464
ecd24264898b
8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents:
7166
diff
changeset
|
515 _number_of_classes = number_of_classes; |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
516 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
|
517 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
518 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
519 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
|
520 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
|
521 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
|
522 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
|
523 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
|
524 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
|
525 // 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
|
526 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
|
527 // snapshot already contains 'live' records |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
528 assert(matched_rec->is_allocation_record() || matched_rec->is_arena_memory_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
|
529 "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
|
530 // update block states |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
531 if (new_rec->is_allocation_record()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
532 assign_pointer(matched_rec, new_rec); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
533 } else if (new_rec->is_arena_memory_record()) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
534 if (new_rec->size() == 0) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
535 // remove size record once size drops to 0 |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
536 malloc_snapshot_itr.remove(); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
537 } else { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
538 assign_pointer(matched_rec, new_rec); |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
539 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
540 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
541 // 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
|
542 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
|
543 // 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
|
544 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
|
545 MemPointerRecord* next = (MemPointerRecord*)malloc_snapshot_itr.peek_next(); |
8102
fc64254f5579
8008071: Crashed in promote_malloc_records() with Kitchensink after 19 days
zgu
parents:
7464
diff
changeset
|
546 if (next != NULL && next->is_arena_memory_record() && |
fc64254f5579
8008071: Crashed in promote_malloc_records() with Kitchensink after 19 days
zgu
parents:
7464
diff
changeset
|
547 next->is_memory_record_of_arena(matched_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
|
548 malloc_snapshot_itr.remove(); |
6197 | 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 // 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
|
552 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
|
553 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
554 } else { |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
555 // don't insert size 0 record |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
556 if (new_rec->is_arena_memory_record() && new_rec->size() == 0) { |
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
557 new_rec = 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
|
558 } |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
559 |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
560 if (new_rec != NULL) { |
6979
fb3190e77d3c
8001592: NMT: assertion failed: assert(_amount >= amt) failed: Just check: memBaseline.hpp:180
zgu
parents:
6937
diff
changeset
|
561 if (new_rec->is_allocation_record() || new_rec->is_arena_memory_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
|
562 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
|
563 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
|
564 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
|
565 } |
6197 | 566 } 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
|
567 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
|
568 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
|
569 } |
6197 | 570 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
571 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
572 #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
|
573 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
|
574 // 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
|
575 _untracked_count ++; |
6197 | 576 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
577 #endif |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
578 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
579 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
580 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
|
581 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
582 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
|
583 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
584 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
585 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
|
586 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
|
587 MemPointerRecord* new_rec = (MemPointerRecord*)itr->current(); |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
588 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
|
589 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
|
590 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
|
591 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
592 // 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
|
593 // 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
|
594 // address |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
595 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
|
596 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
|
597 // snapshot can only have 'live' records |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
598 assert(reserved_rec->is_reserved_region(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
599 if (new_rec->is_allocation_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
600 if (!reserved_rec->is_same_region(new_rec)) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
601 // 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
|
602 // So far, CDS is the only use case. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
603 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
|
604 return false; |
6197 | 605 } |
606 } | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
607 } else if (new_rec->is_uncommit_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
608 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
|
609 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
610 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
611 } else if (new_rec->is_commit_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
612 // 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
|
613 // newly committed region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
614 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
|
615 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
616 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
617 } else if (new_rec->is_deallocation_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
618 // release part or all memory region |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
619 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
|
620 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
621 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
622 } else if (new_rec->is_type_tagging_record()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
623 // 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
|
624 // to different type. |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
625 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
|
626 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
|
627 "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
628 reserved_rec->tag(new_rec->flags()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
629 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
630 ShouldNotReachHere(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
631 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
632 } else { |
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 * 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
|
635 * 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
|
636 * 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
|
637 */ |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
638 assert(new_rec->is_allocation_record(), "Sanity check"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
639 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
|
640 return false; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
641 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
642 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
643 new_rec = (MemPointerRecord*)itr->next(); |
6197 | 644 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
645 return true; |
6197 | 646 } |
647 | |
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
|
648 #ifndef PRODUCT |
6197 | 649 void MemSnapshot::print_snapshot_stats(outputStream* st) { |
650 st->print_cr("Snapshot:"); | |
651 st->print_cr("\tMalloced: %d/%d [%5.2f%%] %dKB", _alloc_ptrs->length(), _alloc_ptrs->capacity(), | |
652 (100.0 * (float)_alloc_ptrs->length()) / (float)_alloc_ptrs->capacity(), _alloc_ptrs->instance_size()/K); | |
653 | |
654 st->print_cr("\tVM: %d/%d [%5.2f%%] %dKB", _vm_ptrs->length(), _vm_ptrs->capacity(), | |
655 (100.0 * (float)_vm_ptrs->length()) / (float)_vm_ptrs->capacity(), _vm_ptrs->instance_size()/K); | |
656 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
657 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
|
658 _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
|
659 (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
|
660 _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
|
661 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
662 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
|
663 _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
|
664 (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
|
665 _staging_area.vm_data()->instance_size()/K); |
6197 | 666 |
667 st->print_cr("\tUntracked allocation: %d", _untracked_count); | |
668 } | |
669 | |
670 void MemSnapshot::check_malloc_pointers() { | |
671 MemPointerArrayIteratorImpl mItr(_alloc_ptrs); | |
672 MemPointerRecord* p = (MemPointerRecord*)mItr.current(); | |
673 MemPointerRecord* prev = NULL; | |
674 while (p != NULL) { | |
675 if (prev != NULL) { | |
676 assert(p->addr() >= prev->addr(), "sorting order"); | |
677 } | |
678 prev = p; | |
679 p = (MemPointerRecord*)mItr.next(); | |
680 } | |
681 } | |
682 | |
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
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
690 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
|
691 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
692 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
|
693 } |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
694 #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
|
695 |
e5bf1c79ed5b
7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents:
6599
diff
changeset
|
696 #ifdef ASSERT |
6197 | 697 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
|
698 MemPointerArrayIteratorImpl itr(_staging_area.malloc_data()); |
6197 | 699 MemPointerRecord* cur = (MemPointerRecord*)itr.current(); |
700 MemPointerRecord* next = (MemPointerRecord*)itr.next(); | |
701 while (next != NULL) { | |
702 assert((next->addr() > cur->addr()) || | |
703 ((next->flags() & MemPointerRecord::tag_masks) > | |
704 (cur->flags() & MemPointerRecord::tag_masks)), | |
705 "sorting order"); | |
706 cur = next; | |
707 next = (MemPointerRecord*)itr.next(); | |
708 } | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
709 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6607
diff
changeset
|
710 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
|
711 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
|
712 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
|
713 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
|
714 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
|
715 } |
6197 | 716 } |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
717 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
718 void MemSnapshot::dump_all_vm_pointers() { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
719 MemPointerArrayIteratorImpl itr(_vm_ptrs); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
720 VMMemRegion* ptr = (VMMemRegion*)itr.current(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
721 tty->print_cr("dump virtual memory pointers:"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
722 while (ptr != NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
723 if (ptr->is_committed_region()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
724 tty->print("\t"); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
725 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
726 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
|
727 (ptr->addr() + ptr->size()), ptr->flags()); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
728 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
729 if (MemTracker::track_callsite()) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
730 VMMemRegionEx* ex = (VMMemRegionEx*)ptr; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
731 if (ex->pc() != NULL) { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
732 char buf[1024]; |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
733 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
|
734 tty->print_cr("\t%s", buf); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
735 } else { |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
736 tty->print_cr(""); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
737 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
738 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
739 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
740 |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
741 ptr = (VMMemRegion*)itr.next(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
742 } |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
743 tty->flush(); |
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6741
diff
changeset
|
744 } |
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
|
745 #endif // ASSERT |
6197 | 746 |