< prev index next >

src/share/vm/runtime/thread.hpp

Print this page

        

*** 100,109 **** --- 100,115 ---- // - WatcherThread class Thread: public ThreadShadow { friend class VMStructs; private: + + #ifndef USE_LIBRARY_BASED_TLS_ONLY + // Current thread is maintained as a thread-local variable + static THREAD_LOCAL_DECL Thread* _thr_current; + #endif + // Exception handling // (Note: _pending_exception and friends are in ThreadShadow) //oop _pending_exception; // pending exception for current thread // const char* _exception_file; // file information for exception (debugging only) // int _exception_line; // line information for exception (debugging only)
*** 258,268 **** NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot? friend class No_Alloc_Verifier; friend class No_Safepoint_Verifier; friend class Pause_No_Safepoint_Verifier; - friend class ThreadLocalStorage; friend class GC_locker; ThreadLocalAllocBuffer _tlab; // Thread-local eden jlong _allocated_bytes; // Cumulative number of bytes allocated on // the Java heap --- 264,273 ----
*** 305,317 **** // Constructor Thread(); virtual ~Thread(); ! // initializtion ! void initialize_thread_local_storage(); // thread entry point virtual void run(); // Testers virtual bool is_VM_thread() const { return false; } --- 310,325 ---- // Constructor Thread(); virtual ~Thread(); ! // Manage Thread::current() ! void initialize_thread_current(); ! private: ! void clear_thread_current(); // needed for detaching JNI threads + public: // thread entry point virtual void run(); // Testers virtual bool is_VM_thread() const { return false; }
*** 335,348 **** // Casts virtual WorkerThread* as_Worker_thread() const { return NULL; } virtual char* name() const { return (char*)"Unknown thread"; } ! // Returns the current thread static inline Thread* current(); ! // ... without having to include thread.inline.hpp. ! static Thread* current_noinline(); // Common thread operations static void set_priority(Thread* thread, ThreadPriority priority); static ThreadPriority get_priority(const Thread* const thread); static void start(Thread* thread); --- 343,359 ---- // Casts virtual WorkerThread* as_Worker_thread() const { return NULL; } virtual char* name() const { return (char*)"Unknown thread"; } ! // Returns the current thread (ASSERTS if NULL) static inline Thread* current(); ! // Returns the current thread, or NULL if not attached ! static inline Thread* current_or_null(); ! // Returns the current thread, or NULL if not attached, and is ! // safe for use from signal-handlers ! static inline Thread* current_or_null_safe(); // Common thread operations static void set_priority(Thread* thread, ThreadPriority priority); static ThreadPriority get_priority(const Thread* const thread); static void start(Thread* thread);
*** 647,675 **** static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev); static void muxRelease(volatile intptr_t * Lock); }; // Inline implementation of Thread::current() - // Thread::current is "hot" it's called > 128K times in the 1st 500 msecs of - // startup. - // ThreadLocalStorage::thread is warm -- it's called > 16K times in the same - // period. This is inlined in thread_<os_family>.inline.hpp. - inline Thread* Thread::current() { ! #ifdef ASSERT ! // This function is very high traffic. Define PARANOID to enable expensive ! // asserts. ! #ifdef PARANOID ! // Signal handler should call ThreadLocalStorage::get_thread_slow() ! 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 { --- 658,683 ---- static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev); static void muxRelease(volatile intptr_t * Lock); }; // Inline implementation of Thread::current() inline Thread* Thread::current() { ! Thread* current = current_or_null(); ! assert(current != NULL, "Thread::current() called on detached thread"); ! return current; ! } ! ! inline Thread* Thread::current_or_null() { ! #ifndef USE_LIBRARY_BASED_TLS_ONLY ! return _thr_current; ! #else ! return ThreadLocalStorage::thread(); #endif ! } ! ! inline Thread* Thread::current_or_null_safe() { ! return ThreadLocalStorage::thread(); } // Name support for threads. non-JavaThread subclasses with multiple // uniquely named instances should derive from this. class NamedThread: public Thread {
*** 1840,1851 **** 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"); --- 1848,1859 ---- 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 >