Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/z/zAddress.inline.hpp
40957 views
1
/*
2
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
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
29
#include "gc/z/zGlobals.hpp"
30
#include "utilities/globalDefinitions.hpp"
31
#include "utilities/macros.hpp"
32
#include "utilities/powerOfTwo.hpp"
33
34
inline bool ZAddress::is_null(uintptr_t value) {
35
return value == 0;
36
}
37
38
inline bool ZAddress::is_bad(uintptr_t value) {
39
return value & ZAddressBadMask;
40
}
41
42
inline bool ZAddress::is_good(uintptr_t value) {
43
return !is_bad(value) && !is_null(value);
44
}
45
46
inline bool ZAddress::is_good_or_null(uintptr_t value) {
47
// Checking if an address is "not bad" is an optimized version of
48
// checking if it's "good or null", which eliminates an explicit
49
// null check. However, the implicit null check only checks that
50
// the mask bits are zero, not that the entire address is zero.
51
// This means that an address without mask bits would pass through
52
// the barrier as if it was null. This should be harmless as such
53
// addresses should ever be passed through the barrier.
54
const bool result = !is_bad(value);
55
assert((is_good(value) || is_null(value)) == result, "Bad address");
56
return result;
57
}
58
59
inline bool ZAddress::is_weak_bad(uintptr_t value) {
60
return value & ZAddressWeakBadMask;
61
}
62
63
inline bool ZAddress::is_weak_good(uintptr_t value) {
64
return !is_weak_bad(value) && !is_null(value);
65
}
66
67
inline bool ZAddress::is_weak_good_or_null(uintptr_t value) {
68
return !is_weak_bad(value);
69
}
70
71
inline bool ZAddress::is_marked(uintptr_t value) {
72
return value & ZAddressMetadataMarked;
73
}
74
75
inline bool ZAddress::is_marked_or_null(uintptr_t value) {
76
return is_marked(value) || is_null(value);
77
}
78
79
inline bool ZAddress::is_finalizable(uintptr_t value) {
80
return value & ZAddressMetadataFinalizable;
81
}
82
83
inline bool ZAddress::is_finalizable_good(uintptr_t value) {
84
return is_finalizable(value) && is_good(value ^ ZAddressMetadataFinalizable);
85
}
86
87
inline bool ZAddress::is_remapped(uintptr_t value) {
88
return value & ZAddressMetadataRemapped;
89
}
90
91
inline bool ZAddress::is_in(uintptr_t value) {
92
// Check that exactly one non-offset bit is set
93
if (!is_power_of_2(value & ~ZAddressOffsetMask)) {
94
return false;
95
}
96
97
// Check that one of the non-finalizable metadata is set
98
return value & (ZAddressMetadataMask & ~ZAddressMetadataFinalizable);
99
}
100
101
inline uintptr_t ZAddress::offset(uintptr_t value) {
102
return value & ZAddressOffsetMask;
103
}
104
105
inline uintptr_t ZAddress::good(uintptr_t value) {
106
return offset(value) | ZAddressGoodMask;
107
}
108
109
inline uintptr_t ZAddress::good_or_null(uintptr_t value) {
110
return is_null(value) ? 0 : good(value);
111
}
112
113
inline uintptr_t ZAddress::finalizable_good(uintptr_t value) {
114
return offset(value) | ZAddressMetadataFinalizable | ZAddressGoodMask;
115
}
116
117
inline uintptr_t ZAddress::marked(uintptr_t value) {
118
return offset(value) | ZAddressMetadataMarked;
119
}
120
121
inline uintptr_t ZAddress::marked0(uintptr_t value) {
122
return offset(value) | ZAddressMetadataMarked0;
123
}
124
125
inline uintptr_t ZAddress::marked1(uintptr_t value) {
126
return offset(value) | ZAddressMetadataMarked1;
127
}
128
129
inline uintptr_t ZAddress::remapped(uintptr_t value) {
130
return offset(value) | ZAddressMetadataRemapped;
131
}
132
133
inline uintptr_t ZAddress::remapped_or_null(uintptr_t value) {
134
return is_null(value) ? 0 : remapped(value);
135
}
136
137
#endif // SHARE_GC_Z_ZADDRESS_INLINE_HPP
138
139