< prev index next >

src/hotspot/share/oops/accessDecorators.hpp

BarrierSetC1_v2

BarrierSetC1

7  *                                                                                                                                   
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 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 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #ifndef SHARE_OOPS_ACCESSDECORATORS_HPP                                                                                              
25 #define SHARE_OOPS_ACCESSDECORATORS_HPP                                                                                              
26 
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
27 // A decorator is an attribute or property that affects the way a memory access is performed in some way.                            
28 // There are different groups of decorators. Some have to do with memory ordering, others to do with,                                
29 // e.g. strength of references, strength of GC barriers, or whether compression should be applied or not.                            
30 // Some decorators are set at buildtime, such as whether primitives require GC barriers or not, others                               
31 // at callsites such as whether an access is in the heap or not, and others are resolved at runtime                                  
32 // such as GC-specific barriers and encoding/decoding compressed oops.                                                               
33 typedef uint64_t DecoratorSet;                                                                                                       
34 
35 // The HasDecorator trait can help at compile-time determining whether a decorator set                                               
36 // has an intersection with a certain other decorator set                                                                            
37 template <DecoratorSet decorators, DecoratorSet decorator>                                                                           
38 struct HasDecorator: public IntegralConstant<bool, (decorators & decorator) != 0> {};                                                
39 
40 // == Internal Decorators - do not use ==                                                                                            
41 // * INTERNAL_EMPTY: This is the name for the empty decorator set (in absence of other decorators).                                  
42 // * INTERNAL_CONVERT_COMPRESSED_OOPS: This is an oop access that will require converting an oop                                     
43 //   to a narrowOop or vice versa, if UseCompressedOops is known to be set.                                                          
44 // * INTERNAL_VALUE_IS_OOP: Remember that the involved access is on oop rather than primitive.                                       
45 const DecoratorSet INTERNAL_EMPTY                    = UCONST64(0);                                                                  

7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 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 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_OOPS_ACCESSDECORATORS_HPP
25 #define SHARE_OOPS_ACCESSDECORATORS_HPP
26 
27 #include "gc/shared/barrierSetConfig.hpp"
28 #include "memory/allocation.hpp"
29 #include "metaprogramming/integralConstant.hpp"
30 #include "utilities/globalDefinitions.hpp"
31 
32 // A decorator is an attribute or property that affects the way a memory access is performed in some way.
33 // There are different groups of decorators. Some have to do with memory ordering, others to do with,
34 // e.g. strength of references, strength of GC barriers, or whether compression should be applied or not.
35 // Some decorators are set at buildtime, such as whether primitives require GC barriers or not, others
36 // at callsites such as whether an access is in the heap or not, and others are resolved at runtime
37 // such as GC-specific barriers and encoding/decoding compressed oops.
38 typedef uint64_t DecoratorSet;
39 
40 // The HasDecorator trait can help at compile-time determining whether a decorator set
41 // has an intersection with a certain other decorator set
42 template <DecoratorSet decorators, DecoratorSet decorator>
43 struct HasDecorator: public IntegralConstant<bool, (decorators & decorator) != 0> {};
44 
45 // == Internal Decorators - do not use ==
46 // * INTERNAL_EMPTY: This is the name for the empty decorator set (in absence of other decorators).
47 // * INTERNAL_CONVERT_COMPRESSED_OOPS: This is an oop access that will require converting an oop
48 //   to a narrowOop or vice versa, if UseCompressedOops is known to be set.
49 // * INTERNAL_VALUE_IS_OOP: Remember that the involved access is on oop rather than primitive.
50 const DecoratorSet INTERNAL_EMPTY                    = UCONST64(0);

197 const DecoratorSet OOP_DECORATOR_MASK = OOP_NOT_NULL;                                                                                
198 
199 // == Arraycopy Decorators ==                                                                                                        
200 // * ARRAYCOPY_CHECKCAST: This property means that the class of the objects in source                                                
201 //   are not guaranteed to be subclasses of the class of the destination array. This requires                                        
202 //   a check-cast barrier during the copying operation. If this is not set, it is assumed                                            
203 //   that the array is covariant: (the source array type is-a destination array type)                                                
204 // * ARRAYCOPY_DISJOINT: This property means that it is known that the two array ranges                                              
205 //   are disjoint.                                                                                                                   
206 // * ARRAYCOPY_ARRAYOF: The copy is in the arrayof form.                                                                             
207 // * ARRAYCOPY_ATOMIC: The accesses have to be atomic over the size of its elements.                                                 
208 // * ARRAYCOPY_ALIGNED: The accesses have to be aligned on a HeapWord.                                                               
209 const DecoratorSet ARRAYCOPY_CHECKCAST            = UCONST64(1) << 26;                                                               
210 const DecoratorSet ARRAYCOPY_DISJOINT             = UCONST64(1) << 27;                                                               
211 const DecoratorSet ARRAYCOPY_ARRAYOF              = UCONST64(1) << 28;                                                               
212 const DecoratorSet ARRAYCOPY_ATOMIC               = UCONST64(1) << 29;                                                               
213 const DecoratorSet ARRAYCOPY_ALIGNED              = UCONST64(1) << 30;                                                               
214 const DecoratorSet ARRAYCOPY_DECORATOR_MASK       = ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT |                                       
215                                                     ARRAYCOPY_DISJOINT | ARRAYCOPY_ARRAYOF |                                         
216                                                     ARRAYCOPY_ATOMIC | ARRAYCOPY_ALIGNED;                                            
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
217 
218 #endif // SHARE_OOPS_ACCESSDECORATORS_HPP                                                                                            

202 const DecoratorSet OOP_DECORATOR_MASK = OOP_NOT_NULL;
203 
204 // == Arraycopy Decorators ==
205 // * ARRAYCOPY_CHECKCAST: This property means that the class of the objects in source
206 //   are not guaranteed to be subclasses of the class of the destination array. This requires
207 //   a check-cast barrier during the copying operation. If this is not set, it is assumed
208 //   that the array is covariant: (the source array type is-a destination array type)
209 // * ARRAYCOPY_DISJOINT: This property means that it is known that the two array ranges
210 //   are disjoint.
211 // * ARRAYCOPY_ARRAYOF: The copy is in the arrayof form.
212 // * ARRAYCOPY_ATOMIC: The accesses have to be atomic over the size of its elements.
213 // * ARRAYCOPY_ALIGNED: The accesses have to be aligned on a HeapWord.
214 const DecoratorSet ARRAYCOPY_CHECKCAST            = UCONST64(1) << 26;
215 const DecoratorSet ARRAYCOPY_DISJOINT             = UCONST64(1) << 27;
216 const DecoratorSet ARRAYCOPY_ARRAYOF              = UCONST64(1) << 28;
217 const DecoratorSet ARRAYCOPY_ATOMIC               = UCONST64(1) << 29;
218 const DecoratorSet ARRAYCOPY_ALIGNED              = UCONST64(1) << 30;
219 const DecoratorSet ARRAYCOPY_DECORATOR_MASK       = ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT |
220                                                     ARRAYCOPY_DISJOINT | ARRAYCOPY_ARRAYOF |
221                                                     ARRAYCOPY_ATOMIC | ARRAYCOPY_ALIGNED;
222 
223 // Keep track of the last decorator.
224 const DecoratorSet DECORATOR_LAST = UCONST64(1) << 30;
225 
226 namespace AccessInternal {
227   // This class adds implied decorators that follow according to decorator rules.
228   // For example adding default reference strength and default memory ordering
229   // semantics.
230   template <DecoratorSet input_decorators>
231   struct DecoratorFixup: AllStatic {
232     // If no reference strength has been picked, then strong will be picked
233     static const DecoratorSet ref_strength_default = input_decorators |
234       (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
235        ON_STRONG_OOP_REF : INTERNAL_EMPTY);
236     // If no memory ordering has been picked, unordered will be picked
237     static const DecoratorSet memory_ordering_default = ref_strength_default |
238       ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
239     // If no barrier strength has been picked, normal will be used
240     static const DecoratorSet barrier_strength_default = memory_ordering_default |
241       ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
242     // Heap array accesses imply it is a heap access
243     static const DecoratorSet heap_array_is_in_heap = barrier_strength_default |
244       ((IN_HEAP_ARRAY & barrier_strength_default) != 0 ? IN_HEAP : INTERNAL_EMPTY);
245     static const DecoratorSet conc_root_is_root = heap_array_is_in_heap |
246       ((IN_CONCURRENT_ROOT & heap_array_is_in_heap) != 0 ? IN_ROOT : INTERNAL_EMPTY);
247     static const DecoratorSet archive_root_is_root = conc_root_is_root |
248       ((IN_ARCHIVE_ROOT & conc_root_is_root) != 0 ? IN_ROOT : INTERNAL_EMPTY);
249     static const DecoratorSet value = archive_root_is_root | BT_BUILDTIME_DECORATORS;
250   };
251 
252   // This function implements the above DecoratorFixup rules, but without meta
253   // programming for code generation that does not use templates.
254   inline DecoratorSet decorator_fixup(DecoratorSet input_decorators) {
255     // If no reference strength has been picked, then strong will be picked
256     DecoratorSet ref_strength_default = input_decorators |
257       (((ON_DECORATOR_MASK & input_decorators) == 0 && (INTERNAL_VALUE_IS_OOP & input_decorators) != 0) ?
258        ON_STRONG_OOP_REF : INTERNAL_EMPTY);
259     // If no memory ordering has been picked, unordered will be picked
260     DecoratorSet memory_ordering_default = ref_strength_default |
261       ((MO_DECORATOR_MASK & ref_strength_default) == 0 ? MO_UNORDERED : INTERNAL_EMPTY);
262     // If no barrier strength has been picked, normal will be used
263     DecoratorSet barrier_strength_default = memory_ordering_default |
264       ((AS_DECORATOR_MASK & memory_ordering_default) == 0 ? AS_NORMAL : INTERNAL_EMPTY);
265     // Heap array accesses imply it is a heap access
266     DecoratorSet heap_array_is_in_heap = barrier_strength_default |
267       ((IN_HEAP_ARRAY & barrier_strength_default) != 0 ? IN_HEAP : INTERNAL_EMPTY);
268     DecoratorSet conc_root_is_root = heap_array_is_in_heap |
269       ((IN_CONCURRENT_ROOT & heap_array_is_in_heap) != 0 ? IN_ROOT : INTERNAL_EMPTY);
270     DecoratorSet archive_root_is_root = conc_root_is_root |
271       ((IN_ARCHIVE_ROOT & conc_root_is_root) != 0 ? IN_ROOT : INTERNAL_EMPTY);
272     DecoratorSet value = archive_root_is_root | BT_BUILDTIME_DECORATORS;
273     return value;
274   }
275 }
276 
277 #endif // SHARE_OOPS_ACCESSDECORATORS_HPP
< prev index next >