< prev index next >
src/share/vm/runtime/thread.hpp
Print this page
rev 9380 : 8237499: JFR: Include stack trace in the ThreadStart event
Reviewed-by: egahlin
*** 329,338 ****
--- 329,339 ----
virtual char* name() const { return (char*)"Unknown thread"; }
// Returns the current thread
static inline Thread* current();
+ static inline Thread* current_or_null();
// Common thread operations
static void set_priority(Thread* thread, ThreadPriority priority);
static ThreadPriority get_priority(const Thread* const thread);
static void start(Thread* thread);
*** 676,688 ****
Thread* t = ThreadLocalStorage::get_thread_slow();
assert(t != NULL && !t->is_inside_signal_handler(),
"Don't use Thread::current() inside signal handler");
#endif
#endif
! Thread* thread = ThreadLocalStorage::thread();
! assert(thread != NULL, "just checking");
! return thread;
}
// Name support for threads. non-JavaThread subclasses with multiple
// uniquely named instances should derive from this.
class NamedThread: public Thread {
--- 677,696 ----
Thread* t = ThreadLocalStorage::get_thread_slow();
assert(t != NULL && !t->is_inside_signal_handler(),
"Don't use Thread::current() inside signal handler");
#endif
#endif
! Thread* current = current_or_null();
! assert(current != NULL, "Thread::current() called on detached thread");
! return current;
! }
!
! inline Thread* Thread::current_or_null() {
! if (ThreadLocalStorage::is_initialized()) {
! return ThreadLocalStorage::thread();
! }
! return NULL;
}
// Name support for threads. non-JavaThread subclasses with multiple
// uniquely named instances should derive from this.
class NamedThread: public Thread {
*** 1772,1783 ****
void set_claimed_par_id(uint id) { _claimed_par_id = id;}
};
// Inline implementation of JavaThread::current
inline JavaThread* JavaThread::current() {
! Thread* thread = ThreadLocalStorage::thread();
! assert(thread != NULL && thread->is_Java_thread(), "just checking");
return (JavaThread*)thread;
}
inline CompilerThread* JavaThread::as_CompilerThread() {
assert(is_Compiler_thread(), "just checking");
--- 1780,1791 ----
void set_claimed_par_id(uint id) { _claimed_par_id = id;}
};
// Inline implementation of JavaThread::current
inline JavaThread* JavaThread::current() {
! Thread* thread = Thread::current();
! assert(thread->is_Java_thread(), "just checking");
return (JavaThread*)thread;
}
inline CompilerThread* JavaThread::as_CompilerThread() {
assert(is_Compiler_thread(), "just checking");
< prev index next >