Mercurial > hg > truffle
annotate src/share/vm/services/memSnapshot.hpp @ 6800:9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
Reviewed-by: kvn
author | twisti |
---|---|
date | Mon, 24 Sep 2012 17:59:24 -0700 |
parents | 33143ee07800 |
children | 716c64bda5ba |
rev | line source |
---|---|
6197 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP | |
26 #define SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "runtime/mutex.hpp" | |
30 #include "runtime/mutexLocker.hpp" | |
31 #include "services/memBaseline.hpp" | |
32 #include "services/memPtrArray.hpp" | |
33 | |
34 | |
35 // Snapshot pointer array iterator | |
36 | |
37 // The pointer array contains malloc-ed pointers | |
38 class MemPointerIterator : public MemPointerArrayIteratorImpl { | |
39 public: | |
40 MemPointerIterator(MemPointerArray* arr): | |
41 MemPointerArrayIteratorImpl(arr) { | |
42 assert(arr != NULL, "null array"); | |
43 } | |
44 | |
45 #ifdef ASSERT | |
46 virtual bool is_dup_pointer(const MemPointer* ptr1, | |
47 const MemPointer* ptr2) const { | |
48 MemPointerRecord* p1 = (MemPointerRecord*)ptr1; | |
49 MemPointerRecord* p2 = (MemPointerRecord*)ptr2; | |
50 | |
51 if (p1->addr() != p2->addr()) return false; | |
52 if ((p1->flags() & MemPointerRecord::tag_masks) != | |
53 (p2->flags() & MemPointerRecord::tag_masks)) { | |
54 return false; | |
55 } | |
56 // we do see multiple commit/uncommit on the same memory, it is ok | |
57 return (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_alloc || | |
58 (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_release; | |
59 } | |
60 | |
61 virtual bool insert(MemPointer* ptr) { | |
62 if (_pos > 0) { | |
63 MemPointer* p1 = (MemPointer*)ptr; | |
64 MemPointer* p2 = (MemPointer*)_array->at(_pos - 1); | |
65 assert(!is_dup_pointer(p1, p2), | |
6599
4acebbe310e1
7185614: NMT ON: "check by caller" assertion failed on nsk ThreadMXBean test
zgu
parents:
6197
diff
changeset
|
66 err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); |
6197 | 67 } |
68 if (_pos < _array->length() -1) { | |
69 MemPointer* p1 = (MemPointer*)ptr; | |
70 MemPointer* p2 = (MemPointer*)_array->at(_pos + 1); | |
71 assert(!is_dup_pointer(p1, p2), | |
6599
4acebbe310e1
7185614: NMT ON: "check by caller" assertion failed on nsk ThreadMXBean test
zgu
parents:
6197
diff
changeset
|
72 err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); |
6197 | 73 } |
74 return _array->insert_at(ptr, _pos); | |
75 } | |
76 | |
77 virtual bool insert_after(MemPointer* ptr) { | |
78 if (_pos > 0) { | |
79 MemPointer* p1 = (MemPointer*)ptr; | |
80 MemPointer* p2 = (MemPointer*)_array->at(_pos - 1); | |
81 assert(!is_dup_pointer(p1, p2), | |
6599
4acebbe310e1
7185614: NMT ON: "check by caller" assertion failed on nsk ThreadMXBean test
zgu
parents:
6197
diff
changeset
|
82 err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); |
6197 | 83 } |
84 if (_pos < _array->length() - 1) { | |
85 MemPointer* p1 = (MemPointer*)ptr; | |
86 MemPointer* p2 = (MemPointer*)_array->at(_pos + 1); | |
87 | |
88 assert(!is_dup_pointer(p1, p2), | |
6599
4acebbe310e1
7185614: NMT ON: "check by caller" assertion failed on nsk ThreadMXBean test
zgu
parents:
6197
diff
changeset
|
89 err_msg("duplicated pointer, flag = [%x]", (unsigned int)((MemPointerRecord*)p1)->flags())); |
6197 | 90 } |
91 if (_array->insert_at(ptr, _pos + 1)) { | |
92 _pos ++; | |
93 return true; | |
94 } | |
95 return false; | |
96 } | |
97 #endif | |
98 | |
99 virtual MemPointer* locate(address addr) { | |
100 MemPointer* cur = current(); | |
101 while (cur != NULL && cur->addr() < addr) { | |
102 cur = next(); | |
103 } | |
104 return cur; | |
105 } | |
106 }; | |
107 | |
108 class VMMemPointerIterator : public MemPointerIterator { | |
109 public: | |
110 VMMemPointerIterator(MemPointerArray* arr): | |
111 MemPointerIterator(arr) { | |
112 } | |
113 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
114 // locate an existing record that contains specified address, or |
6197 | 115 // the record, where the record with specified address, should |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
116 // be inserted. |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
117 // virtual memory record array is sorted in address order, so |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
118 // binary search is performed |
6197 | 119 virtual MemPointer* locate(address addr) { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
120 int index_low = 0; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
121 int index_high = _array->length(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
122 int index_mid = (index_high + index_low) / 2; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
123 int r = 1; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
124 while (index_low < index_high && (r = compare(index_mid, addr)) != 0) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
125 if (r > 0) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
126 index_high = index_mid; |
6197 | 127 } else { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
128 index_low = index_mid; |
6197 | 129 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
130 index_mid = (index_high + index_low) / 2; |
6197 | 131 } |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
132 if (r == 0) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
133 // update current location |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
134 _pos = index_mid; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
135 return _array->at(index_mid); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
136 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
137 return NULL; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
138 } |
6197 | 139 } |
140 | |
141 #ifdef ASSERT | |
142 virtual bool is_dup_pointer(const MemPointer* ptr1, | |
143 const MemPointer* ptr2) const { | |
144 VMMemRegion* p1 = (VMMemRegion*)ptr1; | |
145 VMMemRegion* p2 = (VMMemRegion*)ptr2; | |
146 | |
147 if (p1->addr() != p2->addr()) return false; | |
148 if ((p1->flags() & MemPointerRecord::tag_masks) != | |
149 (p2->flags() & MemPointerRecord::tag_masks)) { | |
150 return false; | |
151 } | |
152 // we do see multiple commit/uncommit on the same memory, it is ok | |
153 return (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_alloc || | |
154 (p1->flags() & MemPointerRecord::tag_masks) == MemPointerRecord::tag_release; | |
155 } | |
156 #endif | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
157 // compare if an address falls into a memory region, |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
158 // return 0, if the address falls into a memory region at specified index |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
159 // return 1, if memory region pointed by specified index is higher than the address |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
160 // return -1, if memory region pointed by specified index is lower than the address |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
161 int compare(int index, address addr) const { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
162 VMMemRegion* r = (VMMemRegion*)_array->at(index); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
163 assert(r->is_reserve_record(), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
164 if (r->addr() > addr) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
165 return 1; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
166 } else if (r->addr() + r->reserved_size() <= addr) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
167 return -1; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
168 } else { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
169 return 0; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
170 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
171 } |
6197 | 172 }; |
173 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
174 class MallocRecordIterator : public MemPointerArrayIterator { |
6197 | 175 private: |
176 MemPointerArrayIteratorImpl _itr; | |
177 | |
178 public: | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
179 MallocRecordIterator(MemPointerArray* arr) : _itr(arr) { |
6197 | 180 } |
181 | |
182 MemPointer* current() const { | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
183 MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
184 assert(cur == NULL || !cur->is_vm_pointer(), "seek error"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
185 MemPointerRecord* next = (MemPointerRecord*)_itr.peek_next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
186 if (next == NULL || next->addr() != cur->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
187 return cur; |
6197 | 188 } else { |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
189 assert(!cur->is_vm_pointer(), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
190 assert(cur->is_allocation_record() && next->is_deallocation_record(), |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
191 "sorting order"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
192 assert(cur->seq() != next->seq(), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
193 return cur->seq() > next->seq() ? cur : next; |
6197 | 194 } |
195 } | |
196 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
197 MemPointer* next() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
198 MemPointerRecord* cur = (MemPointerRecord*)_itr.current(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
199 assert(cur == NULL || !cur->is_vm_pointer(), "Sanity check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
200 MemPointerRecord* next = (MemPointerRecord*)_itr.next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
201 if (next == NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
202 return NULL; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
203 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
204 if (cur->addr() == next->addr()) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
205 next = (MemPointerRecord*)_itr.next(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
206 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
207 return current(); |
6197 | 208 } |
209 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
210 MemPointer* peek_next() const { ShouldNotReachHere(); return NULL; } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
211 MemPointer* peek_prev() const { ShouldNotReachHere(); return NULL; } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
212 void remove() { ShouldNotReachHere(); } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
213 bool insert(MemPointer* ptr) { ShouldNotReachHere(); return false; } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
214 bool insert_after(MemPointer* ptr) { ShouldNotReachHere(); return false; } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
215 }; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
216 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
217 class StagingArea : public _ValueObj { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
218 private: |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
219 MemPointerArray* _malloc_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
220 MemPointerArray* _vm_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
221 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
222 public: |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
223 StagingArea() : _malloc_data(NULL), _vm_data(NULL) { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
224 init(); |
6197 | 225 } |
226 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
227 ~StagingArea() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
228 if (_malloc_data != NULL) delete _malloc_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
229 if (_vm_data != NULL) delete _vm_data; |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
230 } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
231 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
232 MallocRecordIterator malloc_record_walker() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
233 return MallocRecordIterator(malloc_data()); |
6197 | 234 } |
235 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
236 MemPointerArrayIteratorImpl virtual_memory_record_walker(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
237 bool init(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
238 void clear() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
239 assert(_malloc_data != NULL && _vm_data != NULL, "Just check"); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
240 _malloc_data->shrink(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
241 _malloc_data->clear(); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
242 _vm_data->clear(); |
6197 | 243 } |
244 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
245 inline MemPointerArray* malloc_data() { return _malloc_data; } |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
246 inline MemPointerArray* vm_data() { return _vm_data; } |
6197 | 247 }; |
248 | |
249 class MemBaseline; | |
250 class MemSnapshot : public CHeapObj<mtNMT> { | |
251 private: | |
252 // the following two arrays contain records of all known lived memory blocks | |
253 // live malloc-ed memory pointers | |
254 MemPointerArray* _alloc_ptrs; | |
255 // live virtual memory pointers | |
256 MemPointerArray* _vm_ptrs; | |
257 | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
258 StagingArea _staging_area; |
6197 | 259 |
260 // the lock to protect this snapshot | |
261 Monitor* _lock; | |
262 | |
263 NOT_PRODUCT(size_t _untracked_count;) | |
264 friend class MemBaseline; | |
265 | |
266 public: | |
267 MemSnapshot(); | |
268 virtual ~MemSnapshot(); | |
269 | |
270 // if we are running out of native memory | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
271 bool out_of_memory() { |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
272 return (_alloc_ptrs == NULL || |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
273 _staging_area.malloc_data() == NULL || |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
274 _staging_area.vm_data() == NULL || |
6197 | 275 _vm_ptrs == NULL || _lock == NULL || |
276 _alloc_ptrs->out_of_memory() || | |
277 _vm_ptrs->out_of_memory()); | |
278 } | |
279 | |
280 // merge a per-thread memory recorder into staging area | |
281 bool merge(MemRecorder* rec); | |
282 // promote staged data to snapshot | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
283 bool promote(); |
6197 | 284 |
285 | |
286 void wait(long timeout) { | |
287 assert(_lock != NULL, "Just check"); | |
288 MonitorLockerEx locker(_lock); | |
289 locker.wait(true, timeout); | |
290 } | |
291 | |
292 NOT_PRODUCT(void print_snapshot_stats(outputStream* st);) | |
293 NOT_PRODUCT(void check_staging_data();) | |
294 NOT_PRODUCT(void check_malloc_pointers();) | |
295 NOT_PRODUCT(bool has_allocation_record(address addr);) | |
296 | |
297 private: | |
298 // copy pointer data from src to dest | |
299 void copy_pointer(MemPointerRecord* dest, const MemPointerRecord* src); | |
6741
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
300 |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
301 bool promote_malloc_records(MemPointerArrayIterator* itr); |
33143ee07800
7181995: NMT ON: NMT assertion failure assert(cur_vm->is_uncommit_record() || cur_vm->is_deallocation_record
zgu
parents:
6599
diff
changeset
|
302 bool promote_virtual_memory_records(MemPointerArrayIterator* itr); |
6197 | 303 }; |
304 | |
305 | |
306 #endif // SHARE_VM_SERVICES_MEM_SNAPSHOT_HPP |