Path: blob/master/src/hotspot/share/utilities/accessFlags.cpp
40949 views
/*1* Copyright (c) 1997, 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*22*/2324#include "precompiled.hpp"25#include "oops/oop.inline.hpp"26#include "runtime/atomic.hpp"27#include "utilities/accessFlags.hpp"2829void AccessFlags::atomic_set_bits(jint bits) {30// Atomically update the flags with the bits given31jint old_flags, new_flags, f;32do {33old_flags = _flags;34new_flags = old_flags | bits;35f = Atomic::cmpxchg(&_flags, old_flags, new_flags);36} while(f != old_flags);37}3839void AccessFlags::atomic_clear_bits(jint bits) {40// Atomically update the flags with the bits given41jint old_flags, new_flags, f;42do {43old_flags = _flags;44new_flags = old_flags & ~bits;45f = Atomic::cmpxchg(&_flags, old_flags, new_flags);46} while(f != old_flags);47}484950#if !defined(PRODUCT) || INCLUDE_JVMTI5152void AccessFlags::print_on(outputStream* st) const {53if (is_public ()) st->print("public " );54if (is_private ()) st->print("private " );55if (is_protected ()) st->print("protected " );56if (is_static ()) st->print("static " );57if (is_final ()) st->print("final " );58if (is_synchronized()) st->print("synchronized ");59if (is_volatile ()) st->print("volatile " );60if (is_transient ()) st->print("transient " );61if (is_native ()) st->print("native " );62if (is_interface ()) st->print("interface " );63if (is_abstract ()) st->print("abstract " );64if (is_synthetic ()) st->print("synthetic " );65if (is_old ()) st->print("{old} " );66if (is_obsolete ()) st->print("{obsolete} " );67if (on_stack ()) st->print("{on_stack} " );68}6970#endif // !PRODUCT || INCLUDE_JVMTI7172void accessFlags_init() {73assert(sizeof(AccessFlags) == sizeof(jint), "just checking size of flags");74}757677