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