Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/accessFlags.cpp
32285 views
/*1* Copyright (c) 1997, 2013, 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 "utilities/accessFlags.hpp"27#ifdef TARGET_OS_FAMILY_linux28# include "os_linux.inline.hpp"29#endif30#ifdef TARGET_OS_FAMILY_solaris31# include "os_solaris.inline.hpp"32#endif33#ifdef TARGET_OS_FAMILY_windows34# include "os_windows.inline.hpp"35#endif36#ifdef TARGET_OS_FAMILY_aix37# include "os_aix.inline.hpp"38#endif39#ifdef TARGET_OS_FAMILY_bsd40# include "os_bsd.inline.hpp"41#endif424344void AccessFlags::atomic_set_bits(jint bits) {45// Atomically update the flags with the bits given46jint old_flags, new_flags, f;47do {48old_flags = _flags;49new_flags = old_flags | bits;50f = Atomic::cmpxchg(new_flags, &_flags, old_flags);51} while(f != old_flags);52}5354void AccessFlags::atomic_clear_bits(jint bits) {55// Atomically update the flags with the bits given56jint old_flags, new_flags, f;57do {58old_flags = _flags;59new_flags = old_flags & ~bits;60f = Atomic::cmpxchg(new_flags, &_flags, old_flags);61} while(f != old_flags);62}6364// Returns true iff this thread succeeded setting the bit.65bool AccessFlags::atomic_set_one_bit(jint bit) {66// Atomically update the flags with the bit given67jint old_flags, new_flags, f;68bool is_setting_bit = false;69do {70old_flags = _flags;71new_flags = old_flags | bit;72is_setting_bit = old_flags != new_flags;73f = Atomic::cmpxchg(new_flags, &_flags, old_flags);74} while(f != old_flags);7576return is_setting_bit;77}7879#if !defined(PRODUCT) || INCLUDE_JVMTI8081void AccessFlags::print_on(outputStream* st) const {82if (is_public ()) st->print("public " );83if (is_private ()) st->print("private " );84if (is_protected ()) st->print("protected " );85if (is_static ()) st->print("static " );86if (is_final ()) st->print("final " );87if (is_synchronized()) st->print("synchronized ");88if (is_volatile ()) st->print("volatile " );89if (is_transient ()) st->print("transient " );90if (is_native ()) st->print("native " );91if (is_interface ()) st->print("interface " );92if (is_abstract ()) st->print("abstract " );93if (is_strict ()) st->print("strict " );94if (is_synthetic ()) st->print("synthetic " );95if (is_old ()) st->print("{old} " );96if (is_obsolete ()) st->print("{obsolete} " );97if (on_stack ()) st->print("{on_stack} " );98}99100#endif // !PRODUCT || INCLUDE_JVMTI101102void accessFlags_init() {103assert(sizeof(AccessFlags) == sizeof(jint), "just checking size of flags");104}105106107