139 while (iter.has_next()) { |
139 while (iter.has_next()) { |
140 iter.next()->invoke(writer); |
140 iter.next()->invoke(writer); |
141 } |
141 } |
142 } |
142 } |
143 |
143 |
|
144 static void serialize_threads(JfrCheckpointWriter& writer) { |
|
145 JfrThreadConstantSet thread_set; |
|
146 writer.write_type(TYPE_THREAD); |
|
147 thread_set.serialize(writer); |
|
148 } |
|
149 |
|
150 static void serialize_thread_groups(JfrCheckpointWriter& writer) { |
|
151 JfrThreadGroupConstant thread_group_set; |
|
152 writer.write_type(TYPE_THREADGROUP); |
|
153 thread_group_set.serialize(writer); |
|
154 } |
|
155 |
|
156 void JfrTypeManager::write_threads(JfrCheckpointWriter& writer) { |
|
157 serialize_threads(writer); |
|
158 serialize_thread_groups(writer); |
|
159 } |
|
160 |
144 void JfrTypeManager::notify_types_on_rotation() { |
161 void JfrTypeManager::notify_types_on_rotation() { |
145 const Iterator iter(types); |
162 const Iterator iter(types); |
146 while (iter.has_next()) { |
163 while (iter.has_next()) { |
147 iter.next()->on_rotation(); |
164 iter.next()->on_rotation(); |
148 } |
165 } |
178 void JfrTypeManager::create_thread_checkpoint(Thread* t) { |
195 void JfrTypeManager::create_thread_checkpoint(Thread* t) { |
179 assert(t != NULL, "invariant"); |
196 assert(t != NULL, "invariant"); |
180 ResourceMark rm(t); |
197 ResourceMark rm(t); |
181 HandleMark hm(t); |
198 HandleMark hm(t); |
182 JfrThreadConstant type_thread(t); |
199 JfrThreadConstant type_thread(t); |
183 JfrCheckpointWriter writer(t); |
200 JfrCheckpointWriter writer(t, true, THREADS); |
184 writer.write_type(TYPE_THREAD); |
201 writer.write_type(TYPE_THREAD); |
185 type_thread.serialize(writer); |
202 type_thread.serialize(writer); |
186 // create and install a checkpoint blob |
203 // create and install a checkpoint blob |
187 t->jfr_thread_local()->set_thread_checkpoint(writer.move()); |
204 t->jfr_thread_local()->set_thread_checkpoint(writer.move()); |
188 assert(t->jfr_thread_local()->has_thread_checkpoint(), "invariant"); |
205 assert(t->jfr_thread_local()->has_thread_checkpoint(), "invariant"); |
191 void JfrTypeManager::write_thread_checkpoint(Thread* t) { |
208 void JfrTypeManager::write_thread_checkpoint(Thread* t) { |
192 assert(t != NULL, "invariant"); |
209 assert(t != NULL, "invariant"); |
193 ResourceMark rm(t); |
210 ResourceMark rm(t); |
194 HandleMark hm(t); |
211 HandleMark hm(t); |
195 JfrThreadConstant type_thread(t); |
212 JfrThreadConstant type_thread(t); |
196 JfrCheckpointWriter writer(t); |
213 JfrCheckpointWriter writer(t, true, THREADS); |
197 writer.write_type(TYPE_THREAD); |
214 writer.write_type(TYPE_THREAD); |
198 type_thread.serialize(writer); |
215 type_thread.serialize(writer); |
199 } |
216 } |
200 |
217 |
201 #ifdef ASSERT |
218 #ifdef ASSERT |
225 return true; |
242 return true; |
226 } |
243 } |
227 |
244 |
228 bool JfrTypeManager::initialize() { |
245 bool JfrTypeManager::initialize() { |
229 SerializerRegistrationGuard guard; |
246 SerializerRegistrationGuard guard; |
230 |
|
231 // register non-safepointing type serialization |
|
232 register_type(TYPE_THREADGROUP, false, new JfrThreadGroupConstant()); |
|
233 register_type(TYPE_THREAD, false, new JfrThreadConstantSet()); |
|
234 register_type(TYPE_FLAGVALUEORIGIN, true, new FlagValueOriginConstant()); |
247 register_type(TYPE_FLAGVALUEORIGIN, true, new FlagValueOriginConstant()); |
235 register_type(TYPE_INFLATECAUSE, true, new MonitorInflateCauseConstant()); |
248 register_type(TYPE_INFLATECAUSE, true, new MonitorInflateCauseConstant()); |
236 register_type(TYPE_GCCAUSE, true, new GCCauseConstant()); |
249 register_type(TYPE_GCCAUSE, true, new GCCauseConstant()); |
237 register_type(TYPE_GCNAME, true, new GCNameConstant()); |
250 register_type(TYPE_GCNAME, true, new GCNameConstant()); |
238 register_type(TYPE_GCWHEN, true, new GCWhenConstant()); |
251 register_type(TYPE_GCWHEN, true, new GCWhenConstant()); |
245 register_type(TYPE_NARROWOOPMODE, true, new NarrowOopModeConstant()); |
258 register_type(TYPE_NARROWOOPMODE, true, new NarrowOopModeConstant()); |
246 register_type(TYPE_COMPILERPHASETYPE, true, new CompilerPhaseTypeConstant()); |
259 register_type(TYPE_COMPILERPHASETYPE, true, new CompilerPhaseTypeConstant()); |
247 register_type(TYPE_CODEBLOBTYPE, true, new CodeBlobTypeConstant()); |
260 register_type(TYPE_CODEBLOBTYPE, true, new CodeBlobTypeConstant()); |
248 register_type(TYPE_VMOPERATIONTYPE, true, new VMOperationTypeConstant()); |
261 register_type(TYPE_VMOPERATIONTYPE, true, new VMOperationTypeConstant()); |
249 register_type(TYPE_THREADSTATE, true, new ThreadStateConstant()); |
262 register_type(TYPE_THREADSTATE, true, new ThreadStateConstant()); |
250 |
|
251 return true; |
263 return true; |
252 } |
264 } |
253 |
265 |
254 // implementation for the static registration function exposed in the JfrSerializer api |
266 // implementation for the static registration function exposed in the JfrSerializer api |
255 bool JfrSerializer::register_serializer(JfrTypeId id, bool permit_cache, JfrSerializer* serializer) { |
267 bool JfrSerializer::register_serializer(JfrTypeId id, bool permit_cache, JfrSerializer* serializer) { |