author | stuefe |
Wed, 06 Nov 2019 17:13:26 +0100 | |
branch | stuefe-new-metaspace-branch |
changeset 58948 | 18659e040c64 |
parent 58838 | 55ce65813b62 |
parent 58863 | c16ac7a2eba4 |
child 59272 | 54750b448264 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
57644
446dcfc2a925
8228834: Regression caused by JDK-8214542 not installing complete checkpoint data to candidates
mgronlun
parents:
55571
diff
changeset
|
2 |
* Copyright (c) 2016, 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 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "classfile/javaClasses.inline.hpp" |
|
27 |
#include "code/codeBlob.hpp" |
|
28 |
#include "code/codeCache.hpp" |
|
29 |
#include "gc/shared/gcCause.hpp" |
|
30 |
#include "gc/shared/gcName.hpp" |
|
31 |
#include "gc/shared/gcTrace.hpp" |
|
32 |
#include "gc/shared/gcWhen.hpp" |
|
33 |
#include "jfr/leakprofiler/leakProfiler.hpp" |
|
58863 | 34 |
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" |
50113 | 35 |
#include "jfr/recorder/checkpoint/types/jfrType.hpp" |
36 |
#include "jfr/recorder/jfrRecorder.hpp" |
|
37 |
#include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp" |
|
38 |
#include "jfr/recorder/checkpoint/types/jfrThreadState.hpp" |
|
39 |
#include "jfr/support/jfrThreadLocal.hpp" |
|
40 |
#include "jfr/writers/jfrJavaEventWriter.hpp" |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
58003
diff
changeset
|
41 |
#include "memory/metaspace.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
58003
diff
changeset
|
42 |
#include "memory/metaspace/metaspaceEnums.hpp" |
58863 | 43 |
#include "jfr/utilities/jfrThreadIterator.hpp" |
50113 | 44 |
#include "memory/referenceType.hpp" |
45 |
#include "memory/universe.hpp" |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
53897
diff
changeset
|
46 |
#include "oops/compressedOops.hpp" |
50113 | 47 |
#include "runtime/flags/jvmFlag.hpp" |
48 |
#include "runtime/mutexLocker.hpp" |
|
49 |
#include "runtime/osThread.hpp" |
|
50 |
#include "runtime/safepoint.hpp" |
|
51 |
#include "runtime/synchronizer.hpp" |
|
52 |
#include "runtime/thread.inline.hpp" |
|
52877
9e041366c764
8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents:
51004
diff
changeset
|
53 |
#include "runtime/vmOperations.hpp" |
50113 | 54 |
|
55 |
#ifdef COMPILER2 |
|
56 |
#include "opto/compile.hpp" |
|
57 |
#include "opto/node.hpp" |
|
58 |
#endif |
|
59 |
||
60 |
// Requires a ResourceMark for get_thread_name/as_utf8 |
|
61 |
class JfrCheckpointThreadClosure : public ThreadClosure { |
|
62 |
private: |
|
63 |
JfrCheckpointWriter& _writer; |
|
51004
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
64 |
JfrCheckpointContext _ctx; |
53897
0abec72a3ac2
8217647: JFR: recordings on 32-bit systems unreadable
bulasevich
parents:
52877
diff
changeset
|
65 |
const int64_t _count_position; |
51004
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
66 |
Thread* const _curthread; |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
67 |
u4 _count; |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
68 |
|
50113 | 69 |
public: |
51004
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
70 |
JfrCheckpointThreadClosure(JfrCheckpointWriter& writer) : _writer(writer), |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
71 |
_ctx(writer.context()), |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
72 |
_count_position(writer.reserve(sizeof(u4))), |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
73 |
_curthread(Thread::current()), |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
74 |
_count(0) { |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
75 |
} |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
76 |
|
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
77 |
~JfrCheckpointThreadClosure() { |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
78 |
if (_count == 0) { |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
79 |
// restore |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
80 |
_writer.set_context(_ctx); |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
81 |
return; |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
82 |
} |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
83 |
_writer.write_count(_count, _count_position); |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
84 |
} |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
85 |
|
50113 | 86 |
void do_thread(Thread* t); |
87 |
}; |
|
88 |
||
89 |
void JfrCheckpointThreadClosure::do_thread(Thread* t) { |
|
90 |
assert(t != NULL, "invariant"); |
|
51004
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
91 |
++_count; |
58863 | 92 |
_writer.write_key(JfrThreadId::jfr_id(t)); |
93 |
const char* const name = JfrThreadName::name(t); |
|
94 |
assert(name != NULL, "invariant"); |
|
95 |
_writer.write(name); |
|
96 |
_writer.write<traceid>(JfrThreadId::os_id(t)); |
|
50113 | 97 |
if (t->is_Java_thread()) { |
58863 | 98 |
_writer.write(name); |
99 |
_writer.write(JfrThreadId::id(t)); |
|
100 |
_writer.write(JfrThreadGroup::thread_group_id((JavaThread*)t, _curthread)); |
|
50113 | 101 |
return; |
102 |
} |
|
103 |
_writer.write((const char*)NULL); // java name |
|
51004
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
104 |
_writer.write((traceid)0); // java thread id |
162867fa0f8d
8203943: eventThreadGroup was null in TestJavaBlockedEvent.java
mgronlun
parents:
50749
diff
changeset
|
105 |
_writer.write((traceid)0); // java thread group |
50113 | 106 |
} |
107 |
||
108 |
void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) { |
|
109 |
JfrCheckpointThreadClosure tc(writer); |
|
58863 | 110 |
JfrJavaThreadIterator javathreads; |
111 |
while (javathreads.has_next()) { |
|
112 |
tc.do_thread(javathreads.next()); |
|
113 |
} |
|
114 |
JfrNonJavaThreadIterator nonjavathreads; |
|
115 |
while (nonjavathreads.has_next()) { |
|
116 |
tc.do_thread(nonjavathreads.next()); |
|
117 |
} |
|
50113 | 118 |
} |
119 |
||
120 |
void JfrThreadGroupConstant::serialize(JfrCheckpointWriter& writer) { |
|
121 |
JfrThreadGroup::serialize(writer); |
|
122 |
} |
|
123 |
||
124 |
static const char* flag_value_origin_to_string(JVMFlag::Flags origin) { |
|
125 |
switch (origin) { |
|
126 |
case JVMFlag::DEFAULT: return "Default"; |
|
127 |
case JVMFlag::COMMAND_LINE: return "Command line"; |
|
128 |
case JVMFlag::ENVIRON_VAR: return "Environment variable"; |
|
129 |
case JVMFlag::CONFIG_FILE: return "Config file"; |
|
130 |
case JVMFlag::MANAGEMENT: return "Management"; |
|
131 |
case JVMFlag::ERGONOMIC: return "Ergonomic"; |
|
132 |
case JVMFlag::ATTACH_ON_DEMAND: return "Attach on demand"; |
|
133 |
case JVMFlag::INTERNAL: return "Internal"; |
|
58842
6c255334120d
8232080: jlink plugins for vendor information and run-time options
mr
parents:
58786
diff
changeset
|
134 |
case JVMFlag::JIMAGE_RESOURCE: return "JImage resource"; |
50113 | 135 |
default: ShouldNotReachHere(); return ""; |
136 |
} |
|
137 |
} |
|
138 |
||
139 |
void FlagValueOriginConstant::serialize(JfrCheckpointWriter& writer) { |
|
140 |
static const u4 nof_entries = JVMFlag::LAST_VALUE_ORIGIN + 1; |
|
141 |
writer.write_count(nof_entries); |
|
142 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
143 |
writer.write_key(i); |
|
144 |
writer.write(flag_value_origin_to_string((JVMFlag::Flags)i)); |
|
145 |
} |
|
146 |
} |
|
147 |
||
148 |
void MonitorInflateCauseConstant::serialize(JfrCheckpointWriter& writer) { |
|
149 |
static const u4 nof_entries = ObjectSynchronizer::inflate_cause_nof; |
|
150 |
writer.write_count(nof_entries); |
|
151 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
152 |
writer.write_key(i); |
|
153 |
writer.write(ObjectSynchronizer::inflate_cause_name((ObjectSynchronizer::InflateCause)i)); |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
void GCCauseConstant::serialize(JfrCheckpointWriter& writer) { |
|
158 |
static const u4 nof_entries = GCCause::_last_gc_cause; |
|
159 |
writer.write_count(nof_entries); |
|
160 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
161 |
writer.write_key(i); |
|
162 |
writer.write(GCCause::to_string((GCCause::Cause)i)); |
|
163 |
} |
|
164 |
} |
|
165 |
||
166 |
void GCNameConstant::serialize(JfrCheckpointWriter& writer) { |
|
167 |
static const u4 nof_entries = GCNameEndSentinel; |
|
168 |
writer.write_count(nof_entries); |
|
169 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
170 |
writer.write_key(i); |
|
171 |
writer.write(GCNameHelper::to_string((GCName)i)); |
|
172 |
} |
|
173 |
} |
|
174 |
||
175 |
void GCWhenConstant::serialize(JfrCheckpointWriter& writer) { |
|
176 |
static const u4 nof_entries = GCWhen::GCWhenEndSentinel; |
|
177 |
writer.write_count(nof_entries); |
|
178 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
179 |
writer.write_key(i); |
|
180 |
writer.write(GCWhen::to_string((GCWhen::Type)i)); |
|
181 |
} |
|
182 |
} |
|
183 |
||
184 |
void GCThresholdUpdaterConstant::serialize(JfrCheckpointWriter& writer) { |
|
185 |
static const u4 nof_entries = MetaspaceGCThresholdUpdater::Last; |
|
186 |
writer.write_count(nof_entries); |
|
187 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
188 |
writer.write_key(i); |
|
189 |
writer.write(MetaspaceGCThresholdUpdater::to_string((MetaspaceGCThresholdUpdater::Type)i)); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
void MetadataTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
58003
diff
changeset
|
194 |
static const u4 nof_entries = metaspace::MetadataTypeCount; |
50113 | 195 |
writer.write_count(nof_entries); |
196 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
197 |
writer.write_key(i); |
|
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
58003
diff
changeset
|
198 |
writer.write(metaspace::describe_mdtype((metaspace::MetadataType)i)); |
50113 | 199 |
} |
200 |
} |
|
201 |
||
202 |
void MetaspaceObjectTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
203 |
static const u4 nof_entries = MetaspaceObj::_number_of_types; |
|
204 |
writer.write_count(nof_entries); |
|
205 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
206 |
writer.write_key(i); |
|
207 |
writer.write(MetaspaceObj::type_name((MetaspaceObj::Type)i)); |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
static const char* reference_type_to_string(ReferenceType rt) { |
|
212 |
switch (rt) { |
|
213 |
case REF_NONE: return "None reference"; |
|
214 |
case REF_OTHER: return "Other reference"; |
|
215 |
case REF_SOFT: return "Soft reference"; |
|
216 |
case REF_WEAK: return "Weak reference"; |
|
217 |
case REF_FINAL: return "Final reference"; |
|
218 |
case REF_PHANTOM: return "Phantom reference"; |
|
219 |
default: |
|
220 |
ShouldNotReachHere(); |
|
221 |
return NULL; |
|
222 |
} |
|
223 |
} |
|
224 |
||
225 |
void ReferenceTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
226 |
static const u4 nof_entries = REF_PHANTOM + 1; |
|
227 |
writer.write_count(nof_entries); |
|
228 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
229 |
writer.write_key(i); |
|
230 |
writer.write(reference_type_to_string((ReferenceType)i)); |
|
231 |
} |
|
232 |
} |
|
233 |
||
234 |
void NarrowOopModeConstant::serialize(JfrCheckpointWriter& writer) { |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
53897
diff
changeset
|
235 |
static const u4 nof_entries = CompressedOops::HeapBasedNarrowOop + 1; |
50113 | 236 |
writer.write_count(nof_entries); |
237 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
238 |
writer.write_key(i); |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
53897
diff
changeset
|
239 |
writer.write(CompressedOops::mode_to_string((CompressedOops::Mode)i)); |
50113 | 240 |
} |
241 |
} |
|
242 |
||
243 |
void CompilerPhaseTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
244 |
#ifdef COMPILER2 |
|
245 |
static const u4 nof_entries = PHASE_NUM_TYPES; |
|
246 |
writer.write_count(nof_entries); |
|
247 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
248 |
writer.write_key(i); |
|
249 |
writer.write(CompilerPhaseTypeHelper::to_string((CompilerPhaseType)i)); |
|
250 |
} |
|
251 |
#endif |
|
252 |
} |
|
253 |
||
254 |
void CodeBlobTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
255 |
static const u4 nof_entries = CodeBlobType::NumTypes; |
|
256 |
writer.write_count(nof_entries); |
|
257 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
258 |
writer.write_key(i); |
|
259 |
writer.write(CodeCache::get_code_heap_name(i)); |
|
260 |
} |
|
261 |
}; |
|
262 |
||
263 |
void VMOperationTypeConstant::serialize(JfrCheckpointWriter& writer) { |
|
264 |
static const u4 nof_entries = VM_Operation::VMOp_Terminating; |
|
265 |
writer.write_count(nof_entries); |
|
266 |
for (u4 i = 0; i < nof_entries; ++i) { |
|
267 |
writer.write_key(i); |
|
268 |
writer.write(VM_Operation::name(VM_Operation::VMOp_Type(i))); |
|
269 |
} |
|
270 |
} |
|
271 |
||
272 |
void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) { |
|
273 |
JfrThreadState::serialize(writer); |
|
274 |
} |
|
275 |
||
276 |
void JfrThreadConstant::serialize(JfrCheckpointWriter& writer) { |
|
277 |
assert(_thread != NULL, "invariant"); |
|
278 |
assert(_thread == Thread::current(), "invariant"); |
|
279 |
writer.write_count(1); |
|
58863 | 280 |
writer.write_key(JfrThreadId::jfr_id(_thread)); |
281 |
const char* const name = JfrThreadName::name(_thread); |
|
282 |
writer.write(name); |
|
283 |
writer.write(JfrThreadId::os_id(_thread)); |
|
284 |
if (_thread->is_Java_thread()) { |
|
285 |
writer.write(name); |
|
286 |
writer.write(JfrThreadId::id(_thread)); |
|
287 |
JavaThread* const jt = (JavaThread*)_thread; |
|
288 |
const traceid thread_group_id = JfrThreadGroup::thread_group_id(jt, jt); |
|
289 |
writer.write(thread_group_id); |
|
290 |
JfrThreadGroup::serialize(&writer, thread_group_id); |
|
291 |
return; |
|
292 |
} |
|
293 |
writer.write((const char*)NULL); // java name |
|
294 |
writer.write((traceid)0); // java thread id |
|
295 |
writer.write((traceid)0); // java thread group |
|
50113 | 296 |
} |