Path: blob/master/src/hotspot/share/gc/z/zBarrierSetNMethod.cpp
40961 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. 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*/2223#include "precompiled.hpp"24#include "code/nmethod.hpp"25#include "gc/z/zBarrierSetNMethod.hpp"26#include "gc/z/zGlobals.hpp"27#include "gc/z/zLock.inline.hpp"28#include "gc/z/zNMethod.hpp"29#include "gc/z/zThreadLocalData.hpp"30#include "logging/log.hpp"31#include "runtime/threadWXSetters.inline.hpp"3233bool ZBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {34ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));35log_trace(nmethod, barrier)("Entered critical zone for %p", nm);3637if (!is_armed(nm)) {38// Some other thread got here first and healed the oops39// and disarmed the nmethod.40return true;41}4243MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));4445if (nm->is_unloading()) {46// We don't need to take the lock when unlinking nmethods from47// the Method, because it is only concurrently unlinked by48// the entry barrier, which acquires the per nmethod lock.49nm->unlink_from_method();5051// We can end up calling nmethods that are unloading52// since we clear compiled ICs lazily. Returning false53// will re-resovle the call and update the compiled IC.54return false;55}5657// Heal oops58ZNMethod::nmethod_oops_barrier(nm);5960// Disarm61disarm(nm);6263return true;64}6566int* ZBarrierSetNMethod::disarmed_value_address() const {67return (int*)ZAddressBadMaskHighOrderBitsAddr;68}6970ByteSize ZBarrierSetNMethod::thread_disarmed_offset() const {71return ZThreadLocalData::nmethod_disarmed_offset();72}737475