9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZADDRESS_INLINE_HPP
25 #define SHARE_GC_Z_ZADDRESS_INLINE_HPP
26
27 #include "gc/z/zAddress.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "utilities/macros.hpp"
30
31 inline bool ZAddress::is_null(uintptr_t value) {
32 return value == 0;
33 }
34
35 inline bool ZAddress::is_bad(uintptr_t value) {
36 return value & ZAddressBadMask;
37 }
38
39 inline bool ZAddress::is_good(uintptr_t value) {
40 return !is_bad(value) && !is_null(value);
41 }
42
43 inline bool ZAddress::is_good_or_null(uintptr_t value) {
44 // Checking if an address is "not bad" is an optimized version of
45 // checking if it's "good or null", which eliminates an explicit
46 // null check. However, the implicit null check only checks that
47 // the mask bits are zero, not that the entire address is zero.
48 // This means that an address without mask bits would pass through
62 }
63
64 inline bool ZAddress::is_weak_good_or_null(uintptr_t value) {
65 return !is_weak_bad(value);
66 }
67
68 inline bool ZAddress::is_marked(uintptr_t value) {
69 return value & ZAddressMetadataMarked;
70 }
71
72 inline bool ZAddress::is_finalizable(uintptr_t value) {
73 return value & ZAddressMetadataFinalizable;
74 }
75
76 inline bool ZAddress::is_finalizable_good(uintptr_t value) {
77 return is_finalizable(value) && is_good(value ^ ZAddressMetadataFinalizable);
78 }
79
80 inline bool ZAddress::is_remapped(uintptr_t value) {
81 return value & ZAddressMetadataRemapped;
82 }
83
84 inline uintptr_t ZAddress::address(uintptr_t value) {
85 return value | ZAddressBase;
86 }
87
88 inline uintptr_t ZAddress::offset(uintptr_t value) {
89 return value & ZAddressOffsetMask;
90 }
91
92 inline uintptr_t ZAddress::good(uintptr_t value) {
93 return address(offset(value) | ZAddressGoodMask);
94 }
95
96 inline uintptr_t ZAddress::good_or_null(uintptr_t value) {
97 return is_null(value) ? 0 : good(value);
98 }
99
100 inline uintptr_t ZAddress::finalizable_good(uintptr_t value) {
101 return address(offset(value) | ZAddressMetadataFinalizable | ZAddressGoodMask);
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZADDRESS_INLINE_HPP
25 #define SHARE_GC_Z_ZADDRESS_INLINE_HPP
26
27 #include "gc/z/zAddress.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #include "utilities/macros.hpp"
31
32 inline bool ZAddress::is_null(uintptr_t value) {
33 return value == 0;
34 }
35
36 inline bool ZAddress::is_bad(uintptr_t value) {
37 return value & ZAddressBadMask;
38 }
39
40 inline bool ZAddress::is_good(uintptr_t value) {
41 return !is_bad(value) && !is_null(value);
42 }
43
44 inline bool ZAddress::is_good_or_null(uintptr_t value) {
45 // Checking if an address is "not bad" is an optimized version of
46 // checking if it's "good or null", which eliminates an explicit
47 // null check. However, the implicit null check only checks that
48 // the mask bits are zero, not that the entire address is zero.
49 // This means that an address without mask bits would pass through
63 }
64
65 inline bool ZAddress::is_weak_good_or_null(uintptr_t value) {
66 return !is_weak_bad(value);
67 }
68
69 inline bool ZAddress::is_marked(uintptr_t value) {
70 return value & ZAddressMetadataMarked;
71 }
72
73 inline bool ZAddress::is_finalizable(uintptr_t value) {
74 return value & ZAddressMetadataFinalizable;
75 }
76
77 inline bool ZAddress::is_finalizable_good(uintptr_t value) {
78 return is_finalizable(value) && is_good(value ^ ZAddressMetadataFinalizable);
79 }
80
81 inline bool ZAddress::is_remapped(uintptr_t value) {
82 return value & ZAddressMetadataRemapped;
83 }
84
85 inline bool ZAddress::is_in(uintptr_t value) {
86 // Check that exactly one non-offset bit is set
87 if (!is_power_of_2(value & ~ZAddressOffsetMask)) {
88 return false;
89 }
90
91 // Check that one of the non-finalizable metadata is set
92 return value & (ZAddressMetadataMask & ~ZAddressMetadataFinalizable);
93 }
94
95 inline uintptr_t ZAddress::address(uintptr_t value) {
96 return value | ZAddressBase;
97 }
98
99 inline uintptr_t ZAddress::offset(uintptr_t value) {
100 return value & ZAddressOffsetMask;
101 }
102
103 inline uintptr_t ZAddress::good(uintptr_t value) {
104 return address(offset(value) | ZAddressGoodMask);
105 }
106
107 inline uintptr_t ZAddress::good_or_null(uintptr_t value) {
108 return is_null(value) ? 0 : good(value);
109 }
110
111 inline uintptr_t ZAddress::finalizable_good(uintptr_t value) {
112 return address(offset(value) | ZAddressMetadataFinalizable | ZAddressGoodMask);
|