Skip to content

Commit 72ac72f

Browse files
committedOct 4, 2024
8341413: Stop including osThread_os.hpp in the middle of the OSThread class
Reviewed-by: coleenp, dholmes
1 parent 7fa2f22 commit 72ac72f

30 files changed

+368
-450
lines changed
 

‎src/hotspot/os/aix/osThread_aix.cpp

+17-21
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,28 @@
2323
*
2424
*/
2525

26-
// no precompiled headers
27-
28-
#include "memory/allocation.inline.hpp"
29-
#include "runtime/handles.inline.hpp"
30-
#include "runtime/mutexLocker.hpp"
31-
#include "runtime/os.hpp"
26+
#include "precompiled.hpp"
27+
#include "memory/allocation.hpp"
28+
#include "runtime/mutex.hpp"
3229
#include "runtime/osThread.hpp"
33-
#include "runtime/safepoint.hpp"
34-
#include "runtime/vmThread.hpp"
35-
36-
void OSThread::pd_initialize() {
37-
_thread_id = 0;
38-
_kernel_thread_id = 0;
39-
_siginfo = nullptr;
40-
_ucontext = nullptr;
41-
_expanding_stack = 0;
42-
_alt_sig_stack = nullptr;
4330

44-
_last_cpu_times.sys = _last_cpu_times.user = 0L;
31+
#include <signal.h>
4532

33+
OSThread::OSThread()
34+
: _thread_id(0),
35+
_thread_type(),
36+
_kernel_thread_id(0),
37+
_caller_sigmask(),
38+
sr(),
39+
_siginfo(nullptr),
40+
_ucontext(nullptr),
41+
_expanding_stack(0),
42+
_alt_sig_stack(nullptr),
43+
_last_cpu_times(),
44+
_startThread_lock(new Monitor(Mutex::event, "startThread_lock")) {
4645
sigemptyset(&_caller_sigmask);
47-
48-
_startThread_lock = new Monitor(Mutex::event, "startThread_lock");
49-
assert(_startThread_lock != nullptr, "check");
5046
}
5147

52-
void OSThread::pd_destroy() {
48+
OSThread::~OSThread() {
5349
delete _startThread_lock;
5450
}

‎src/hotspot/os/aix/osThread_aix.hpp

+31-30
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@
2626
#ifndef OS_AIX_OSTHREAD_AIX_HPP
2727
#define OS_AIX_OSTHREAD_AIX_HPP
2828

29-
public:
30-
typedef pthread_t thread_id_t;
31-
32-
private:
33-
int _thread_type;
29+
#include "runtime/osThreadBase.hpp"
30+
#include "suspendResume_posix.hpp"
31+
#include "utilities/globalDefinitions.hpp"
3432

35-
public:
33+
class OSThread : public OSThreadBase {
34+
friend class VMStructs;
3635

37-
int thread_type() const {
38-
return _thread_type;
39-
}
40-
void set_thread_type(int type) {
41-
_thread_type = type;
42-
}
36+
typedef pthread_t thread_id_t;
4337

44-
private:
38+
thread_id_t _thread_id;
39+
int _thread_type;
4540

4641
// On AIX, we use the pthread id as OSThread::thread_id and keep the kernel thread id
4742
// separately for diagnostic purposes.
@@ -54,15 +49,27 @@
5449
sigset_t _caller_sigmask; // Caller's signal mask
5550

5651
public:
52+
OSThread();
53+
~OSThread();
54+
55+
int thread_type() const {
56+
return _thread_type;
57+
}
58+
void set_thread_type(int type) {
59+
_thread_type = type;
60+
}
5761

5862
// Methods to save/restore caller's signal mask
5963
sigset_t caller_sigmask() const { return _caller_sigmask; }
6064
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
6165

62-
#ifndef PRODUCT
63-
// Used for debugging, return a unique integer for each thread.
64-
int thread_identifier() const { return _thread_id; }
65-
#endif
66+
thread_id_t thread_id() const {
67+
return _thread_id;
68+
}
69+
void set_thread_id(thread_id_t id) {
70+
_thread_id = id;
71+
}
72+
6673
tid_t kernel_thread_id() const {
6774
return _kernel_thread_id;
6875
}
@@ -71,15 +78,14 @@
7178
}
7279

7380
pthread_t pthread_id() const {
74-
// Here: same as OSThread::thread_id()
81+
// Here: same as thread_id()
7582
return _thread_id;
7683
}
7784

7885
// ***************************************************************
7986
// suspension support.
8087
// ***************************************************************
8188

82-
public:
8389
// flags that support signal based suspend/resume on Aix are in a
8490
// separate class to avoid confusion with many flags in OSThread that
8591
// are used by VM level suspend/resume.
@@ -125,22 +131,17 @@
125131
return _startThread_lock;
126132
}
127133

128-
// ***************************************************************
129-
// Platform dependent initialization and cleanup
130-
// ***************************************************************
131-
132-
private:
133-
134-
void pd_initialize();
135-
void pd_destroy();
136-
137-
public:
138-
139134
// The last measured values of cpu timing to prevent the "stale
140135
// value return" bug in thread_cpu_time.
141136
volatile struct {
142137
jlong sys;
143138
jlong user;
144139
} _last_cpu_times;
145140

141+
// Printing
142+
uintx thread_id_for_printing() const override {
143+
return (uintx)_thread_id;
144+
}
145+
};
146+
146147
#endif // OS_AIX_OSTHREAD_AIX_HPP

‎src/hotspot/os/aix/vmStructs_aix.hpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@
2929
// constants required by the Serviceability Agent. This file is
3030
// referenced by vmStructs.cpp.
3131

32-
#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
33-
34-
#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
32+
#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \
33+
\
34+
/******************************/ \
35+
/* Threads (NOTE: incomplete) */ \
36+
/******************************/ \
37+
nonstatic_field(OSThread, _thread_id, pthread_t) \
38+
39+
#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \
40+
\
41+
/**********************/ \
42+
/* Posix Thread IDs */ \
43+
/**********************/ \
44+
\
45+
declare_unsigned_integer_type(pthread_t)
3546

3647
#define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
3748

‎src/hotspot/os/bsd/osThread_bsd.cpp

+19-17
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,32 @@
2222
*
2323
*/
2424

25-
// no precompiled headers
26-
#include "memory/allocation.inline.hpp"
27-
#include "runtime/mutexLocker.hpp"
25+
#include "precompiled.hpp"
26+
#include "memory/allocation.hpp"
27+
#include "runtime/mutex.hpp"
2828
#include "runtime/osThread.hpp"
2929

3030
#include <signal.h>
3131

32-
void OSThread::pd_initialize() {
32+
OSThread::OSThread()
33+
: _thread_id(
3334
#ifdef __APPLE__
34-
_thread_id = 0;
35+
0
3536
#else
36-
_thread_id = nullptr;
37+
nullptr
3738
#endif
38-
_unique_thread_id = 0;
39-
_pthread_id = nullptr;
40-
_siginfo = nullptr;
41-
_ucontext = nullptr;
42-
_expanding_stack = 0;
43-
_alt_sig_stack = nullptr;
44-
39+
),
40+
_thread_type(),
41+
_pthread_id(nullptr),
42+
_unique_thread_id(0),
43+
_caller_sigmask(),
44+
sr(),
45+
_siginfo(nullptr),
46+
_ucontext(nullptr),
47+
_expanding_stack(0),
48+
_alt_sig_stack(nullptr),
49+
_startThread_lock(new Monitor(Mutex::event, "startThread_lock")) {
4550
sigemptyset(&_caller_sigmask);
46-
47-
_startThread_lock = new Monitor(Mutex::event, "startThread_lock");
48-
assert(_startThread_lock !=nullptr, "check");
4951
}
5052

5153
// Additional thread_id used to correlate threads in SA
@@ -64,6 +66,6 @@ void OSThread::set_unique_thread_id() {
6466
#endif
6567
}
6668

67-
void OSThread::pd_destroy() {
69+
OSThread::~OSThread() {
6870
delete _startThread_lock;
6971
}

‎src/hotspot/os/bsd/osThread_bsd.hpp

+27-29
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,22 @@
2525
#ifndef OS_BSD_OSTHREAD_BSD_HPP
2626
#define OS_BSD_OSTHREAD_BSD_HPP
2727

28-
private:
29-
int _thread_type;
28+
#include "runtime/osThreadBase.hpp"
29+
#include "suspendResume_posix.hpp"
30+
#include "utilities/globalDefinitions.hpp"
3031

31-
public:
32-
33-
int thread_type() const {
34-
return _thread_type;
35-
}
36-
void set_thread_type(int type) {
37-
_thread_type = type;
38-
}
39-
40-
private:
32+
class OSThread : public OSThreadBase {
33+
friend class VMStructs;
4134

4235
#ifdef __APPLE__
4336
typedef thread_t thread_id_t;
4437
#else
4538
typedef pid_t thread_id_t;
4639
#endif
4740

41+
thread_id_t _thread_id;
42+
int _thread_type;
43+
4844
// _pthread_id is the pthread id, which is used by library calls
4945
// (e.g. pthread_kill).
5046
pthread_t _pthread_id;
@@ -57,15 +53,26 @@
5753
sigset_t _caller_sigmask; // Caller's signal mask
5854

5955
public:
56+
OSThread();
57+
~OSThread();
58+
59+
int thread_type() const {
60+
return _thread_type;
61+
}
62+
void set_thread_type(int type) {
63+
_thread_type = type;
64+
}
6065

6166
// Methods to save/restore caller's signal mask
6267
sigset_t caller_sigmask() const { return _caller_sigmask; }
6368
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
6469

65-
#ifndef PRODUCT
66-
// Used for debugging, return a unique integer for each thread.
67-
intptr_t thread_identifier() const { return (intptr_t)_pthread_id; }
68-
#endif
70+
thread_id_t thread_id() const {
71+
return _thread_id;
72+
}
73+
void set_thread_id(thread_id_t id) {
74+
_thread_id = id;
75+
}
6976

7077
pthread_t pthread_id() const {
7178
return _pthread_id;
@@ -80,7 +87,6 @@
8087
// suspension support.
8188
// ***************************************************************
8289

83-
public:
8490
// flags that support signal based suspend/resume on Bsd are in a
8591
// separate class to avoid confusion with many flags in OSThread that
8692
// are used by VM level suspend/resume.
@@ -126,17 +132,9 @@
126132
return _startThread_lock;
127133
}
128134

129-
// ***************************************************************
130-
// Platform dependent initialization and cleanup
131-
// ***************************************************************
132-
133-
private:
134-
135-
void pd_initialize();
136-
void pd_destroy();
137-
138-
// Reconciliation History
139-
// osThread_solaris.hpp 1.24 99/08/27 13:11:54
140-
// End
135+
uintx thread_id_for_printing() const override {
136+
return (uintx)_thread_id;
137+
}
138+
};
141139

142140
#endif // OS_BSD_OSTHREAD_BSD_HPP

‎src/hotspot/os/bsd/vmStructs_bsd.hpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@
3131
// constants required by the Serviceability Agent. This file is
3232
// referenced by vmStructs.cpp.
3333

34-
#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
35-
36-
#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
34+
#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \
35+
\
36+
/******************************/ \
37+
/* Threads (NOTE: incomplete) */ \
38+
/******************************/ \
39+
nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \
40+
nonstatic_field(OSThread, _unique_thread_id, uint64_t)
41+
42+
#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \
43+
\
44+
/**********************/ \
45+
/* Thread IDs */ \
46+
/**********************/ \
47+
\
48+
declare_unsigned_integer_type(OSThread::thread_id_t)
3749

3850
#define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
3951

0 commit comments

Comments
 (0)
Please sign in to comment.