Skip to content

Commit df44cbf

Browse files
committed
8073464: GC workers do not have thread names
Reviewed-by: phh, andrew Backport-of: a827cdfa1047ee0af30bb454aad2067420103bae
1 parent 9f2f0c2 commit df44cbf

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -105,9 +105,7 @@ ConcurrentMarkSweepThread::ConcurrentMarkSweepThread(CMSCollector* collector)
105105
void ConcurrentMarkSweepThread::run() {
106106
assert(this == cmst(), "just checking");
107107

108-
this->record_stack_base_and_size();
109-
this->initialize_thread_local_storage();
110-
this->set_active_handles(JNIHandleBlock::allocate_block());
108+
initialize_in_thread();
111109
// From this time Thread::current() should be working.
112110
assert(this == Thread::current(), "just checking");
113111
if (BindCMSThreadToCPU && !os::bind_to_processor(CPUForCMSThread)) {

hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,7 @@ void GCTaskThread::run() {
9898
// Set up the thread for stack overflow support
9999
this->record_stack_base_and_size();
100100
this->initialize_thread_local_storage();
101+
this->initialize_named_thread();
101102
// Bind yourself to your processor.
102103
if (processor_id() != GCTaskManager::sentinel_worker()) {
103104
if (TraceGCTaskThread) {

hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -55,6 +55,7 @@ void ConcurrentGCThread::create_and_start() {
5555
void ConcurrentGCThread::initialize_in_thread() {
5656
this->record_stack_base_and_size();
5757
this->initialize_thread_local_storage();
58+
this->initialize_named_thread();
5859
this->set_active_handles(JNIHandleBlock::allocate_block());
5960
// From this time Thread::current() should be working.
6061
assert(this == Thread::current(), "just checking");

hotspot/src/share/vm/runtime/thread.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,10 @@ void NamedThread::set_name(const char* format, ...) {
12311231
va_end(ap);
12321232
}
12331233

1234+
void NamedThread::initialize_named_thread() {
1235+
set_native_thread_name(name());
1236+
}
1237+
12341238
void NamedThread::print_on(outputStream* st) const {
12351239
st->print("\"%s\" ", name());
12361240
Thread::print_on(st);

hotspot/src/share/vm/runtime/thread.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ class NamedThread: public Thread {
709709
~NamedThread();
710710
// May only be called once per thread.
711711
void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
712+
void initialize_named_thread();
712713
virtual bool is_Named_thread() const { return true; }
713714
virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; }
714715
JavaThread *processed_thread() { return _processed_thread; }

hotspot/src/share/vm/runtime/vmThread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void VMThread::run() {
254254
assert(this == vm_thread(), "check");
255255

256256
this->initialize_thread_local_storage();
257-
this->set_native_thread_name(this->name());
257+
this->initialize_named_thread();
258258
this->record_stack_base_and_size();
259259
// Notify_lock wait checks on active_handles() to rewait in
260260
// case of spurious wakeup, it should wait on the last

hotspot/src/share/vm/utilities/workgroup.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -245,6 +245,7 @@ void GangWorker::run() {
245245
void GangWorker::initialize() {
246246
this->initialize_thread_local_storage();
247247
this->record_stack_base_and_size();
248+
this->initialize_named_thread();
248249
assert(_gang != NULL, "No gang to run in");
249250
os::set_priority(this, NearMaxPriority);
250251
if (TraceWorkGang) {

0 commit comments

Comments
 (0)