author | mgronlun |
Thu, 29 Aug 2019 12:53:05 +0200 | |
branch | JEP-349-branch |
changeset 57934 | 9c150f2b1fea |
parent 57870 | 00860d9caf4d |
child 57983 | a57907813a83 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50880
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50880
diff
changeset
|
25 |
#ifndef SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50880
diff
changeset
|
26 |
#define SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
50113 | 27 |
|
28 |
#include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp" |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
29 |
#include "jfr/recorder/stacktrace/jfrStackTrace.hpp" |
50113 | 30 |
#include "jfr/utilities/jfrAllocation.hpp" |
31 |
#include "jfr/utilities/jfrTime.hpp" |
|
32 |
#include "jfr/utilities/jfrTypes.hpp" |
|
33 |
#include "memory/allocation.hpp" |
|
34 |
#include "oops/oop.hpp" |
|
35 |
#include "utilities/ticks.hpp" |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
36 |
|
50113 | 37 |
/* |
38 |
* Handle for diagnosing Java memory leaks. |
|
39 |
* |
|
40 |
* The class tracks the time the object was |
|
41 |
* allocated, the thread and the stack trace. |
|
42 |
*/ |
|
43 |
class ObjectSample : public JfrCHeapObj { |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
44 |
friend class CheckpointInstall; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
45 |
friend class ObjectResolver; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
46 |
friend class ObjectSampleCheckpoint; |
50113 | 47 |
friend class ObjectSampler; |
48 |
friend class SampleList; |
|
49 |
private: |
|
50 |
ObjectSample* _next; |
|
51 |
ObjectSample* _previous; |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
52 |
mutable const JfrStackTrace* _stack_trace; |
50113 | 53 |
JfrCheckpointBlobHandle _thread_cp; |
54 |
JfrCheckpointBlobHandle _klass_cp; |
|
55 |
oop _object; |
|
56 |
Ticks _allocation_time; |
|
57 |
traceid _stack_trace_id; |
|
58 |
traceid _thread_id; |
|
59 |
int _index; |
|
60 |
size_t _span; |
|
61 |
size_t _allocated; |
|
50880
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
62 |
size_t _heap_used_at_last_gc; |
50113 | 63 |
unsigned int _stack_trace_hash; |
64 |
bool _dead; |
|
65 |
||
66 |
void set_dead() { |
|
67 |
_dead = true; |
|
68 |
} |
|
69 |
||
70 |
void release_references() { |
|
71 |
if (_thread_cp.valid()) { |
|
72 |
_thread_cp.~JfrCheckpointBlobHandle(); |
|
73 |
} |
|
74 |
if (_klass_cp.valid()) { |
|
75 |
_klass_cp.~JfrCheckpointBlobHandle(); |
|
76 |
} |
|
77 |
} |
|
78 |
||
79 |
void reset() { |
|
80 |
set_stack_trace_id(0); |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
81 |
set_stack_trace_hash(0); |
50113 | 82 |
release_references(); |
83 |
_dead = false; |
|
84 |
} |
|
85 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
86 |
~ObjectSample() { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
87 |
if (_stack_trace != NULL) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
88 |
delete _stack_trace; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
89 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
90 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
91 |
|
50113 | 92 |
public: |
93 |
ObjectSample() : _next(NULL), |
|
94 |
_previous(NULL), |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
95 |
_stack_trace(NULL), |
50113 | 96 |
_thread_cp(), |
97 |
_klass_cp(), |
|
98 |
_object(NULL), |
|
99 |
_allocation_time(), |
|
100 |
_stack_trace_id(0), |
|
101 |
_thread_id(0), |
|
102 |
_index(0), |
|
103 |
_span(0), |
|
104 |
_allocated(0), |
|
50880
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
105 |
_heap_used_at_last_gc(0), |
50113 | 106 |
_stack_trace_hash(0), |
107 |
_dead(false) {} |
|
108 |
||
109 |
ObjectSample* next() const { |
|
110 |
return _next; |
|
111 |
} |
|
112 |
||
113 |
void set_next(ObjectSample* next) { |
|
114 |
_next = next; |
|
115 |
} |
|
116 |
||
117 |
ObjectSample* prev() const { |
|
118 |
return _previous; |
|
119 |
} |
|
120 |
||
121 |
void set_prev(ObjectSample* prev) { |
|
122 |
_previous = prev; |
|
123 |
} |
|
124 |
||
125 |
bool is_dead() const { |
|
126 |
return _dead; |
|
127 |
} |
|
128 |
||
129 |
const oop object() const { |
|
130 |
return _object; |
|
131 |
} |
|
132 |
||
133 |
const oop* object_addr() const { |
|
134 |
return &_object; |
|
135 |
} |
|
136 |
||
137 |
void set_object(oop object) { |
|
138 |
_object = object; |
|
139 |
} |
|
140 |
||
141 |
const Klass* klass() const { |
|
142 |
assert(_object != NULL, "invariant"); |
|
143 |
return _object->klass(); |
|
144 |
} |
|
145 |
||
146 |
int index() const { |
|
147 |
return _index; |
|
148 |
} |
|
149 |
||
150 |
void set_index(int index) { |
|
151 |
_index = index; |
|
152 |
} |
|
153 |
||
154 |
size_t span() const { |
|
155 |
return _span; |
|
156 |
} |
|
157 |
||
158 |
void set_span(size_t span) { |
|
159 |
_span = span; |
|
160 |
} |
|
161 |
||
162 |
void add_span(size_t span) { |
|
163 |
_span += span; |
|
164 |
} |
|
165 |
||
166 |
size_t allocated() const { |
|
167 |
return _allocated; |
|
168 |
} |
|
169 |
||
170 |
void set_allocated(size_t size) { |
|
171 |
_allocated = size; |
|
172 |
} |
|
173 |
||
174 |
const Ticks& allocation_time() const { |
|
175 |
return _allocation_time; |
|
176 |
} |
|
177 |
||
178 |
const void set_allocation_time(const JfrTicks& time) { |
|
179 |
_allocation_time = Ticks(time.value()); |
|
180 |
} |
|
181 |
||
50880
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
182 |
void set_heap_used_at_last_gc(size_t heap_used) { |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
183 |
_heap_used_at_last_gc = heap_used; |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
184 |
} |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
185 |
|
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
186 |
size_t heap_used_at_last_gc() const { |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
187 |
return _heap_used_at_last_gc; |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
188 |
} |
e1117321adaf
8197425: Liveset information for Old Object sample event
egahlin
parents:
50113
diff
changeset
|
189 |
|
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
190 |
bool has_stack_trace_id() const { |
50113 | 191 |
return stack_trace_id() != 0; |
192 |
} |
|
193 |
||
194 |
traceid stack_trace_id() const { |
|
195 |
return _stack_trace_id; |
|
196 |
} |
|
197 |
||
198 |
void set_stack_trace_id(traceid id) { |
|
199 |
_stack_trace_id = id; |
|
200 |
} |
|
201 |
||
202 |
unsigned int stack_trace_hash() const { |
|
203 |
return _stack_trace_hash; |
|
204 |
} |
|
205 |
||
206 |
void set_stack_trace_hash(unsigned int hash) { |
|
207 |
_stack_trace_hash = hash; |
|
208 |
} |
|
209 |
||
57870
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
210 |
const JfrStackTrace* stack_trace() const { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
211 |
return _stack_trace; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
212 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
213 |
|
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
214 |
void set_stack_trace(const JfrStackTrace* trace) const { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
215 |
_stack_trace = trace; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
216 |
} |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
53244
diff
changeset
|
217 |
|
50113 | 218 |
bool has_thread() const { |
219 |
return _thread_id != 0; |
|
220 |
} |
|
221 |
||
222 |
traceid thread_id() const { |
|
223 |
return _thread_id; |
|
224 |
} |
|
225 |
||
226 |
void set_thread_id(traceid id) { |
|
227 |
_thread_id = id; |
|
228 |
} |
|
229 |
||
230 |
bool is_alive_and_older_than(jlong time_stamp) const { |
|
231 |
return !is_dead() && (JfrTime::is_ft_enabled() ? |
|
232 |
_allocation_time.ft_value() : _allocation_time.value()) < time_stamp; |
|
233 |
} |
|
234 |
||
235 |
const JfrCheckpointBlobHandle& thread_checkpoint() const { |
|
236 |
return _thread_cp; |
|
237 |
} |
|
238 |
||
239 |
bool has_thread_checkpoint() const { |
|
240 |
return _thread_cp.valid(); |
|
241 |
} |
|
242 |
||
243 |
// JfrCheckpointBlobHandle assignment operator |
|
244 |
// maintains proper reference counting |
|
245 |
void set_thread_checkpoint(const JfrCheckpointBlobHandle& ref) { |
|
246 |
if (_thread_cp != ref) { |
|
247 |
_thread_cp = ref; |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
const JfrCheckpointBlobHandle& klass_checkpoint() const { |
|
252 |
return _klass_cp; |
|
253 |
} |
|
254 |
||
255 |
bool has_klass_checkpoint() const { |
|
256 |
return _klass_cp.valid(); |
|
257 |
} |
|
258 |
||
259 |
void set_klass_checkpoint(const JfrCheckpointBlobHandle& ref) { |
|
260 |
if (_klass_cp != ref) { |
|
261 |
if (_klass_cp.valid()) { |
|
262 |
_klass_cp->set_next(ref); |
|
263 |
return; |
|
264 |
} |
|
265 |
_klass_cp = ref; |
|
266 |
} |
|
267 |
} |
|
268 |
}; |
|
269 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50880
diff
changeset
|
270 |
#endif // SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |