2380
2381 // We mark this thread_blocked state as a suspend-equivalent so
2382 // that a caller to is_ext_suspend_completed() won't be confused.
2383 // The suspend-equivalent state is cleared by java_suspend_self().
2384 thread->set_suspend_equivalent();
2385
2386 // If the safepoint code sees the _thread_in_native_trans state, it will
2387 // wait until the thread changes to other thread state. There is no
2388 // guarantee on how soon we can obtain the SR_lock and complete the
2389 // self-suspend request. It would be a bad idea to let safepoint wait for
2390 // too long. Temporarily change the state to _thread_blocked to
2391 // let the VM thread know that this thread is ready for GC. The problem
2392 // of changing thread state is that safepoint could happen just after
2393 // java_suspend_self() returns after being resumed, and VM thread will
2394 // see the _thread_blocked state. We must check for safepoint
2395 // after restoring the state and make sure we won't leave while a safepoint
2396 // is in progress.
2397 thread->set_thread_state(_thread_blocked);
2398 thread->java_suspend_self();
2399 thread->set_thread_state(state);
2400 // Make sure new state is seen by VM thread
2401 if (os::is_MP()) {
2402 if (UseMembar) {
2403 // Force a fence between the write above and read below
2404 OrderAccess::fence();
2405 } else {
2406 // Must use this rather than serialization page in particular on Windows
2407 InterfaceSupport::serialize_memory(thread);
2408 }
2409 }
2410 }
2411
2412 if (SafepointSynchronize::do_call_back()) {
2413 // If we are safepointing, then block the caller which may not be
2414 // the same as the target thread (see above).
2415 SafepointSynchronize::block(curJT);
2416 }
2417
2418 if (thread->is_deopt_suspend()) {
2419 thread->clear_deopt_suspend();
2420 RegisterMap map(thread, false);
2421 frame f = thread->last_frame();
2422 while (f.id() != thread->must_deopt_id() && ! f.is_first_frame()) {
2423 f = f.sender(&map);
2424 }
2425 if (f.id() == thread->must_deopt_id()) {
2426 thread->clear_must_deopt_id();
2427 f.deoptimize(thread);
2428 } else {
2429 fatal("missed deoptimization!");
|
2380
2381 // We mark this thread_blocked state as a suspend-equivalent so
2382 // that a caller to is_ext_suspend_completed() won't be confused.
2383 // The suspend-equivalent state is cleared by java_suspend_self().
2384 thread->set_suspend_equivalent();
2385
2386 // If the safepoint code sees the _thread_in_native_trans state, it will
2387 // wait until the thread changes to other thread state. There is no
2388 // guarantee on how soon we can obtain the SR_lock and complete the
2389 // self-suspend request. It would be a bad idea to let safepoint wait for
2390 // too long. Temporarily change the state to _thread_blocked to
2391 // let the VM thread know that this thread is ready for GC. The problem
2392 // of changing thread state is that safepoint could happen just after
2393 // java_suspend_self() returns after being resumed, and VM thread will
2394 // see the _thread_blocked state. We must check for safepoint
2395 // after restoring the state and make sure we won't leave while a safepoint
2396 // is in progress.
2397 thread->set_thread_state(_thread_blocked);
2398 thread->java_suspend_self();
2399 thread->set_thread_state(state);
2400
2401 InterfaceSupport::serialize_thread_state_with_handler(thread);
2402 }
2403
2404 if (SafepointSynchronize::do_call_back()) {
2405 // If we are safepointing, then block the caller which may not be
2406 // the same as the target thread (see above).
2407 SafepointSynchronize::block(curJT);
2408 }
2409
2410 if (thread->is_deopt_suspend()) {
2411 thread->clear_deopt_suspend();
2412 RegisterMap map(thread, false);
2413 frame f = thread->last_frame();
2414 while (f.id() != thread->must_deopt_id() && ! f.is_first_frame()) {
2415 f = f.sender(&map);
2416 }
2417 if (f.id() == thread->must_deopt_id()) {
2418 thread->clear_must_deopt_id();
2419 f.deoptimize(thread);
2420 } else {
2421 fatal("missed deoptimization!");
|