Path: blob/master/src/hotspot/share/gc/z/zAddress.inline.hpp
40957 views
/*1* Copyright (c) 2015, 2019, 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#ifndef SHARE_GC_Z_ZADDRESS_INLINE_HPP24#define SHARE_GC_Z_ZADDRESS_INLINE_HPP2526#include "gc/z/zAddress.hpp"2728#include "gc/z/zGlobals.hpp"29#include "utilities/globalDefinitions.hpp"30#include "utilities/macros.hpp"31#include "utilities/powerOfTwo.hpp"3233inline bool ZAddress::is_null(uintptr_t value) {34return value == 0;35}3637inline bool ZAddress::is_bad(uintptr_t value) {38return value & ZAddressBadMask;39}4041inline bool ZAddress::is_good(uintptr_t value) {42return !is_bad(value) && !is_null(value);43}4445inline bool ZAddress::is_good_or_null(uintptr_t value) {46// Checking if an address is "not bad" is an optimized version of47// checking if it's "good or null", which eliminates an explicit48// null check. However, the implicit null check only checks that49// the mask bits are zero, not that the entire address is zero.50// This means that an address without mask bits would pass through51// the barrier as if it was null. This should be harmless as such52// addresses should ever be passed through the barrier.53const bool result = !is_bad(value);54assert((is_good(value) || is_null(value)) == result, "Bad address");55return result;56}5758inline bool ZAddress::is_weak_bad(uintptr_t value) {59return value & ZAddressWeakBadMask;60}6162inline bool ZAddress::is_weak_good(uintptr_t value) {63return !is_weak_bad(value) && !is_null(value);64}6566inline bool ZAddress::is_weak_good_or_null(uintptr_t value) {67return !is_weak_bad(value);68}6970inline bool ZAddress::is_marked(uintptr_t value) {71return value & ZAddressMetadataMarked;72}7374inline bool ZAddress::is_marked_or_null(uintptr_t value) {75return is_marked(value) || is_null(value);76}7778inline bool ZAddress::is_finalizable(uintptr_t value) {79return value & ZAddressMetadataFinalizable;80}8182inline bool ZAddress::is_finalizable_good(uintptr_t value) {83return is_finalizable(value) && is_good(value ^ ZAddressMetadataFinalizable);84}8586inline bool ZAddress::is_remapped(uintptr_t value) {87return value & ZAddressMetadataRemapped;88}8990inline bool ZAddress::is_in(uintptr_t value) {91// Check that exactly one non-offset bit is set92if (!is_power_of_2(value & ~ZAddressOffsetMask)) {93return false;94}9596// Check that one of the non-finalizable metadata is set97return value & (ZAddressMetadataMask & ~ZAddressMetadataFinalizable);98}99100inline uintptr_t ZAddress::offset(uintptr_t value) {101return value & ZAddressOffsetMask;102}103104inline uintptr_t ZAddress::good(uintptr_t value) {105return offset(value) | ZAddressGoodMask;106}107108inline uintptr_t ZAddress::good_or_null(uintptr_t value) {109return is_null(value) ? 0 : good(value);110}111112inline uintptr_t ZAddress::finalizable_good(uintptr_t value) {113return offset(value) | ZAddressMetadataFinalizable | ZAddressGoodMask;114}115116inline uintptr_t ZAddress::marked(uintptr_t value) {117return offset(value) | ZAddressMetadataMarked;118}119120inline uintptr_t ZAddress::marked0(uintptr_t value) {121return offset(value) | ZAddressMetadataMarked0;122}123124inline uintptr_t ZAddress::marked1(uintptr_t value) {125return offset(value) | ZAddressMetadataMarked1;126}127128inline uintptr_t ZAddress::remapped(uintptr_t value) {129return offset(value) | ZAddressMetadataRemapped;130}131132inline uintptr_t ZAddress::remapped_or_null(uintptr_t value) {133return is_null(value) ? 0 : remapped(value);134}135136#endif // SHARE_GC_Z_ZADDRESS_INLINE_HPP137138139