< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 51784 : imported patch syncknobs-04-Knob_ExitRelease


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
1954   // regular Java monitors here if monitor enter-exit matching is broken.
1955   //
1956   // Optionally release any monitors for regular JavaThread exits. This
1957   // is provided as a work around for any bugs in monitor enter-exit
1958   // matching. This can be expensive so it is not enabled by default.
1959   //
1960   // ensure_join() ignores IllegalThreadStateExceptions, and so does
1961   // ObjectSynchronizer::release_monitors_owned_by_thread().
1962   if (exit_type == jni_detach || ObjectMonitor::Knob_ExitRelease) {
1963     // Sanity check even though JNI DetachCurrentThread() would have
1964     // returned JNI_ERR if there was a Java frame. JavaThread exit
1965     // should be done executing Java code by the time we get here.
1966     assert(!this->has_last_Java_frame(),
1967            "should not have a Java frame when detaching or exiting");
1968     ObjectSynchronizer::release_monitors_owned_by_thread(this);
1969     assert(!this->has_pending_exception(), "release_monitors should have cleared");
1970   }
1971 
1972   // These things needs to be done while we are still a Java Thread. Make sure that thread
1973   // is in a consistent state, in case GC happens
1974   assert(_privileged_stack_top == NULL, "must be NULL when we get here");
1975 
1976   if (active_handles() != NULL) {
1977     JNIHandleBlock* block = active_handles();
1978     set_active_handles(NULL);
1979     JNIHandleBlock::release_block(block);
1980   }
1981 
1982   if (free_handle_block() != NULL) {




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
1954   // regular Java monitors here if monitor enter-exit matching is broken.
1955   //
1956   // Optionally release any monitors for regular JavaThread exits. This
1957   // is provided as a work around for any bugs in monitor enter-exit
1958   // matching. This can be expensive so it is not enabled by default.
1959   //
1960   // ensure_join() ignores IllegalThreadStateExceptions, and so does
1961   // ObjectSynchronizer::release_monitors_owned_by_thread().
1962   if (exit_type == jni_detach) {
1963     // Sanity check even though JNI DetachCurrentThread() would have
1964     // returned JNI_ERR if there was a Java frame. JavaThread exit
1965     // should be done executing Java code by the time we get here.
1966     assert(!this->has_last_Java_frame(),
1967            "should not have a Java frame when detaching or exiting");
1968     ObjectSynchronizer::release_monitors_owned_by_thread(this);
1969     assert(!this->has_pending_exception(), "release_monitors should have cleared");
1970   }
1971 
1972   // These things needs to be done while we are still a Java Thread. Make sure that thread
1973   // is in a consistent state, in case GC happens
1974   assert(_privileged_stack_top == NULL, "must be NULL when we get here");
1975 
1976   if (active_handles() != NULL) {
1977     JNIHandleBlock* block = active_handles();
1978     set_active_handles(NULL);
1979     JNIHandleBlock::release_block(block);
1980   }
1981 
1982   if (free_handle_block() != NULL) {


< prev index next >