< prev index next >

src/hotspot/share/oops/accessDecorators.hpp

BarrierSetC1_v2

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 "metaprogramming/integralConstant.hpp"                                                                                      
28 #include "utilities/globalDefinitions.hpp"                                                                                           
29 
30 // A decorator is an attribute or property that affects the way a memory access is performed in some way.                            
31 // There are different groups of decorators. Some have to do with memory ordering, others to do with,                                
32 // e.g. strength of references, strength of GC barriers, or whether compression should be applied or not.                            
33 // Some decorators are set at buildtime, such as whether primitives require GC barriers or not, others                               
34 // at callsites such as whether an access is in the heap or not, and others are resolved at runtime                                  
35 // such as GC-specific barriers and encoding/decoding compressed oops.                                                               
36 typedef uint64_t DecoratorSet;                                                                                                       
37 
38 // The HasDecorator trait can help at compile-time determining whether a decorator set                                               
39 // has an intersection with a certain other decorator set                                                                            
40 template <DecoratorSet decorators, DecoratorSet decorator>                                                                           
41 struct HasDecorator: public IntegralConstant<bool, (decorators & decorator) != 0> {};                                                
42 
43 // == Internal Decorators - do not use ==                                                                                            
44 // * INTERNAL_EMPTY: This is the name for the empty decorator set (in absence of other decorators).                                  
45 // * INTERNAL_CONVERT_COMPRESSED_OOPS: This is an oop access that will require converting an oop                                     

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

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

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 >