1977 JNIHandleBlock::release_block(block);
1978 }
1979
1980 if (free_handle_block() != NULL) {
1981 JNIHandleBlock* block = free_handle_block();
1982 set_free_handle_block(NULL);
1983 JNIHandleBlock::release_block(block);
1984 }
1985
1986 // These have to be removed while this is still a valid thread.
1987 remove_stack_guard_pages();
1988
1989 if (UseTLAB) {
1990 tlab().make_parsable(true); // retire TLAB
1991 }
1992
1993 if (JvmtiEnv::environments_might_exist()) {
1994 JvmtiExport::cleanup_thread(this);
1995 }
1996
1997 BarrierSet::barrier_set()->on_thread_destroy(this);
1998
1999 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2000 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2001 os::current_thread_id());
2002
2003 if (log_is_enabled(Debug, os, thread, timer)) {
2004 _timer_exit_phase3.stop();
2005 _timer_exit_phase4.start();
2006 }
2007 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
2008 Threads::remove(this);
2009
2010 if (log_is_enabled(Debug, os, thread, timer)) {
2011 _timer_exit_phase4.stop();
2012 ResourceMark rm(this);
2013 log_debug(os, thread, timer)("name='%s'"
2014 ", exit-phase1=" JLONG_FORMAT
2015 ", exit-phase2=" JLONG_FORMAT
2016 ", exit-phase3=" JLONG_FORMAT
2017 ", exit-phase4=" JLONG_FORMAT,
2026 void JavaThread::cleanup_failed_attach_current_thread() {
2027 if (active_handles() != NULL) {
2028 JNIHandleBlock* block = active_handles();
2029 set_active_handles(NULL);
2030 JNIHandleBlock::release_block(block);
2031 }
2032
2033 if (free_handle_block() != NULL) {
2034 JNIHandleBlock* block = free_handle_block();
2035 set_free_handle_block(NULL);
2036 JNIHandleBlock::release_block(block);
2037 }
2038
2039 // These have to be removed while this is still a valid thread.
2040 remove_stack_guard_pages();
2041
2042 if (UseTLAB) {
2043 tlab().make_parsable(true); // retire TLAB, if any
2044 }
2045
2046 BarrierSet::barrier_set()->on_thread_destroy(this);
2047
2048 Threads::remove(this);
2049 this->smr_delete();
2050 }
2051
2052 JavaThread* JavaThread::active() {
2053 Thread* thread = Thread::current();
2054 if (thread->is_Java_thread()) {
2055 return (JavaThread*) thread;
2056 } else {
2057 assert(thread->is_VM_thread(), "this must be a vm thread");
2058 VM_Operation* op = ((VMThread*) thread)->vm_operation();
2059 JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2060 assert(ret->is_Java_thread(), "must be a Java thread");
2061 return ret;
2062 }
2063 }
2064
2065 bool JavaThread::is_lock_owned(address adr) const {
2066 if (Thread::is_lock_owned(adr)) return true;
4285 if (version == JNI_VERSION_1_1) return JNI_TRUE;
4286 return is_supported_jni_version(version);
4287 }
4288
4289
4290 jboolean Threads::is_supported_jni_version(jint version) {
4291 if (version == JNI_VERSION_1_2) return JNI_TRUE;
4292 if (version == JNI_VERSION_1_4) return JNI_TRUE;
4293 if (version == JNI_VERSION_1_6) return JNI_TRUE;
4294 if (version == JNI_VERSION_1_8) return JNI_TRUE;
4295 if (version == JNI_VERSION_9) return JNI_TRUE;
4296 if (version == JNI_VERSION_10) return JNI_TRUE;
4297 return JNI_FALSE;
4298 }
4299
4300
4301 void Threads::add(JavaThread* p, bool force_daemon) {
4302 // The threads lock must be owned at this point
4303 assert_locked_or_safepoint(Threads_lock);
4304
4305 BarrierSet::barrier_set()->on_thread_create(p);
4306
4307 p->set_next(_thread_list);
4308 _thread_list = p;
4309
4310 // Once a JavaThread is added to the Threads list, smr_delete() has
4311 // to be used to delete it. Otherwise we can just delete it directly.
4312 p->set_on_thread_list();
4313
4314 _number_of_threads++;
4315 oop threadObj = p->threadObj();
4316 bool daemon = true;
4317 // Bootstrapping problem: threadObj can be null for initial
4318 // JavaThread (or for threads attached via JNI)
4319 if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4320 _number_of_non_daemon_threads++;
4321 daemon = false;
4322 }
4323
4324 ThreadService::add_thread(p, daemon);
4325
|
1977 JNIHandleBlock::release_block(block);
1978 }
1979
1980 if (free_handle_block() != NULL) {
1981 JNIHandleBlock* block = free_handle_block();
1982 set_free_handle_block(NULL);
1983 JNIHandleBlock::release_block(block);
1984 }
1985
1986 // These have to be removed while this is still a valid thread.
1987 remove_stack_guard_pages();
1988
1989 if (UseTLAB) {
1990 tlab().make_parsable(true); // retire TLAB
1991 }
1992
1993 if (JvmtiEnv::environments_might_exist()) {
1994 JvmtiExport::cleanup_thread(this);
1995 }
1996
1997 BarrierSet::barrier_set()->on_thread_detach(this);
1998
1999 log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2000 exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2001 os::current_thread_id());
2002
2003 if (log_is_enabled(Debug, os, thread, timer)) {
2004 _timer_exit_phase3.stop();
2005 _timer_exit_phase4.start();
2006 }
2007 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
2008 Threads::remove(this);
2009
2010 if (log_is_enabled(Debug, os, thread, timer)) {
2011 _timer_exit_phase4.stop();
2012 ResourceMark rm(this);
2013 log_debug(os, thread, timer)("name='%s'"
2014 ", exit-phase1=" JLONG_FORMAT
2015 ", exit-phase2=" JLONG_FORMAT
2016 ", exit-phase3=" JLONG_FORMAT
2017 ", exit-phase4=" JLONG_FORMAT,
2026 void JavaThread::cleanup_failed_attach_current_thread() {
2027 if (active_handles() != NULL) {
2028 JNIHandleBlock* block = active_handles();
2029 set_active_handles(NULL);
2030 JNIHandleBlock::release_block(block);
2031 }
2032
2033 if (free_handle_block() != NULL) {
2034 JNIHandleBlock* block = free_handle_block();
2035 set_free_handle_block(NULL);
2036 JNIHandleBlock::release_block(block);
2037 }
2038
2039 // These have to be removed while this is still a valid thread.
2040 remove_stack_guard_pages();
2041
2042 if (UseTLAB) {
2043 tlab().make_parsable(true); // retire TLAB, if any
2044 }
2045
2046 BarrierSet::barrier_set()->on_thread_detach(this);
2047
2048 Threads::remove(this);
2049 this->smr_delete();
2050 }
2051
2052 JavaThread* JavaThread::active() {
2053 Thread* thread = Thread::current();
2054 if (thread->is_Java_thread()) {
2055 return (JavaThread*) thread;
2056 } else {
2057 assert(thread->is_VM_thread(), "this must be a vm thread");
2058 VM_Operation* op = ((VMThread*) thread)->vm_operation();
2059 JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2060 assert(ret->is_Java_thread(), "must be a Java thread");
2061 return ret;
2062 }
2063 }
2064
2065 bool JavaThread::is_lock_owned(address adr) const {
2066 if (Thread::is_lock_owned(adr)) return true;
4285 if (version == JNI_VERSION_1_1) return JNI_TRUE;
4286 return is_supported_jni_version(version);
4287 }
4288
4289
4290 jboolean Threads::is_supported_jni_version(jint version) {
4291 if (version == JNI_VERSION_1_2) return JNI_TRUE;
4292 if (version == JNI_VERSION_1_4) return JNI_TRUE;
4293 if (version == JNI_VERSION_1_6) return JNI_TRUE;
4294 if (version == JNI_VERSION_1_8) return JNI_TRUE;
4295 if (version == JNI_VERSION_9) return JNI_TRUE;
4296 if (version == JNI_VERSION_10) return JNI_TRUE;
4297 return JNI_FALSE;
4298 }
4299
4300
4301 void Threads::add(JavaThread* p, bool force_daemon) {
4302 // The threads lock must be owned at this point
4303 assert_locked_or_safepoint(Threads_lock);
4304
4305 BarrierSet::barrier_set()->on_thread_attach(p);
4306
4307 p->set_next(_thread_list);
4308 _thread_list = p;
4309
4310 // Once a JavaThread is added to the Threads list, smr_delete() has
4311 // to be used to delete it. Otherwise we can just delete it directly.
4312 p->set_on_thread_list();
4313
4314 _number_of_threads++;
4315 oop threadObj = p->threadObj();
4316 bool daemon = true;
4317 // Bootstrapping problem: threadObj can be null for initial
4318 // JavaThread (or for threads attached via JNI)
4319 if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4320 _number_of_non_daemon_threads++;
4321 daemon = false;
4322 }
4323
4324 ThreadService::add_thread(p, daemon);
4325
|