< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp

Print this page

        

*** 36,56 **** ShenandoahEvacOOMHandler::ShenandoahEvacOOMHandler() : _threads_in_evac(0) { } void ShenandoahEvacOOMHandler::wait_for_no_evac_threads() { ! while ((OrderAccess::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) != 0) { os::naked_short_sleep(1); } // At this point we are sure that no threads can evacuate anything. Raise // the thread-local oom_during_evac flag to indicate that any attempt // to evacuate should simply return the forwarding pointer instead (which is safe now). ShenandoahThreadLocalData::set_oom_during_evac(Thread::current(), true); } void ShenandoahEvacOOMHandler::enter_evacuation() { ! jint threads_in_evac = OrderAccess::load_acquire(&_threads_in_evac); assert(!ShenandoahThreadLocalData::is_evac_allowed(Thread::current()), "sanity"); assert(!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current()), "TL oom-during-evac must not be set"); if ((threads_in_evac & OOM_MARKER_MASK) != 0) { --- 36,56 ---- ShenandoahEvacOOMHandler::ShenandoahEvacOOMHandler() : _threads_in_evac(0) { } void ShenandoahEvacOOMHandler::wait_for_no_evac_threads() { ! while ((Atomic::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) != 0) { os::naked_short_sleep(1); } // At this point we are sure that no threads can evacuate anything. Raise // the thread-local oom_during_evac flag to indicate that any attempt // to evacuate should simply return the forwarding pointer instead (which is safe now). ShenandoahThreadLocalData::set_oom_during_evac(Thread::current(), true); } void ShenandoahEvacOOMHandler::enter_evacuation() { ! jint threads_in_evac = Atomic::load_acquire(&_threads_in_evac); assert(!ShenandoahThreadLocalData::is_evac_allowed(Thread::current()), "sanity"); assert(!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current()), "TL oom-during-evac must not be set"); if ((threads_in_evac & OOM_MARKER_MASK) != 0) {
*** 77,87 **** } } void ShenandoahEvacOOMHandler::leave_evacuation() { if (!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current())) { ! assert((OrderAccess::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) > 0, "sanity"); // NOTE: It's ok to simply decrement, even with mask set, because unmasked value is positive. Atomic::dec(&_threads_in_evac); } else { // If we get here, the current thread has already gone through the // OOM-during-evac protocol and has thus either never entered or successfully left --- 77,87 ---- } } void ShenandoahEvacOOMHandler::leave_evacuation() { if (!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current())) { ! assert((Atomic::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) > 0, "sanity"); // NOTE: It's ok to simply decrement, even with mask set, because unmasked value is positive. Atomic::dec(&_threads_in_evac); } else { // If we get here, the current thread has already gone through the // OOM-during-evac protocol and has thus either never entered or successfully left
*** 94,104 **** void ShenandoahEvacOOMHandler::handle_out_of_memory_during_evacuation() { assert(ShenandoahThreadLocalData::is_evac_allowed(Thread::current()), "sanity"); assert(!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current()), "TL oom-during-evac must not be set"); ! jint threads_in_evac = OrderAccess::load_acquire(&_threads_in_evac); while (true) { jint other = Atomic::cmpxchg((threads_in_evac - 1) | OOM_MARKER_MASK, &_threads_in_evac, threads_in_evac); if (other == threads_in_evac) { // Success: wait for other threads to get out of the protocol and return. --- 94,104 ---- void ShenandoahEvacOOMHandler::handle_out_of_memory_during_evacuation() { assert(ShenandoahThreadLocalData::is_evac_allowed(Thread::current()), "sanity"); assert(!ShenandoahThreadLocalData::is_oom_during_evac(Thread::current()), "TL oom-during-evac must not be set"); ! jint threads_in_evac = Atomic::load_acquire(&_threads_in_evac); while (true) { jint other = Atomic::cmpxchg((threads_in_evac - 1) | OOM_MARKER_MASK, &_threads_in_evac, threads_in_evac); if (other == threads_in_evac) { // Success: wait for other threads to get out of the protocol and return.
*** 111,122 **** } } void ShenandoahEvacOOMHandler::clear() { assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at a safepoint"); ! assert((OrderAccess::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) == 0, "sanity"); ! OrderAccess::release_store_fence<jint>(&_threads_in_evac, 0); } ShenandoahEvacOOMScope::ShenandoahEvacOOMScope() { ShenandoahHeap::heap()->enter_evacuation(); } --- 111,122 ---- } } void ShenandoahEvacOOMHandler::clear() { assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at a safepoint"); ! assert((Atomic::load_acquire(&_threads_in_evac) & ~OOM_MARKER_MASK) == 0, "sanity"); ! Atomic::release_store_fence<jint>(&_threads_in_evac, 0); } ShenandoahEvacOOMScope::ShenandoahEvacOOMScope() { ShenandoahHeap::heap()->enter_evacuation(); }
< prev index next >