author | mgronlun |
Mon, 02 Sep 2019 19:42:46 +0200 | |
branch | JEP-349-branch |
changeset 57983 | a57907813a83 |
parent 57934 | 9c150f2b1fea |
child 58154 | 060d9d139109 |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52212
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" |
|
57360 | 26 |
#include "jfr/jfr.hpp" |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
27 |
#include "jfr/leakprofiler/leakProfiler.hpp" |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
28 |
#include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp" |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
29 |
#include "jfr/metadata/jfrSerializer.hpp" |
50113 | 30 |
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" |
31 |
#include "jfr/recorder/checkpoint/types/jfrType.hpp" |
|
32 |
#include "jfr/recorder/checkpoint/types/jfrTypeManager.hpp" |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
33 |
#include "jfr/utilities/jfrDoublyLinkedList.hpp" |
50113 | 34 |
#include "jfr/utilities/jfrIterator.hpp" |
57878
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
35 |
#include "memory/resourceArea.hpp" |
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
36 |
#include "runtime/handles.inline.hpp" |
50113 | 37 |
#include "runtime/safepoint.hpp" |
38 |
#include "runtime/thread.inline.hpp" |
|
39 |
#include "utilities/exceptions.hpp" |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
40 |
#include "runtime/semaphore.hpp" |
50113 | 41 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
42 |
class JfrSerializerRegistration : public JfrCHeapObj { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
43 |
private: |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
44 |
JfrSerializerRegistration* _next; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
45 |
JfrSerializerRegistration* _prev; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
46 |
JfrSerializer* _serializer; |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
47 |
mutable JfrBlobHandle _cache; |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
48 |
JfrTypeId _id; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
49 |
bool _permit_cache; |
50113 | 50 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
51 |
public: |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
52 |
JfrSerializerRegistration(JfrTypeId id, bool permit_cache, JfrSerializer* serializer) : |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
53 |
_next(NULL), _prev(NULL), _serializer(serializer), _cache(), _id(id), _permit_cache(permit_cache) {} |
50113 | 54 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
55 |
~JfrSerializerRegistration() { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
56 |
delete _serializer; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
57 |
} |
50113 | 58 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
59 |
JfrSerializerRegistration* next() const { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
60 |
return _next; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
61 |
} |
50113 | 62 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
63 |
void set_next(JfrSerializerRegistration* next) { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
64 |
_next = next; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
65 |
} |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
66 |
|
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
67 |
JfrSerializerRegistration* prev() const { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
68 |
return _prev; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
69 |
} |
50113 | 70 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
71 |
void set_prev(JfrSerializerRegistration* prev) { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
72 |
_prev = prev; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
73 |
} |
50113 | 74 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
75 |
JfrTypeId id() const { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
76 |
return _id; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
77 |
} |
50113 | 78 |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
79 |
void invoke(JfrCheckpointWriter& writer) const; |
57360 | 80 |
|
81 |
void on_rotation() const; |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
82 |
}; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
83 |
|
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
84 |
void JfrSerializerRegistration::invoke(JfrCheckpointWriter& writer) const { |
50113 | 85 |
if (_cache.valid()) { |
86 |
writer.increment(); |
|
87 |
_cache->write(writer); |
|
88 |
return; |
|
89 |
} |
|
90 |
const JfrCheckpointContext ctx = writer.context(); |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
91 |
// serialize the type id before invoking callback |
50113 | 92 |
writer.write_type(_id); |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
93 |
const intptr_t start = writer.current_offset(); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
94 |
// invoke the serializer routine |
50113 | 95 |
_serializer->serialize(writer); |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
96 |
if (start == writer.current_offset() ) { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
97 |
// the serializer implementation did nothing, rewind to restore |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
98 |
writer.set_context(ctx); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
99 |
return; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
100 |
} |
50113 | 101 |
if (_permit_cache) { |
102 |
_cache = writer.copy(&ctx); |
|
103 |
} |
|
104 |
} |
|
105 |
||
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:
57360
diff
changeset
|
106 |
void JfrSerializerRegistration::on_rotation() const { |
57360 | 107 |
_serializer->on_rotation(); |
108 |
} |
|
109 |
||
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
110 |
class SerializerRegistrationGuard : public StackObj { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
111 |
private: |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
112 |
static Semaphore _mutex_semaphore; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
113 |
public: |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
114 |
SerializerRegistrationGuard() { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
115 |
_mutex_semaphore.wait(); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
116 |
} |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
117 |
~SerializerRegistrationGuard() { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
118 |
_mutex_semaphore.signal(); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
119 |
} |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
120 |
}; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
121 |
|
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
122 |
Semaphore SerializerRegistrationGuard::_mutex_semaphore(1); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
123 |
|
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
124 |
typedef JfrDoublyLinkedList<JfrSerializerRegistration> List; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
125 |
typedef StopOnNullIterator<const List> Iterator; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
126 |
static List types; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
127 |
|
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
128 |
void JfrTypeManager::clear() { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
129 |
SerializerRegistrationGuard guard; |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
130 |
Iterator iter(types); |
50113 | 131 |
JfrSerializerRegistration* registration; |
132 |
while (iter.has_next()) { |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
133 |
registration = types.remove(iter.next()); |
50113 | 134 |
assert(registration != NULL, "invariant"); |
135 |
delete registration; |
|
136 |
} |
|
137 |
} |
|
138 |
||
57934 | 139 |
static bool new_registration = false; |
140 |
||
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
141 |
void JfrTypeManager::write_types(JfrCheckpointWriter& writer) { |
57934 | 142 |
SerializerRegistrationGuard guard; |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
143 |
const Iterator iter(types); |
50113 | 144 |
while (iter.has_next()) { |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
145 |
iter.next()->invoke(writer); |
50113 | 146 |
} |
57934 | 147 |
new_registration = false; |
50113 | 148 |
} |
149 |
||
57882 | 150 |
static void serialize_threads(JfrCheckpointWriter& writer) { |
151 |
JfrThreadConstantSet thread_set; |
|
152 |
writer.write_type(TYPE_THREAD); |
|
153 |
thread_set.serialize(writer); |
|
154 |
} |
|
155 |
||
156 |
static void serialize_thread_groups(JfrCheckpointWriter& writer) { |
|
157 |
JfrThreadGroupConstant thread_group_set; |
|
158 |
writer.write_type(TYPE_THREADGROUP); |
|
159 |
thread_group_set.serialize(writer); |
|
160 |
} |
|
161 |
||
162 |
void JfrTypeManager::write_threads(JfrCheckpointWriter& writer) { |
|
163 |
serialize_threads(writer); |
|
164 |
serialize_thread_groups(writer); |
|
165 |
} |
|
166 |
||
57360 | 167 |
void JfrTypeManager::notify_types_on_rotation() { |
168 |
const Iterator iter(types); |
|
50113 | 169 |
while (iter.has_next()) { |
57360 | 170 |
iter.next()->on_rotation(); |
50113 | 171 |
} |
172 |
} |
|
173 |
||
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
174 |
void JfrTypeManager::write_type_set() { |
57360 | 175 |
assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
176 |
if (!LeakProfiler::is_running()) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
177 |
JfrCheckpointWriter writer; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
178 |
TypeSet set; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
179 |
set.serialize(writer); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
180 |
return; |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
181 |
} |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
182 |
JfrCheckpointWriter leakp_writer; |
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:
57360
diff
changeset
|
183 |
JfrCheckpointWriter writer; |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
184 |
TypeSet set(&leakp_writer); |
50113 | 185 |
set.serialize(writer); |
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
186 |
ObjectSampleCheckpoint::on_type_set(leakp_writer); |
50113 | 187 |
} |
188 |
||
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
189 |
void JfrTypeManager::write_type_set_for_unloaded_classes() { |
57360 | 190 |
assert(SafepointSynchronize::is_at_safepoint(), "invariant"); |
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:
57360
diff
changeset
|
191 |
JfrCheckpointWriter writer; |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
192 |
const JfrCheckpointContext ctx = writer.context(); |
50113 | 193 |
ClassUnloadTypeSet class_unload_set; |
194 |
class_unload_set.serialize(writer); |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
195 |
if (LeakProfiler::is_running()) { |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
196 |
ObjectSampleCheckpoint::on_type_set_unload(writer); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
197 |
} |
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:
57360
diff
changeset
|
198 |
if (!Jfr::is_recording()) { |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
199 |
// discard anything written |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
200 |
writer.set_context(ctx); |
00860d9caf4d
New metadata system for oldobjects built on top of simplified tagging model. Caching and serialization improvements. Flushpoint checkpoint with chunkheader contents.
mgronlun
parents:
57360
diff
changeset
|
201 |
} |
50113 | 202 |
} |
203 |
||
57360 | 204 |
size_t JfrTypeManager::flush_type_set() { |
205 |
assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); |
|
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:
57360
diff
changeset
|
206 |
JfrCheckpointWriter writer; |
57360 | 207 |
FlushTypeSet flush; |
208 |
flush.serialize(writer); |
|
209 |
return flush.elements(); |
|
210 |
} |
|
211 |
||
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
212 |
void JfrTypeManager::create_thread_blob(Thread* t) { |
57360 | 213 |
assert(t != NULL, "invariant"); |
57878
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
214 |
ResourceMark rm(t); |
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
215 |
HandleMark hm(t); |
57360 | 216 |
JfrThreadConstant type_thread(t); |
57882 | 217 |
JfrCheckpointWriter writer(t, true, THREADS); |
50113 | 218 |
writer.write_type(TYPE_THREAD); |
219 |
type_thread.serialize(writer); |
|
220 |
// create and install a checkpoint blob |
|
57983
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
221 |
t->jfr_thread_local()->set_thread_blob(writer.move()); |
a57907813a83
old object sample blob:ification and serialization support
mgronlun
parents:
57934
diff
changeset
|
222 |
assert(t->jfr_thread_local()->has_thread_blob(), "invariant"); |
50113 | 223 |
} |
224 |
||
57360 | 225 |
void JfrTypeManager::write_thread_checkpoint(Thread* t) { |
226 |
assert(t != NULL, "invariant"); |
|
57878
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
227 |
ResourceMark rm(t); |
bffba8d6611a
Thread metadata to include excluded threads, thread sampler to exclude excluded threads, thread name friend
mgronlun
parents:
57870
diff
changeset
|
228 |
HandleMark hm(t); |
57360 | 229 |
JfrThreadConstant type_thread(t); |
57882 | 230 |
JfrCheckpointWriter writer(t, true, THREADS); |
57360 | 231 |
writer.write_type(TYPE_THREAD); |
232 |
type_thread.serialize(writer); |
|
50113 | 233 |
} |
234 |
||
235 |
#ifdef ASSERT |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
236 |
static void assert_not_registered_twice(JfrTypeId id, List& list) { |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
237 |
const Iterator iter(list); |
50113 | 238 |
while (iter.has_next()) { |
239 |
assert(iter.next()->id() != id, "invariant"); |
|
240 |
} |
|
241 |
} |
|
242 |
#endif |
|
243 |
||
57360 | 244 |
static bool register_type(JfrTypeId id, bool permit_cache, JfrSerializer* serializer) { |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
245 |
assert(serializer != NULL, "invariant"); |
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
246 |
JfrSerializerRegistration* const registration = new JfrSerializerRegistration(id, permit_cache, serializer); |
50113 | 247 |
if (registration == NULL) { |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
248 |
delete serializer; |
50113 | 249 |
return false; |
250 |
} |
|
57360 | 251 |
|
252 |
assert(!types.in_list(registration), "invariant"); |
|
253 |
DEBUG_ONLY(assert_not_registered_twice(id, types);) |
|
254 |
if (Jfr::is_recording()) { |
|
57934 | 255 |
JfrCheckpointWriter writer(STATICS); |
57360 | 256 |
registration->invoke(writer); |
57934 | 257 |
new_registration = true; |
50113 | 258 |
} |
57360 | 259 |
types.prepend(registration); |
50113 | 260 |
return true; |
261 |
} |
|
262 |
||
263 |
bool JfrTypeManager::initialize() { |
|
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
264 |
SerializerRegistrationGuard guard; |
57360 | 265 |
register_type(TYPE_FLAGVALUEORIGIN, true, new FlagValueOriginConstant()); |
266 |
register_type(TYPE_INFLATECAUSE, true, new MonitorInflateCauseConstant()); |
|
267 |
register_type(TYPE_GCCAUSE, true, new GCCauseConstant()); |
|
268 |
register_type(TYPE_GCNAME, true, new GCNameConstant()); |
|
269 |
register_type(TYPE_GCWHEN, true, new GCWhenConstant()); |
|
270 |
register_type(TYPE_G1HEAPREGIONTYPE, true, new G1HeapRegionTypeConstant()); |
|
271 |
register_type(TYPE_GCTHRESHOLDUPDATER, true, new GCThresholdUpdaterConstant()); |
|
272 |
register_type(TYPE_METADATATYPE, true, new MetadataTypeConstant()); |
|
273 |
register_type(TYPE_METASPACEOBJECTTYPE, true, new MetaspaceObjectTypeConstant()); |
|
274 |
register_type(TYPE_G1YCTYPE, true, new G1YCTypeConstant()); |
|
275 |
register_type(TYPE_REFERENCETYPE, true, new ReferenceTypeConstant()); |
|
276 |
register_type(TYPE_NARROWOOPMODE, true, new NarrowOopModeConstant()); |
|
277 |
register_type(TYPE_COMPILERPHASETYPE, true, new CompilerPhaseTypeConstant()); |
|
278 |
register_type(TYPE_CODEBLOBTYPE, true, new CodeBlobTypeConstant()); |
|
279 |
register_type(TYPE_VMOPERATIONTYPE, true, new VMOperationTypeConstant()); |
|
280 |
register_type(TYPE_THREADSTATE, true, new ThreadStateConstant()); |
|
50113 | 281 |
return true; |
282 |
} |
|
283 |
||
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
284 |
// implementation for the static registration function exposed in the JfrSerializer api |
57360 | 285 |
bool JfrSerializer::register_serializer(JfrTypeId id, bool permit_cache, JfrSerializer* serializer) { |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
286 |
SerializerRegistrationGuard guard; |
57360 | 287 |
return register_type(id, permit_cache, serializer); |
50703
0486d7749b8d
8205053: Decouple type registration from framework lifecycle
egahlin
parents:
50525
diff
changeset
|
288 |
} |
57934 | 289 |
|
290 |
bool JfrTypeManager::is_new_constant_registered() { |
|
291 |
if (new_registration) { |
|
292 |
SerializerRegistrationGuard guard; |
|
293 |
new_registration = false; |
|
294 |
return true; |
|
295 |
} |
|
296 |
return false; |
|
297 |
} |