< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 52112 : [mq]: 8021335


1913           ThreadService::current_thread_exiting(this);
1914           break;
1915         }
1916         // Implied else:
1917         // Things get a little tricky here. We have a pending external
1918         // suspend request, but we are holding the SR_lock so we
1919         // can't just self-suspend. So we temporarily drop the lock
1920         // and then self-suspend.
1921       }
1922 
1923       ThreadBlockInVM tbivm(this);
1924       java_suspend_self();
1925 
1926       // We're done with this suspend request, but we have to loop around
1927       // and check again. Eventually we will get SR_lock without a pending
1928       // external suspend request and will be able to mark ourselves as
1929       // exiting.
1930     }
1931     // no more external suspends are allowed at this point
1932   } else {

1933     // before_exit() has already posted JVMTI THREAD_END events
1934   }
1935 
1936   if (log_is_enabled(Debug, os, thread, timer)) {
1937     _timer_exit_phase1.stop();
1938     _timer_exit_phase2.start();
1939   }
1940   // Notify waiters on thread object. This has to be done after exit() is called
1941   // on the thread (if the thread is the last thread in a daemon ThreadGroup the
1942   // group should have the destroyed bit set before waiters are notified).
1943   ensure_join(this);
1944   assert(!this->has_pending_exception(), "ensure_join should have cleared");
1945 
1946   if (log_is_enabled(Debug, os, thread, timer)) {
1947     _timer_exit_phase2.stop();
1948     _timer_exit_phase3.start();
1949   }
1950   // 6282335 JNI DetachCurrentThread spec states that all Java monitors
1951   // held by this thread must be released. The spec does not distinguish
1952   // between JNI-acquired and regular Java monitors. We can only see


4315 
4316 jboolean Threads::is_supported_jni_version_including_1_1(jint version) {
4317   if (version == JNI_VERSION_1_1) return JNI_TRUE;
4318   return is_supported_jni_version(version);
4319 }
4320 
4321 
4322 jboolean Threads::is_supported_jni_version(jint version) {
4323   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4324   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4325   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4326   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4327   if (version == JNI_VERSION_9) return JNI_TRUE;
4328   if (version == JNI_VERSION_10) return JNI_TRUE;
4329   return JNI_FALSE;
4330 }
4331 
4332 
4333 void Threads::add(JavaThread* p, bool force_daemon) {
4334   // The threads lock must be owned at this point
4335   assert_locked_or_safepoint(Threads_lock);
4336 
4337   BarrierSet::barrier_set()->on_thread_attach(p);
4338 
4339   p->set_next(_thread_list);
4340   _thread_list = p;
4341 
4342   // Once a JavaThread is added to the Threads list, smr_delete() has
4343   // to be used to delete it. Otherwise we can just delete it directly.
4344   p->set_on_thread_list();
4345 
4346   _number_of_threads++;
4347   oop threadObj = p->threadObj();
4348   bool daemon = true;
4349   // Bootstrapping problem: threadObj can be null for initial
4350   // JavaThread (or for threads attached via JNI)
4351   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4352     _number_of_non_daemon_threads++;
4353     daemon = false;
4354   }
4355 




1913           ThreadService::current_thread_exiting(this);
1914           break;
1915         }
1916         // Implied else:
1917         // Things get a little tricky here. We have a pending external
1918         // suspend request, but we are holding the SR_lock so we
1919         // can't just self-suspend. So we temporarily drop the lock
1920         // and then self-suspend.
1921       }
1922 
1923       ThreadBlockInVM tbivm(this);
1924       java_suspend_self();
1925 
1926       // We're done with this suspend request, but we have to loop around
1927       // and check again. Eventually we will get SR_lock without a pending
1928       // external suspend request and will be able to mark ourselves as
1929       // exiting.
1930     }
1931     // no more external suspends are allowed at this point
1932   } else {
1933     assert(!is_terminated() && !is_exiting(), "must not be exiting");
1934     // before_exit() has already posted JVMTI THREAD_END events
1935   }
1936 
1937   if (log_is_enabled(Debug, os, thread, timer)) {
1938     _timer_exit_phase1.stop();
1939     _timer_exit_phase2.start();
1940   }
1941   // Notify waiters on thread object. This has to be done after exit() is called
1942   // on the thread (if the thread is the last thread in a daemon ThreadGroup the
1943   // group should have the destroyed bit set before waiters are notified).
1944   ensure_join(this);
1945   assert(!this->has_pending_exception(), "ensure_join should have cleared");
1946 
1947   if (log_is_enabled(Debug, os, thread, timer)) {
1948     _timer_exit_phase2.stop();
1949     _timer_exit_phase3.start();
1950   }
1951   // 6282335 JNI DetachCurrentThread spec states that all Java monitors
1952   // held by this thread must be released. The spec does not distinguish
1953   // between JNI-acquired and regular Java monitors. We can only see


4316 
4317 jboolean Threads::is_supported_jni_version_including_1_1(jint version) {
4318   if (version == JNI_VERSION_1_1) return JNI_TRUE;
4319   return is_supported_jni_version(version);
4320 }
4321 
4322 
4323 jboolean Threads::is_supported_jni_version(jint version) {
4324   if (version == JNI_VERSION_1_2) return JNI_TRUE;
4325   if (version == JNI_VERSION_1_4) return JNI_TRUE;
4326   if (version == JNI_VERSION_1_6) return JNI_TRUE;
4327   if (version == JNI_VERSION_1_8) return JNI_TRUE;
4328   if (version == JNI_VERSION_9) return JNI_TRUE;
4329   if (version == JNI_VERSION_10) return JNI_TRUE;
4330   return JNI_FALSE;
4331 }
4332 
4333 
4334 void Threads::add(JavaThread* p, bool force_daemon) {
4335   // The threads lock must be owned at this point
4336   assert(Threads_lock->owned_by_self(), "must have threads lock");
4337 
4338   BarrierSet::barrier_set()->on_thread_attach(p);
4339 
4340   p->set_next(_thread_list);
4341   _thread_list = p;
4342 
4343   // Once a JavaThread is added to the Threads list, smr_delete() has
4344   // to be used to delete it. Otherwise we can just delete it directly.
4345   p->set_on_thread_list();
4346 
4347   _number_of_threads++;
4348   oop threadObj = p->threadObj();
4349   bool daemon = true;
4350   // Bootstrapping problem: threadObj can be null for initial
4351   // JavaThread (or for threads attached via JNI)
4352   if ((!force_daemon) && (threadObj == NULL || !java_lang_Thread::is_daemon(threadObj))) {
4353     _number_of_non_daemon_threads++;
4354     daemon = false;
4355   }
4356 


< prev index next >