6885993: Named Thread: introduce print() and print_on(outputStream* st) methods
Summary: Eliminating duplicated code by introducing print_on(outputStream* st) methods in NamedThread
Reviewed-by: twisti, coleenp, dholmes
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -223,12 +223,6 @@
}
}
-void ConcurrentMarkSweepThread::print_on(outputStream* st) const {
- st->print("\"%s\" ", name());
- Thread::print_on(st);
- st->cr();
-}
-
void ConcurrentMarkSweepThread::print_all_on(outputStream* st) {
if (_cmst != NULL) {
_cmst->print_on(st);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -94,8 +94,6 @@
static void threads_do(ThreadClosure* tc);
// Printing
- void print_on(outputStream* st) const;
- void print() const { print_on(tty); }
static void print_all_on(outputStream* st);
static void print_all() { print_all_on(tty); }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -58,6 +58,9 @@
}
initialize();
create_and_start();
+
+ // set name
+ set_name("G1 Concurrent Refinement Thread#%d", worker_id);
}
void ConcurrentG1RefineThread::initialize() {
@@ -247,12 +250,3 @@
}
}
-void ConcurrentG1RefineThread::print() const {
- print_on(tty);
-}
-
-void ConcurrentG1RefineThread::print_on(outputStream* st) const {
- st->print("\"G1 Concurrent Refinement Thread#%d\" ", _worker_id);
- Thread::print_on(st);
- st->cr();
-}
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -77,10 +77,6 @@
void initialize();
- // Printing
- void print() const;
- void print_on(outputStream* st) const;
-
// Total virtual time so far.
double vtime_accum() { return _vtime_accum; }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -46,6 +46,8 @@
_in_progress(false),
_vtime_accum(0.0),
_vtime_mark_accum(0.0) {
+
+ set_name("G1 Main Concurrent Mark GC Thread");
create_and_start();
}
@@ -322,16 +324,6 @@
}
}
-void ConcurrentMarkThread::print() const {
- print_on(tty);
-}
-
-void ConcurrentMarkThread::print_on(outputStream* st) const {
- st->print("\"G1 Main Concurrent Mark GC Thread\" ");
- Thread::print_on(st);
- st->cr();
-}
-
void ConcurrentMarkThread::sleepBeforeNextCycle() {
// We join here because we don't want to do the "shouldConcurrentMark()"
// below while the world is otherwise stopped.
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -60,10 +60,6 @@
static void makeSurrogateLockerThread(TRAPS);
static SurrogateLockerThread* slt() { return _slt; }
- // Printing
- void print_on(outputStream* st) const;
- void print() const;
-
// Total virtual time so far.
double vtime_accum();
// Marking virtual time so far
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -53,12 +53,6 @@
return _thread;
}
-void G1StringDedupThread::print_on(outputStream* st) const {
- st->print("\"%s\" ", name());
- Thread::print_on(st);
- st->cr();
-}
-
void G1StringDedupThread::run() {
G1StringDedupStat total_stat;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -52,7 +52,6 @@
static G1StringDedupThread* thread();
virtual void run();
- virtual void print_on(outputStream* st) const;
};
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1STRINGDEDUPTHREAD_HPP
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -87,12 +87,6 @@
_time_stamp_index = 0;
}
-void GCTaskThread::print_on(outputStream* st) const {
- st->print("\"%s\" ", name());
- Thread::print_on(st);
- st->cr();
-}
-
// GC workers get tasks from the GCTaskManager and execute
// them in this method. If there are no tasks to execute,
// the GC workers wait in the GCTaskManager's get_task()
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -69,8 +69,6 @@
void start();
void print_task_time_stamps();
- void print_on(outputStream* st) const;
- void print() const { print_on(tty); }
protected:
// Constructor. Clients use factory, but there could be subclasses.
--- a/hotspot/src/share/vm/runtime/thread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/runtime/thread.cpp Thu May 01 05:52:28 2014 -0700
@@ -1198,6 +1198,13 @@
va_end(ap);
}
+void NamedThread::print_on(outputStream* st) const {
+ st->print("\"%s\" ", name());
+ Thread::print_on(st);
+ st->cr();
+}
+
+
// ======= WatcherThread ========
// The watcher thread exists to simulate timer interrupts. It should
--- a/hotspot/src/share/vm/runtime/thread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/runtime/thread.hpp Thu May 01 05:52:28 2014 -0700
@@ -566,7 +566,7 @@
void set_lgrp_id(int value) { _lgrp_id = value; }
// Printing
- void print_on(outputStream* st) const;
+ virtual void print_on(outputStream* st) const;
void print() const { print_on(tty); }
virtual void print_on_error(outputStream* st, char* buf, int buflen) const;
@@ -700,6 +700,7 @@
virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; }
JavaThread *processed_thread() { return _processed_thread; }
void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
+ virtual void print_on(outputStream* st) const;
};
// Worker threads are named and have an id of an assigned work.
@@ -746,7 +747,6 @@
// Printing
char* name() const { return (char*)"VM Periodic Task Thread"; }
void print_on(outputStream* st) const;
- void print() const { print_on(tty); }
void unpark();
// Returns the single instance of WatcherThread
@@ -1459,7 +1459,6 @@
// Misc. operations
char* name() const { return (char*)get_thread_name(); }
void print_on(outputStream* st) const;
- void print() const { print_on(tty); }
void print_value();
void print_thread_state_on(outputStream* ) const PRODUCT_RETURN;
void print_thread_state() const PRODUCT_RETURN;
--- a/hotspot/src/share/vm/runtime/vmThread.cpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp Thu May 01 05:52:28 2014 -0700
@@ -339,12 +339,6 @@
}
}
-void VMThread::print_on(outputStream* st) const {
- st->print("\"%s\" ", name());
- Thread::print_on(st);
- st->cr();
-}
-
void VMThread::evaluate_operation(VM_Operation* op) {
ResourceMark rm;
--- a/hotspot/src/share/vm/runtime/vmThread.hpp Mon Apr 28 09:31:25 2014 +0000
+++ b/hotspot/src/share/vm/runtime/vmThread.hpp Thu May 01 05:52:28 2014 -0700
@@ -128,9 +128,6 @@
// GC support
void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
- // Debugging
- void print_on(outputStream* st) const;
- void print() const { print_on(tty); }
void verify();
// Performance measurement