< prev index next >

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

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_HPP                                                                                   
25 #define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_HPP                                                                                   
26 
27 #include "gc/g1/g1RegionToSpaceMapper.hpp"                                                                                           
28 #include "gc/shared/cardTableModRefBS.hpp"                                                                                           
29 #include "memory/memRegion.hpp"                                                                                                      
30 #include "oops/oop.hpp"                                                                                                              
31 #include "utilities/macros.hpp"                                                                                                      
32 
33 class DirtyCardQueueSet;                                                                                                             
34 class G1SATBCardTableLoggingModRefBS;                                                                                                
35 class CardTable;                                                                                                                     
36 class G1CardTable;                                                                                                                   
37 
38 // This barrier is specialized to use a logging barrier to support                                                                   
39 // snapshot-at-the-beginning marking.                                                                                                
40 
41 class G1SATBCardTableModRefBS: public CardTableModRefBS {                                                                            
42   friend class VMStructs;                                                                                                            
43 protected:                                                                                                                           
44   G1SATBCardTableModRefBS(G1CardTable* table, const BarrierSet::FakeRtti& fake_rtti);                                                
45   ~G1SATBCardTableModRefBS() { }                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
46 
47 public:                                                                                                                              
48   // Add "pre_val" to a set of objects that may have been disconnected from the                                                      
49   // pre-marking object graph.                                                                                                       
50   static void enqueue(oop pre_val);                                                                                                  
51 
52   static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);                                                        
53 
54   template <class T> void write_ref_array_pre_work(T* dst, int count);                                                               
55   virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized);                                                    
56   virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized);                                              
57 
58   template <DecoratorSet decorators, typename T>                                                                                     
59   void write_ref_field_pre(T* field);                                                                                                
60 };                                                                                                                                   
61                                                                                                                                      
62 template<>                                                                                                                           
63 struct BarrierSet::GetName<G1SATBCardTableModRefBS> {                                                                                
64   static const BarrierSet::Name value = BarrierSet::G1SATBCT;                                                                        
65 };                                                                                                                                   
66                                                                                                                                      
67 template<>                                                                                                                           
68 struct BarrierSet::GetType<BarrierSet::G1SATBCT> {                                                                                   
69   typedef G1SATBCardTableModRefBS type;                                                                                              
70 };                                                                                                                                   
71                                                                                                                                      
72 // Adds card-table logging to the post-barrier.                                                                                      
73 // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.                                                             
74 class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {                                                               
75  private:                                                                                                                            
76   DirtyCardQueueSet& _dcqs;                                                                                                          
77                                                                                                                                      
78  public:                                                                                                                             
79   G1SATBCardTableLoggingModRefBS(G1CardTable* card_table);                                                                           
80 
81   // NB: if you do a whole-heap invalidation, the "usual invariant" defined                                                          
82   // above no longer applies.                                                                                                        
83   void invalidate(MemRegion mr);                                                                                                     
84 
85   void write_region(MemRegion mr)         { invalidate(mr); }                                                                        
86   void write_ref_array_work(MemRegion mr) { invalidate(mr); }                                                                        
87 
88   template <DecoratorSet decorators, typename T>                                                                                     
89   void write_ref_field_post(T* field, oop new_val);                                                                                  
90   void write_ref_field_post_slow(volatile jbyte* byte);                                                                              
91 
92   virtual void on_thread_attach(JavaThread* thread);                                                                                 
93   virtual void on_thread_detach(JavaThread* thread);                                                                                 
94 
95   // Callbacks for runtime accesses.                                                                                                 
96   template <DecoratorSet decorators, typename BarrierSetT = G1SATBCardTableLoggingModRefBS>                                          
97   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {                                             
98     typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;                                                         
99     typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;                                                                  
100 
101   public:                                                                                                                            
102     // Needed for loads on non-heap weak references                                                                                  
103     template <typename T>                                                                                                            
104     static oop oop_load_not_in_heap(T* addr);                                                                                        
105 
106     // Needed for non-heap stores                                                                                                    
107     template <typename T>                                                                                                            
108     static void oop_store_not_in_heap(T* addr, oop new_value);                                                                       
109 
110     // Needed for weak references                                                                                                    
111     static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);                                                                      
112 
113     // Defensive: will catch weak oops at addresses in heap                                                                          
114     template <typename T>                                                                                                            
115     static oop oop_load_in_heap(T* addr);                                                                                            
116   };                                                                                                                                 
117 };                                                                                                                                   
118 
119 template<>                                                                                                                           
120 struct BarrierSet::GetName<G1SATBCardTableLoggingModRefBS> {                                                                         
121   static const BarrierSet::Name value = BarrierSet::G1SATBCTLogging;                                                                 
122 };                                                                                                                                   
123 
124 template<>                                                                                                                           
125 struct BarrierSet::GetType<BarrierSet::G1SATBCTLogging> {                                                                            
126   typedef G1SATBCardTableLoggingModRefBS type;                                                                                       
127 };                                                                                                                                   
128 
129 #endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_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_HPP
25 #define SHARE_VM_GC_G1_G1BARRIERSET_HPP
26 

27 #include "gc/shared/cardTableModRefBS.hpp"



28 
29 class DirtyCardQueueSet;

30 class CardTable;
31 class G1CardTable;
32 
33 // This barrier is specialized to use a logging barrier to support
34 // snapshot-at-the-beginning marking.
35 
36 class G1BarrierSet: public CardTableModRefBS {
37   friend class VMStructs;
38  private:
39   DirtyCardQueueSet& _dcqs;
40 
41  public:
42   G1BarrierSet(G1CardTable* table);
43   ~G1BarrierSet() { }
44 

45   // Add "pre_val" to a set of objects that may have been disconnected from the
46   // pre-marking object graph.
47   static void enqueue(oop pre_val);
48 
49   static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
50 
51   template <class T> void write_ref_array_pre_work(T* dst, int count);
52   virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized);
53   virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized);
54 
55   template <DecoratorSet decorators, typename T>
56   void write_ref_field_pre(T* field);




















57 
58   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
59   // above no longer applies.
60   void invalidate(MemRegion mr);
61 
62   void write_region(MemRegion mr)         { invalidate(mr); }
63   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
64 
65   template <DecoratorSet decorators, typename T>
66   void write_ref_field_post(T* field, oop new_val);
67   void write_ref_field_post_slow(volatile jbyte* byte);
68 
69   virtual void on_thread_attach(JavaThread* thread);
70   virtual void on_thread_detach(JavaThread* thread);
71 
72   // Callbacks for runtime accesses.
73   template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
74   class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
75     typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
76     typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
77 
78   public:
79     // Needed for loads on non-heap weak references
80     template <typename T>
81     static oop oop_load_not_in_heap(T* addr);
82 
83     // Needed for non-heap stores
84     template <typename T>
85     static void oop_store_not_in_heap(T* addr, oop new_value);
86 
87     // Needed for weak references
88     static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
89 
90     // Defensive: will catch weak oops at addresses in heap
91     template <typename T>
92     static oop oop_load_in_heap(T* addr);
93   };
94 };
95 
96 template<>
97 struct BarrierSet::GetName<G1BarrierSet> {
98   static const BarrierSet::Name value = BarrierSet::G1BarrierSet;
99 };
100 
101 template<>
102 struct BarrierSet::GetType<BarrierSet::G1BarrierSet> {
103   typedef ::G1BarrierSet type;
104 };
105 
106 #endif // SHARE_VM_GC_G1_G1BARRIERSET_HPP
< prev index next >