equal
deleted
inserted
replaced
642 } |
642 } |
643 #endif |
643 #endif |
644 |
644 |
645 // Thread start routine for all newly created threads |
645 // Thread start routine for all newly created threads |
646 static void *thread_native_entry(Thread *thread) { |
646 static void *thread_native_entry(Thread *thread) { |
|
647 |
|
648 thread->record_stack_base_and_size(); |
|
649 |
647 // Try to randomize the cache line index of hot stack frames. |
650 // Try to randomize the cache line index of hot stack frames. |
648 // This helps when threads of the same stack traces evict each other's |
651 // This helps when threads of the same stack traces evict each other's |
649 // cache lines. The threads can be either from the same JVM instance, or |
652 // cache lines. The threads can be either from the same JVM instance, or |
650 // from different JVM instances. The benefit is especially true for |
653 // from different JVM instances. The benefit is especially true for |
651 // processors with hyperthreading technology. |
654 // processors with hyperthreading technology. |
694 sync->wait(Mutex::_no_safepoint_check_flag); |
697 sync->wait(Mutex::_no_safepoint_check_flag); |
695 } |
698 } |
696 } |
699 } |
697 |
700 |
698 // call one more level start routine |
701 // call one more level start routine |
699 thread->run(); |
702 thread->call_run(); |
|
703 |
|
704 // Note: at this point the thread object may already have deleted itself. |
|
705 // Prevent dereferencing it from here on out. |
|
706 thread = NULL; |
700 |
707 |
701 log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", |
708 log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", |
702 os::current_thread_id(), (uintx) pthread_self()); |
709 os::current_thread_id(), (uintx) pthread_self()); |
703 |
|
704 // If a thread has not deleted itself ("delete this") as part of its |
|
705 // termination sequence, we have to ensure thread-local-storage is |
|
706 // cleared before we actually terminate. No threads should ever be |
|
707 // deleted asynchronously with respect to their termination. |
|
708 if (Thread::current_or_null_safe() != NULL) { |
|
709 assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); |
|
710 thread->clear_thread_current(); |
|
711 } |
|
712 |
710 |
713 return 0; |
711 return 0; |
714 } |
712 } |
715 |
713 |
716 bool os::create_thread(Thread* thread, ThreadType thr_type, |
714 bool os::create_thread(Thread* thread, ThreadType thr_type, |