@@ -501,72 +501,63 @@ class ParallelSPCleanupTask : public AbstractGangTask {
501
501
private:
502
502
SubTasksDone _subtasks;
503
503
uint _num_workers;
504
+
505
+ class Tracer {
506
+ private:
507
+ const char * _name;
508
+ EventSafepointCleanupTask _event;
509
+ TraceTime _timer;
510
+
511
+ public:
512
+ Tracer (const char * name) :
513
+ _name (name),
514
+ _event (),
515
+ _timer (name, TRACETIME_LOG(Info, safepoint, cleanup)) {}
516
+ ~Tracer () {
517
+ post_safepoint_cleanup_task_event (_event, SafepointSynchronize::safepoint_id (), _name);
518
+ }
519
+ };
520
+
504
521
public:
505
522
ParallelSPCleanupTask (uint num_workers) :
506
523
AbstractGangTask (" Parallel Safepoint Cleanup" ),
507
524
_subtasks (SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS),
508
525
_num_workers (num_workers) {}
509
526
510
527
void work (uint worker_id) {
511
- uint64_t safepoint_id = SafepointSynchronize::safepoint_id ();
512
-
513
528
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_DEFLATE_MONITORS)) {
514
- const char * name = " deflating idle monitors" ;
515
- EventSafepointCleanupTask event;
516
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
529
+ Tracer t (" deflating idle monitors" );
517
530
ObjectSynchronizer::do_safepoint_work ();
518
-
519
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
520
531
}
521
532
522
533
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
523
- const char * name = " updating inline caches" ;
524
- EventSafepointCleanupTask event;
525
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
534
+ Tracer t (" updating inline caches" );
526
535
InlineCacheBuffer::update_inline_caches ();
527
-
528
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
529
536
}
530
537
531
538
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
532
- const char * name = " compilation policy safepoint handler" ;
533
- EventSafepointCleanupTask event;
534
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
539
+ Tracer t (" compilation policy safepoint handler" );
535
540
CompilationPolicy::policy ()->do_safepoint_work ();
536
-
537
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
538
541
}
539
542
540
543
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH)) {
541
544
if (SymbolTable::needs_rehashing ()) {
542
- const char * name = " rehashing symbol table" ;
543
- EventSafepointCleanupTask event;
544
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
545
+ Tracer t (" rehashing symbol table" );
545
546
SymbolTable::rehash_table ();
546
-
547
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
548
547
}
549
548
}
550
549
551
550
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_STRING_TABLE_REHASH)) {
552
551
if (StringTable::needs_rehashing ()) {
553
- const char * name = " rehashing string table" ;
554
- EventSafepointCleanupTask event;
555
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
552
+ Tracer t (" rehashing string table" );
556
553
StringTable::rehash_table ();
557
-
558
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
559
554
}
560
555
}
561
556
562
557
if (_subtasks.try_claim_task (SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) {
563
558
if (Dictionary::does_any_dictionary_needs_resizing ()) {
564
- const char * name = " resizing system dictionaries" ;
565
- EventSafepointCleanupTask event;
566
- TraceTime timer (name, TRACETIME_LOG (Info, safepoint, cleanup));
559
+ Tracer t (" resizing system dictionaries" );
567
560
ClassLoaderDataGraph::resize_dictionaries ();
568
-
569
- post_safepoint_cleanup_task_event (event, safepoint_id, name);
570
561
}
571
562
}
572
563
0 commit comments