< prev index next >

src/share/vm/runtime/thread.cpp

Print this page
rev 13201 : imported patch 8183545


2175     // }
2176     // set_thread_state(_thread_in_vm_trans);
2177     // if (safepoint) block;
2178     // set_thread_state(state);
2179     //
2180     // but that is pretty messy. Instead we just go with the way the
2181     // code has worked before and note that this is the only path to
2182     // java_suspend_self that doesn't put the thread in _thread_blocked
2183     // mode.
2184 
2185     frame_anchor()->make_walkable(this);
2186     java_suspend_self();
2187 
2188     // We might be here for reasons in addition to the self-suspend request
2189     // so check for other async requests.
2190   }
2191 
2192   if (check_asyncs) {
2193     check_and_handle_async_exceptions();
2194   }





2195 }
2196 
2197 void JavaThread::send_thread_stop(oop java_throwable)  {
2198   assert(Thread::current()->is_VM_thread(), "should be in the vm thread");
2199   assert(Threads_lock->is_locked(), "Threads_lock should be locked by safepoint code");
2200   assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");
2201 
2202   // Do not throw asynchronous exceptions against the compiler thread
2203   // (the compiler thread should not be a Java thread -- fix in 1.4.2)
2204   if (!can_call_java()) return;
2205 
2206   {
2207     // Actually throw the Throwable against the target Thread - however
2208     // only if there is no thread death exception installed already.
2209     if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) {
2210       // If the topmost frame is a runtime stub, then we are calling into
2211       // OptoRuntime from compiled code. Some runtime stubs (new, monitor_exit..)
2212       // must deoptimize the caller before continuing, as the compiled  exception handler table
2213       // may not be valid
2214       if (has_last_Java_frame()) {


2405   if (SafepointSynchronize::do_call_back()) {
2406     // If we are safepointing, then block the caller which may not be
2407     // the same as the target thread (see above).
2408     SafepointSynchronize::block(curJT);
2409   }
2410 
2411   if (thread->is_deopt_suspend()) {
2412     thread->clear_deopt_suspend();
2413     RegisterMap map(thread, false);
2414     frame f = thread->last_frame();
2415     while (f.id() != thread->must_deopt_id() && ! f.is_first_frame()) {
2416       f = f.sender(&map);
2417     }
2418     if (f.id() == thread->must_deopt_id()) {
2419       thread->clear_must_deopt_id();
2420       f.deoptimize(thread);
2421     } else {
2422       fatal("missed deoptimization!");
2423     }
2424   }





2425 }
2426 
2427 // Slow path when the native==>VM/Java barriers detect a safepoint is in
2428 // progress or when _suspend_flags is non-zero.
2429 // Current thread needs to self-suspend if there is a suspend request and/or
2430 // block if a safepoint is in progress.
2431 // Also check for pending async exception (not including unsafe access error).
2432 // Note only the native==>VM/Java barriers can call this function and when
2433 // thread state is _thread_in_native_trans.
2434 void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) {
2435   check_safepoint_and_suspend_for_native_trans(thread);
2436 
2437   if (thread->has_async_exception()) {
2438     // We are in _thread_in_native_trans state, don't handle unsafe
2439     // access error since that may block.
2440     thread->check_and_handle_async_exceptions(false);
2441   }
2442 }
2443 
2444 // This is a variant of the normal




2175     // }
2176     // set_thread_state(_thread_in_vm_trans);
2177     // if (safepoint) block;
2178     // set_thread_state(state);
2179     //
2180     // but that is pretty messy. Instead we just go with the way the
2181     // code has worked before and note that this is the only path to
2182     // java_suspend_self that doesn't put the thread in _thread_blocked
2183     // mode.
2184 
2185     frame_anchor()->make_walkable(this);
2186     java_suspend_self();
2187 
2188     // We might be here for reasons in addition to the self-suspend request
2189     // so check for other async requests.
2190   }
2191 
2192   if (check_asyncs) {
2193     check_and_handle_async_exceptions();
2194   }
2195 #if INCLUDE_TRACE
2196   if (is_trace_suspend()) {
2197     TRACE_SUSPEND_THREAD(this);
2198   }
2199 #endif
2200 }
2201 
2202 void JavaThread::send_thread_stop(oop java_throwable)  {
2203   assert(Thread::current()->is_VM_thread(), "should be in the vm thread");
2204   assert(Threads_lock->is_locked(), "Threads_lock should be locked by safepoint code");
2205   assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");
2206 
2207   // Do not throw asynchronous exceptions against the compiler thread
2208   // (the compiler thread should not be a Java thread -- fix in 1.4.2)
2209   if (!can_call_java()) return;
2210 
2211   {
2212     // Actually throw the Throwable against the target Thread - however
2213     // only if there is no thread death exception installed already.
2214     if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) {
2215       // If the topmost frame is a runtime stub, then we are calling into
2216       // OptoRuntime from compiled code. Some runtime stubs (new, monitor_exit..)
2217       // must deoptimize the caller before continuing, as the compiled  exception handler table
2218       // may not be valid
2219       if (has_last_Java_frame()) {


2410   if (SafepointSynchronize::do_call_back()) {
2411     // If we are safepointing, then block the caller which may not be
2412     // the same as the target thread (see above).
2413     SafepointSynchronize::block(curJT);
2414   }
2415 
2416   if (thread->is_deopt_suspend()) {
2417     thread->clear_deopt_suspend();
2418     RegisterMap map(thread, false);
2419     frame f = thread->last_frame();
2420     while (f.id() != thread->must_deopt_id() && ! f.is_first_frame()) {
2421       f = f.sender(&map);
2422     }
2423     if (f.id() == thread->must_deopt_id()) {
2424       thread->clear_must_deopt_id();
2425       f.deoptimize(thread);
2426     } else {
2427       fatal("missed deoptimization!");
2428     }
2429   }
2430 #if INCLUDE_TRACE
2431   if (thread->is_trace_suspend()) {
2432     TRACE_SUSPEND_THREAD(thread);
2433   }
2434 #endif
2435 }
2436 
2437 // Slow path when the native==>VM/Java barriers detect a safepoint is in
2438 // progress or when _suspend_flags is non-zero.
2439 // Current thread needs to self-suspend if there is a suspend request and/or
2440 // block if a safepoint is in progress.
2441 // Also check for pending async exception (not including unsafe access error).
2442 // Note only the native==>VM/Java barriers can call this function and when
2443 // thread state is _thread_in_native_trans.
2444 void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) {
2445   check_safepoint_and_suspend_for_native_trans(thread);
2446 
2447   if (thread->has_async_exception()) {
2448     // We are in _thread_in_native_trans state, don't handle unsafe
2449     // access error since that may block.
2450     thread->check_and_handle_async_exceptions(false);
2451   }
2452 }
2453 
2454 // This is a variant of the normal


< prev index next >