Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 20393:966601b12d4f
8057535: add a thread extension class
Reviewed-by: mgerdin, bdelsart, jcoomes
author | sla |
---|---|
date | Thu, 04 Sep 2014 11:21:08 +0200 |
parents | 833b0f92429a |
children | 46f9331baed5 |
comparison
equal
deleted
inserted
replaced
20392:66d359ee9681 | 20393:966601b12d4f |
---|---|
858 int os_prio; | 858 int os_prio; |
859 if (os::get_native_priority(this, &os_prio) == OS_OK) { | 859 if (os::get_native_priority(this, &os_prio) == OS_OK) { |
860 st->print("os_prio=%d ", os_prio); | 860 st->print("os_prio=%d ", os_prio); |
861 } | 861 } |
862 st->print("tid=" INTPTR_FORMAT " ", this); | 862 st->print("tid=" INTPTR_FORMAT " ", this); |
863 ext().print_on(st); | |
863 osthread()->print_on(st); | 864 osthread()->print_on(st); |
864 } | 865 } |
865 debug_only(if (WizardMode) print_owned_locks_on(st);) | 866 debug_only(if (WizardMode) print_owned_locks_on(st);) |
866 } | 867 } |
867 | 868 |
3019 } | 3020 } |
3020 | 3021 |
3021 // Push the Java priority down to the native thread; needs Threads_lock | 3022 // Push the Java priority down to the native thread; needs Threads_lock |
3022 Thread::set_priority(this, prio); | 3023 Thread::set_priority(this, prio); |
3023 | 3024 |
3025 prepare_ext(); | |
3026 | |
3024 // Add the new thread to the Threads list and set it in motion. | 3027 // Add the new thread to the Threads list and set it in motion. |
3025 // We must have threads lock in order to call Threads::add. | 3028 // We must have threads lock in order to call Threads::add. |
3026 // It is crucial that we do not block before the thread is | 3029 // It is crucial that we do not block before the thread is |
3027 // added to the Threads list for if a GC happens, then the java_thread oop | 3030 // added to the Threads list for if a GC happens, then the java_thread oop |
3028 // will not be visited by GC. | 3031 // will not be visited by GC. |
3872 } else { | 3875 } else { |
3873 vm_exit_during_initialization("Could not find JVM_OnLoad function in -Xrun library", agent->name()); | 3876 vm_exit_during_initialization("Could not find JVM_OnLoad function in -Xrun library", agent->name()); |
3874 } | 3877 } |
3875 } | 3878 } |
3876 } | 3879 } |
3880 | |
3881 JavaThread* Threads::find_java_thread_from_java_tid(jlong java_tid) { | |
3882 assert(Threads_lock->owned_by_self(), "Must hold Threads_lock"); | |
3883 | |
3884 JavaThread* java_thread = NULL; | |
3885 // Sequential search for now. Need to do better optimization later. | |
3886 for (JavaThread* thread = Threads::first(); thread != NULL; thread = thread->next()) { | |
3887 oop tobj = thread->threadObj(); | |
3888 if (!thread->is_exiting() && | |
3889 tobj != NULL && | |
3890 java_tid == java_lang_Thread::thread_id(tobj)) { | |
3891 java_thread = thread; | |
3892 break; | |
3893 } | |
3894 } | |
3895 return java_thread; | |
3896 } | |
3897 | |
3877 | 3898 |
3878 // Last thread running calls java.lang.Shutdown.shutdown() | 3899 // Last thread running calls java.lang.Shutdown.shutdown() |
3879 void JavaThread::invoke_shutdown_hooks() { | 3900 void JavaThread::invoke_shutdown_hooks() { |
3880 HandleMark hm(this); | 3901 HandleMark hm(this); |
3881 | 3902 |