Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetNMethod.cpp
40957 views
/*1* Copyright (c) 2019, 2021, 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#include "precompiled.hpp"2526#include "gc/shenandoah/shenandoahBarrierSetNMethod.hpp"27#include "gc/shenandoah/shenandoahClosures.inline.hpp"28#include "gc/shenandoah/shenandoahCodeRoots.hpp"29#include "gc/shenandoah/shenandoahHeap.inline.hpp"30#include "gc/shenandoah/shenandoahLock.hpp"31#include "gc/shenandoah/shenandoahNMethod.inline.hpp"32#include "gc/shenandoah/shenandoahThreadLocalData.hpp"33#include "memory/iterator.hpp"34#include "memory/resourceArea.hpp"35#include "runtime/threadWXSetters.inline.hpp"3637bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {38ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);39assert(lock != NULL, "Must be");40ShenandoahReentrantLocker locker(lock);4142if (!is_armed(nm)) {43// Some other thread got here first and healed the oops44// and disarmed the nmethod.45return true;46}4748MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current());)4950if (nm->is_unloading()) {51// We don't need to take the lock when unlinking nmethods from52// the Method, because it is only concurrently unlinked by53// the entry barrier, which acquires the per nmethod lock.54nm->unlink_from_method();5556// We can end up calling nmethods that are unloading57// since we clear compiled ICs lazily. Returning false58// will re-resovle the call and update the compiled IC.59return false;60}6162// Heal oops and disarm63ShenandoahNMethod::heal_nmethod(nm);64ShenandoahNMethod::disarm_nmethod(nm);65return true;66}6768int ShenandoahBarrierSetNMethod::disarmed_value() const {69return ShenandoahCodeRoots::disarmed_value();70}7172ByteSize ShenandoahBarrierSetNMethod::thread_disarmed_offset() const {73return ShenandoahThreadLocalData::disarmed_value_offset();74}7576int* ShenandoahBarrierSetNMethod::disarmed_value_address() const {77return ShenandoahCodeRoots::disarmed_value_address();78}798081