< prev index next >

src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp

include problems

G1BarrierSet_merge

4  * This code is free software; you can redistribute it and/or modify it                                                              
5  * under the terms of the GNU General Public License version 2 only, as                                                              
6  * published by the Free Software Foundation.                                                                                        
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_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP                                                                            
25 #define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP                                                                            
26 
                                                                                                                                     
27 #include "gc/g1/g1CardTable.hpp"                                                                                                     
28 #include "gc/g1/g1SATBCardTableModRefBS.hpp"                                                                                         
29 #include "gc/shared/accessBarrierSupport.inline.hpp"                                                                                 
                                                                                                                                     
30 
31 template <DecoratorSet decorators, typename T>                                                                                       
32 inline void G1SATBCardTableModRefBS::write_ref_field_pre(T* field) {                                                                 
33   if (HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value ||                                                                    
34       HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {                                                                            
35     return;                                                                                                                          
36   }                                                                                                                                  
37 
38   T heap_oop = oopDesc::load_heap_oop(field);                                                                                        
39   if (!oopDesc::is_null(heap_oop)) {                                                                                                 
40     enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));                                                                            
41   }                                                                                                                                  
42 }                                                                                                                                    
43 
44 template <DecoratorSet decorators, typename T>                                                                                       
45 inline void G1SATBCardTableLoggingModRefBS::write_ref_field_post(T* field, oop new_val) {                                            
46   volatile jbyte* byte = _card_table->byte_for(field);                                                                               
47   if (*byte != G1CardTable::g1_young_card_val()) {                                                                                   
48     // Take a slow path for cards in old                                                                                             
49     write_ref_field_post_slow(byte);                                                                                                 
50   }                                                                                                                                  
51 }                                                                                                                                    
52 
53 inline void G1SATBCardTableModRefBS::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {                                
54   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");                                                
55   // Archive roots need to be enqueued since they add subgraphs to the                                                               
56   // Java heap that were not there at the snapshot when marking started.                                                             
57   // Weak and phantom references also need enqueueing for similar reasons.                                                           
58   const bool in_archive_root   = (decorators & IN_ARCHIVE_ROOT) != 0;                                                                
59   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;                                                              
60   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;                                                                
61   const bool needs_enqueue     = in_archive_root || (!peek && !on_strong_oop_ref);                                                   
62 
63   if (needs_enqueue && value != NULL) {                                                                                              
64     enqueue(value);                                                                                                                  
65   }                                                                                                                                  
66 }                                                                                                                                    
67 
68 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
69 template <typename T>                                                                                                                
70 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::                                                  
71 oop_load_not_in_heap(T* addr) {                                                                                                      
72   oop value = ModRef::oop_load_not_in_heap(addr);                                                                                    
73   enqueue_if_weak_or_archive(decorators, value);                                                                                     
74   return value;                                                                                                                      
75 }                                                                                                                                    
76 
77 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
78 template <typename T>                                                                                                                
79 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::                                                  
80 oop_load_in_heap(T* addr) {                                                                                                          
81   oop value = ModRef::oop_load_in_heap(addr);                                                                                        
82   enqueue_if_weak_or_archive(decorators, value);                                                                                     
83   return value;                                                                                                                      
84 }                                                                                                                                    
85 
86 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
87 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::                                                  
88 oop_load_in_heap_at(oop base, ptrdiff_t offset) {                                                                                    
89   oop value = ModRef::oop_load_in_heap_at(base, offset);                                                                             
90   enqueue_if_weak_or_archive(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);      
91   return value;                                                                                                                      
92 }                                                                                                                                    
93 
94 template <DecoratorSet decorators, typename BarrierSetT>                                                                             
95 template <typename T>                                                                                                                
96 inline void G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::                                                 
97 oop_store_not_in_heap(T* addr, oop new_value) {                                                                                      
98   if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {                                                                         
99     // For roots not scanned in a safepoint, we have to apply SATB barriers                                                          
100     // even for roots.                                                                                                               
101     G1SATBCardTableLoggingModRefBS *bs = barrier_set_cast<G1SATBCardTableLoggingModRefBS>(BarrierSet::barrier_set());                
102     bs->write_ref_field_pre<decorators>(addr);                                                                                       
103   }                                                                                                                                  
104   Raw::oop_store(addr, new_value);                                                                                                   
105 }                                                                                                                                    
106 
107 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_INLINE_HPP                                                                          

4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 only, as
6  * published by the Free Software Foundation.
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_VM_GC_G1_G1BARRIERSET_INLINE_HPP
25 #define SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP
26 
27 #include "gc/g1/g1BarrierSet.hpp"
28 #include "gc/g1/g1CardTable.hpp"

29 #include "gc/shared/accessBarrierSupport.inline.hpp"
30 #include "oops/oop.inline.hpp"
31 
32 template <DecoratorSet decorators, typename T>
33 inline void G1BarrierSet::write_ref_field_pre(T* field) {
34   if (HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value ||
35       HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
36     return;
37   }
38 
39   T heap_oop = RawAccess<MO_VOLATILE>::oop_load(field);
40   if (oopDesc::is_null(heap_oop)) {
41     enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
42   }
43 }
44 
45 template <DecoratorSet decorators, typename T>
46 inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {
47   volatile jbyte* byte = _card_table->byte_for(field);
48   if (*byte != G1CardTable::g1_young_card_val()) {
49     // Take a slow path for cards in old
50     write_ref_field_post_slow(byte);
51   }
52 }
53 
54 inline void G1BarrierSet::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {
55   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
56   // Archive roots need to be enqueued since they add subgraphs to the
57   // Java heap that were not there at the snapshot when marking started.
58   // Weak and phantom references also need enqueueing for similar reasons.
59   const bool in_archive_root   = (decorators & IN_ARCHIVE_ROOT) != 0;
60   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
61   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
62   const bool needs_enqueue     = in_archive_root || (!peek && !on_strong_oop_ref);
63 
64   if (needs_enqueue && value != NULL) {
65     enqueue(value);
66   }
67 }
68 
69 template <DecoratorSet decorators, typename BarrierSetT>
70 template <typename T>
71 inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
72 oop_load_not_in_heap(T* addr) {
73   oop value = ModRef::oop_load_not_in_heap(addr);
74   enqueue_if_weak_or_archive(decorators, value);
75   return value;
76 }
77 
78 template <DecoratorSet decorators, typename BarrierSetT>
79 template <typename T>
80 inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
81 oop_load_in_heap(T* addr) {
82   oop value = ModRef::oop_load_in_heap(addr);
83   enqueue_if_weak_or_archive(decorators, value);
84   return value;
85 }
86 
87 template <DecoratorSet decorators, typename BarrierSetT>
88 inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
89 oop_load_in_heap_at(oop base, ptrdiff_t offset) {
90   oop value = ModRef::oop_load_in_heap_at(base, offset);
91   enqueue_if_weak_or_archive(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
92   return value;
93 }
94 
95 template <DecoratorSet decorators, typename BarrierSetT>
96 template <typename T>
97 inline void G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
98 oop_store_not_in_heap(T* addr, oop new_value) {
99   if (HasDecorator<decorators, IN_CONCURRENT_ROOT>::value) {
100     // For roots not scanned in a safepoint, we have to apply SATB barriers
101     // even for roots.
102     G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
103     bs->write_ref_field_pre<decorators>(addr);
104   }
105   Raw::oop_store(addr, new_value);
106 }
107 
108 #endif // SHARE_VM_GC_G1_G1BARRIERSET_INLINE_HPP
< prev index next >