136 MO_ACQUIRE | MO_RELEASE | MO_SEQ_CST;
137
138 // === Barrier Strength Decorators ===
139 // * AS_RAW: The access will translate into a raw memory access, hence ignoring all semantic concerns
140 // except memory ordering and compressed oops. This will bypass runtime function pointer dispatching
141 // in the pipeline and hardwire to raw accesses without going trough the GC access barriers.
142 // - Accesses on oop* translate to raw memory accesses without runtime checks
143 // - Accesses on narrowOop* translate to encoded/decoded memory accesses without runtime checks
144 // - Accesses on HeapWord* translate to a runtime check choosing one of the above
145 // - Accesses on other types translate to raw memory accesses without runtime checks
146 // * AS_NO_KEEPALIVE: The barrier is used only on oop references and will not keep any involved objects
147 // alive, regardless of the type of reference being accessed. It will however perform the memory access
148 // in a consistent way w.r.t. e.g. concurrent compaction, so that the right field is being accessed,
149 // or maintain, e.g. intergenerational or interregional pointers if applicable. This should be used with
150 // extreme caution in isolated scopes.
151 // * AS_NORMAL: The accesses will be resolved to an accessor on the BarrierSet class, giving the
152 // responsibility of performing the access and what barriers to be performed to the GC. This is the default.
153 // Note that primitive accesses will only be resolved on the barrier set if the appropriate build-time
154 // decorator for enabling primitive barriers is enabled for the build.
155 const DecoratorSet AS_RAW = UCONST64(1) << 12;
156 const DecoratorSet AS_NO_KEEPALIVE = UCONST64(1) << 14;
157 const DecoratorSet AS_NORMAL = UCONST64(1) << 15;
158 const DecoratorSet AS_DECORATOR_MASK = AS_RAW | AS_NO_KEEPALIVE | AS_NORMAL;
159
160 // === Reference Strength Decorators ===
161 // These decorators only apply to accesses on oop-like types (oop/narrowOop).
162 // * ON_STRONG_OOP_REF: Memory access is performed on a strongly reachable reference.
163 // * ON_WEAK_OOP_REF: The memory access is performed on a weakly reachable reference.
164 // * ON_PHANTOM_OOP_REF: The memory access is performed on a phantomly reachable reference.
165 // This is the same ring of strength as jweak and weak oops in the VM.
166 // * ON_UNKNOWN_OOP_REF: The memory access is performed on a reference of unknown strength.
167 // This could for example come from the unsafe API.
168 // * Default (no explicit reference strength specified): ON_STRONG_OOP_REF
169 const DecoratorSet ON_STRONG_OOP_REF = UCONST64(1) << 16;
170 const DecoratorSet ON_WEAK_OOP_REF = UCONST64(1) << 17;
171 const DecoratorSet ON_PHANTOM_OOP_REF = UCONST64(1) << 18;
172 const DecoratorSet ON_UNKNOWN_OOP_REF = UCONST64(1) << 19;
173 const DecoratorSet ON_DECORATOR_MASK = ON_STRONG_OOP_REF | ON_WEAK_OOP_REF |
174 ON_PHANTOM_OOP_REF | ON_UNKNOWN_OOP_REF;
175
176 // === Access Location ===
177 // Accesses can take place in, e.g. the heap, old or young generation and different native roots.
178 // The location is important to the GC as it may imply different actions. The following decorators are used:
179 // * IN_HEAP: The access is performed in the heap. Many barriers such as card marking will
180 // be omitted if this decorator is not set.
181 // * IN_NATIVE: The access is performed in an off-heap data structure pointing into the Java heap.
182 // * IN_CONCURRENT_ROOT: The access is performed in an off-heap data structure pointing into the Java heap,
183 // but is notably not scanned during safepoints. This is sometimes a special case for some GCs and
184 // implies that it is also an IN_NATIVE.
185 const DecoratorSet IN_HEAP = UCONST64(1) << 20;
186 const DecoratorSet IN_NATIVE = UCONST64(1) << 22;
187 const DecoratorSet IN_CONCURRENT_ROOT = UCONST64(1) << 23;
188 const DecoratorSet IN_DECORATOR_MASK = IN_HEAP | IN_NATIVE | IN_CONCURRENT_ROOT;
189
190 // == Boolean Flag Decorators ==
191 // * IS_ARRAY: The access is performed on a heap allocated array. This is sometimes a special case
192 // for some GCs.
193 // * IS_DEST_UNINITIALIZED: This property can be important to e.g. SATB barriers by
194 // marking that the previous value is uninitialized nonsense rather than a real value.
195 // * IS_NOT_NULL: This property can make certain barriers faster such as compressing oops.
196 const DecoratorSet IS_ARRAY = UCONST64(1) << 21;
197 const DecoratorSet IS_DEST_UNINITIALIZED = UCONST64(1) << 13;
198 const DecoratorSet IS_NOT_NULL = UCONST64(1) << 25;
199
200 // == Arraycopy Decorators ==
201 // * ARRAYCOPY_CHECKCAST: This property means that the class of the objects in source
202 // are not guaranteed to be subclasses of the class of the destination array. This requires
203 // a check-cast barrier during the copying operation. If this is not set, it is assumed
204 // that the array is covariant: (the source array type is-a destination array type)
205 // * ARRAYCOPY_DISJOINT: This property means that it is known that the two array ranges
206 // are disjoint.
207 // * ARRAYCOPY_ARRAYOF: The copy is in the arrayof form.
208 // * ARRAYCOPY_ATOMIC: The accesses have to be atomic over the size of its elements.
209 // * ARRAYCOPY_ALIGNED: The accesses have to be aligned on a HeapWord.
210 const DecoratorSet ARRAYCOPY_CHECKCAST = UCONST64(1) << 26;
211 const DecoratorSet ARRAYCOPY_DISJOINT = UCONST64(1) << 27;
212 const DecoratorSet ARRAYCOPY_ARRAYOF = UCONST64(1) << 28;
213 const DecoratorSet ARRAYCOPY_ATOMIC = UCONST64(1) << 29;
214 const DecoratorSet ARRAYCOPY_ALIGNED = UCONST64(1) << 30;
215 const DecoratorSet ARRAYCOPY_DECORATOR_MASK = ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT |
216 ARRAYCOPY_DISJOINT | ARRAYCOPY_ARRAYOF |
217 ARRAYCOPY_ATOMIC | ARRAYCOPY_ALIGNED;
218
219 // Keep track of the last decorator.
220 const DecoratorSet DECORATOR_LAST = UCONST64(1) << 30;
221
222 namespace AccessInternal {
223 // This class adds implied decorators that follow according to decorator rules.
224 // For example adding default reference strength and default memory ordering
225 // semantics.
226 template <DecoratorSet input_decorators>
227 struct DecoratorFixup: AllStatic {
228 // If no reference strength has been picked, then strong will be picked
229 static const DecoratorSet ref_strength_default = input_decorators |
230 (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
231 ON_STRONG_OOP_REF : INTERNAL_EMPTY);
232 // If no memory ordering has been picked, unordered will be picked
233 static const DecoratorSet memory_ordering_default = ref_strength_default |
234 ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
235 // If no barrier strength has been picked, normal will be used
236 static const DecoratorSet barrier_strength_default = memory_ordering_default |
237 ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
238 static const DecoratorSet conc_root_is_root = barrier_strength_default |
239 ((IN_CONCURRENT_ROOT & barrier_strength_default) != 0 ? IN_NATIVE : INTERNAL_EMPTY);
240 static const DecoratorSet value = conc_root_is_root | BT_BUILDTIME_DECORATORS;
241 };
242
243 // This function implements the above DecoratorFixup rules, but without meta
244 // programming for code generation that does not use templates.
245 inline DecoratorSet decorator_fixup(DecoratorSet input_decorators) {
246 // If no reference strength has been picked, then strong will be picked
247 DecoratorSet ref_strength_default = input_decorators |
248 (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
249 ON_STRONG_OOP_REF : INTERNAL_EMPTY);
250 // If no memory ordering has been picked, unordered will be picked
251 DecoratorSet memory_ordering_default = ref_strength_default |
252 ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
253 // If no barrier strength has been picked, normal will be used
254 DecoratorSet barrier_strength_default = memory_ordering_default |
255 ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
256 DecoratorSet conc_root_is_root = barrier_strength_default |
257 ((IN_CONCURRENT_ROOT & barrier_strength_default) != 0 ? IN_NATIVE : INTERNAL_EMPTY);
258 DecoratorSet value = conc_root_is_root | BT_BUILDTIME_DECORATORS;
259 return value;
260 }
261 }
262
263 #endif // SHARE_OOPS_ACCESSDECORATORS_HPP
|
136 MO_ACQUIRE | MO_RELEASE | MO_SEQ_CST;
137
138 // === Barrier Strength Decorators ===
139 // * AS_RAW: The access will translate into a raw memory access, hence ignoring all semantic concerns
140 // except memory ordering and compressed oops. This will bypass runtime function pointer dispatching
141 // in the pipeline and hardwire to raw accesses without going trough the GC access barriers.
142 // - Accesses on oop* translate to raw memory accesses without runtime checks
143 // - Accesses on narrowOop* translate to encoded/decoded memory accesses without runtime checks
144 // - Accesses on HeapWord* translate to a runtime check choosing one of the above
145 // - Accesses on other types translate to raw memory accesses without runtime checks
146 // * AS_NO_KEEPALIVE: The barrier is used only on oop references and will not keep any involved objects
147 // alive, regardless of the type of reference being accessed. It will however perform the memory access
148 // in a consistent way w.r.t. e.g. concurrent compaction, so that the right field is being accessed,
149 // or maintain, e.g. intergenerational or interregional pointers if applicable. This should be used with
150 // extreme caution in isolated scopes.
151 // * AS_NORMAL: The accesses will be resolved to an accessor on the BarrierSet class, giving the
152 // responsibility of performing the access and what barriers to be performed to the GC. This is the default.
153 // Note that primitive accesses will only be resolved on the barrier set if the appropriate build-time
154 // decorator for enabling primitive barriers is enabled for the build.
155 const DecoratorSet AS_RAW = UCONST64(1) << 12;
156 const DecoratorSet AS_NO_KEEPALIVE = UCONST64(1) << 13;
157 const DecoratorSet AS_NORMAL = UCONST64(1) << 14;
158 const DecoratorSet AS_DECORATOR_MASK = AS_RAW | AS_NO_KEEPALIVE | AS_NORMAL;
159
160 // === Reference Strength Decorators ===
161 // These decorators only apply to accesses on oop-like types (oop/narrowOop).
162 // * ON_STRONG_OOP_REF: Memory access is performed on a strongly reachable reference.
163 // * ON_WEAK_OOP_REF: The memory access is performed on a weakly reachable reference.
164 // * ON_PHANTOM_OOP_REF: The memory access is performed on a phantomly reachable reference.
165 // This is the same ring of strength as jweak and weak oops in the VM.
166 // * ON_UNKNOWN_OOP_REF: The memory access is performed on a reference of unknown strength.
167 // This could for example come from the unsafe API.
168 // * Default (no explicit reference strength specified): ON_STRONG_OOP_REF
169 const DecoratorSet ON_STRONG_OOP_REF = UCONST64(1) << 15;
170 const DecoratorSet ON_WEAK_OOP_REF = UCONST64(1) << 16;
171 const DecoratorSet ON_PHANTOM_OOP_REF = UCONST64(1) << 17;
172 const DecoratorSet ON_UNKNOWN_OOP_REF = UCONST64(1) << 18;
173 const DecoratorSet ON_DECORATOR_MASK = ON_STRONG_OOP_REF | ON_WEAK_OOP_REF |
174 ON_PHANTOM_OOP_REF | ON_UNKNOWN_OOP_REF;
175
176 // === Access Location ===
177 // Accesses can take place in, e.g. the heap, old or young generation and different native roots.
178 // The location is important to the GC as it may imply different actions. The following decorators are used:
179 // * IN_HEAP: The access is performed in the heap. Many barriers such as card marking will
180 // be omitted if this decorator is not set.
181 // * IN_NATIVE: The access is performed in an off-heap data structure pointing into the Java heap.
182 const DecoratorSet IN_HEAP = UCONST64(1) << 19;
183 const DecoratorSet IN_NATIVE = UCONST64(1) << 20;
184 const DecoratorSet IN_DECORATOR_MASK = IN_HEAP | IN_NATIVE;
185
186 // == Boolean Flag Decorators ==
187 // * IS_ARRAY: The access is performed on a heap allocated array. This is sometimes a special case
188 // for some GCs.
189 // * IS_DEST_UNINITIALIZED: This property can be important to e.g. SATB barriers by
190 // marking that the previous value is uninitialized nonsense rather than a real value.
191 // * IS_NOT_NULL: This property can make certain barriers faster such as compressing oops.
192 const DecoratorSet IS_ARRAY = UCONST64(1) << 21;
193 const DecoratorSet IS_DEST_UNINITIALIZED = UCONST64(1) << 22;
194 const DecoratorSet IS_NOT_NULL = UCONST64(1) << 23;
195
196 // == Arraycopy Decorators ==
197 // * ARRAYCOPY_CHECKCAST: This property means that the class of the objects in source
198 // are not guaranteed to be subclasses of the class of the destination array. This requires
199 // a check-cast barrier during the copying operation. If this is not set, it is assumed
200 // that the array is covariant: (the source array type is-a destination array type)
201 // * ARRAYCOPY_DISJOINT: This property means that it is known that the two array ranges
202 // are disjoint.
203 // * ARRAYCOPY_ARRAYOF: The copy is in the arrayof form.
204 // * ARRAYCOPY_ATOMIC: The accesses have to be atomic over the size of its elements.
205 // * ARRAYCOPY_ALIGNED: The accesses have to be aligned on a HeapWord.
206 const DecoratorSet ARRAYCOPY_CHECKCAST = UCONST64(1) << 24;
207 const DecoratorSet ARRAYCOPY_DISJOINT = UCONST64(1) << 25;
208 const DecoratorSet ARRAYCOPY_ARRAYOF = UCONST64(1) << 26;
209 const DecoratorSet ARRAYCOPY_ATOMIC = UCONST64(1) << 27;
210 const DecoratorSet ARRAYCOPY_ALIGNED = UCONST64(1) << 28;
211 const DecoratorSet ARRAYCOPY_DECORATOR_MASK = ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT |
212 ARRAYCOPY_DISJOINT | ARRAYCOPY_ARRAYOF |
213 ARRAYCOPY_ATOMIC | ARRAYCOPY_ALIGNED;
214
215 // Keep track of the last decorator.
216 const DecoratorSet DECORATOR_LAST = UCONST64(1) << 28;
217
218 namespace AccessInternal {
219 // This class adds implied decorators that follow according to decorator rules.
220 // For example adding default reference strength and default memory ordering
221 // semantics.
222 template <DecoratorSet input_decorators>
223 struct DecoratorFixup: AllStatic {
224 // If no reference strength has been picked, then strong will be picked
225 static const DecoratorSet ref_strength_default = input_decorators |
226 (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
227 ON_STRONG_OOP_REF : INTERNAL_EMPTY);
228 // If no memory ordering has been picked, unordered will be picked
229 static const DecoratorSet memory_ordering_default = ref_strength_default |
230 ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
231 // If no barrier strength has been picked, normal will be used
232 static const DecoratorSet barrier_strength_default = memory_ordering_default |
233 ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
234 static const DecoratorSet value = barrier_strength_default | BT_BUILDTIME_DECORATORS;
235 };
236
237 // This function implements the above DecoratorFixup rules, but without meta
238 // programming for code generation that does not use templates.
239 inline DecoratorSet decorator_fixup(DecoratorSet input_decorators) {
240 // If no reference strength has been picked, then strong will be picked
241 DecoratorSet ref_strength_default = input_decorators |
242 (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
243 ON_STRONG_OOP_REF : INTERNAL_EMPTY);
244 // If no memory ordering has been picked, unordered will be picked
245 DecoratorSet memory_ordering_default = ref_strength_default |
246 ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
247 // If no barrier strength has been picked, normal will be used
248 DecoratorSet barrier_strength_default = memory_ordering_default |
249 ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
250 DecoratorSet value = barrier_strength_default | BT_BUILDTIME_DECORATORS;
251 return value;
252 }
253 }
254
255 #endif // SHARE_OOPS_ACCESSDECORATORS_HPP
|