< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page




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) {
1983     JNIHandleBlock* block = free_handle_block();
1984     set_free_handle_block(NULL);
1985     JNIHandleBlock::release_block(block);
1986   }
1987 
1988   // These have to be removed while this is still a valid thread.
1989   remove_stack_guard_pages();
1990 
1991   if (UseTLAB) {
1992     tlab().make_parsable(true);  // retire TLAB
1993   }
1994 
1995   if (JvmtiEnv::environments_might_exist()) {
1996     JvmtiExport::cleanup_thread(this);
1997   }
1998 
1999   // We must flush any deferred card marks and other various GC barrier
2000   // related buffers (e.g. G1 SATB buffer and G1 dirty card queue buffer)
2001   // before removing a thread from the list of active threads.
2002   BarrierSet::barrier_set()->on_thread_detach(this);
2003 
2004   log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2005     exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2006     os::current_thread_id());
2007 
2008   if (log_is_enabled(Debug, os, thread, timer)) {
2009     _timer_exit_phase3.stop();
2010     _timer_exit_phase4.start();
2011   }
2012   // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread


2028   }
2029 }
2030 
2031 void JavaThread::cleanup_failed_attach_current_thread() {
2032   if (active_handles() != NULL) {
2033     JNIHandleBlock* block = active_handles();
2034     set_active_handles(NULL);
2035     JNIHandleBlock::release_block(block);
2036   }
2037 
2038   if (free_handle_block() != NULL) {
2039     JNIHandleBlock* block = free_handle_block();
2040     set_free_handle_block(NULL);
2041     JNIHandleBlock::release_block(block);
2042   }
2043 
2044   // These have to be removed while this is still a valid thread.
2045   remove_stack_guard_pages();
2046 
2047   if (UseTLAB) {
2048     tlab().make_parsable(true);  // retire TLAB, if any
2049   }
2050 
2051   BarrierSet::barrier_set()->on_thread_detach(this);
2052 
2053   Threads::remove(this);
2054   this->smr_delete();
2055 }
2056 
2057 JavaThread* JavaThread::active() {
2058   Thread* thread = Thread::current();
2059   if (thread->is_Java_thread()) {
2060     return (JavaThread*) thread;
2061   } else {
2062     assert(thread->is_VM_thread(), "this must be a vm thread");
2063     VM_Operation* op = ((VMThread*) thread)->vm_operation();
2064     JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2065     assert(ret->is_Java_thread(), "must be a Java thread");
2066     return ret;
2067   }
2068 }




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) {
1983     JNIHandleBlock* block = free_handle_block();
1984     set_free_handle_block(NULL);
1985     JNIHandleBlock::release_block(block);
1986   }
1987 
1988   // These have to be removed while this is still a valid thread.
1989   remove_stack_guard_pages();
1990 
1991   if (UseTLAB) {
1992     tlab().retire();
1993   }
1994 
1995   if (JvmtiEnv::environments_might_exist()) {
1996     JvmtiExport::cleanup_thread(this);
1997   }
1998 
1999   // We must flush any deferred card marks and other various GC barrier
2000   // related buffers (e.g. G1 SATB buffer and G1 dirty card queue buffer)
2001   // before removing a thread from the list of active threads.
2002   BarrierSet::barrier_set()->on_thread_detach(this);
2003 
2004   log_info(os, thread)("JavaThread %s (tid: " UINTX_FORMAT ").",
2005     exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
2006     os::current_thread_id());
2007 
2008   if (log_is_enabled(Debug, os, thread, timer)) {
2009     _timer_exit_phase3.stop();
2010     _timer_exit_phase4.start();
2011   }
2012   // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread


2028   }
2029 }
2030 
2031 void JavaThread::cleanup_failed_attach_current_thread() {
2032   if (active_handles() != NULL) {
2033     JNIHandleBlock* block = active_handles();
2034     set_active_handles(NULL);
2035     JNIHandleBlock::release_block(block);
2036   }
2037 
2038   if (free_handle_block() != NULL) {
2039     JNIHandleBlock* block = free_handle_block();
2040     set_free_handle_block(NULL);
2041     JNIHandleBlock::release_block(block);
2042   }
2043 
2044   // These have to be removed while this is still a valid thread.
2045   remove_stack_guard_pages();
2046 
2047   if (UseTLAB) {
2048     tlab().retire();
2049   }
2050 
2051   BarrierSet::barrier_set()->on_thread_detach(this);
2052 
2053   Threads::remove(this);
2054   this->smr_delete();
2055 }
2056 
2057 JavaThread* JavaThread::active() {
2058   Thread* thread = Thread::current();
2059   if (thread->is_Java_thread()) {
2060     return (JavaThread*) thread;
2061   } else {
2062     assert(thread->is_VM_thread(), "this must be a vm thread");
2063     VM_Operation* op = ((VMThread*) thread)->vm_operation();
2064     JavaThread *ret=op == NULL ? NULL : (JavaThread *)op->calling_thread();
2065     assert(ret->is_Java_thread(), "must be a Java thread");
2066     return ret;
2067   }
2068 }


< prev index next >