Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp
40961 views
/*1* Copyright (c) 2020, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHEVACOOMHANDLER_INLINE_HPP25#define SHARE_GC_SHENANDOAH_SHENANDOAHEVACOOMHANDLER_INLINE_HPP2627#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"2829#include "gc/shenandoah/shenandoahHeap.inline.hpp"30#include "gc/shenandoah/shenandoahThreadLocalData.hpp"31#include "runtime/atomic.hpp"3233void ShenandoahEvacOOMHandler::enter_evacuation(Thread* thr) {34jint threads_in_evac = Atomic::load_acquire(&_threads_in_evac);3536uint8_t level = ShenandoahThreadLocalData::push_evac_oom_scope(thr);37if (level == 0) {38// Entering top level scope, register this thread.39register_thread(thr);40} else if (!ShenandoahThreadLocalData::is_oom_during_evac(thr)) {41jint threads_in_evac = Atomic::load_acquire(&_threads_in_evac);42// If OOM is in progress, handle it.43if ((threads_in_evac & OOM_MARKER_MASK) != 0) {44assert((threads_in_evac & ~OOM_MARKER_MASK) > 0, "sanity");45Atomic::dec(&_threads_in_evac);46wait_for_no_evac_threads();47}48}49}5051void ShenandoahEvacOOMHandler::leave_evacuation(Thread* thr) {52uint8_t level = ShenandoahThreadLocalData::pop_evac_oom_scope(thr);53// Not top level, just return54if (level > 1) {55return;56}5758// Leaving top level scope, unregister this thread.59unregister_thread(thr);60}6162ShenandoahEvacOOMScope::ShenandoahEvacOOMScope() :63_thread(Thread::current()) {64ShenandoahHeap::heap()->enter_evacuation(_thread);65}6667ShenandoahEvacOOMScope::ShenandoahEvacOOMScope(Thread* t) :68_thread(t) {69ShenandoahHeap::heap()->enter_evacuation(_thread);70}7172ShenandoahEvacOOMScope::~ShenandoahEvacOOMScope() {73ShenandoahHeap::heap()->leave_evacuation(_thread);74}7576#endif // SHARE_GC_SHENANDOAH_SHENANDOAHEVACOOMHANDLER_INLINE_HPP777879