< prev index next >

src/hotspot/share/gc/z/zRootsIterator.hpp


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 #ifndef SHARE_GC_Z_ZROOTSITERATOR_HPP                                                                                                
24 #define SHARE_GC_Z_ZROOTSITERATOR_HPP                                                                                                
25 
26 #include "gc/shared/oopStorageParState.hpp"                                                                                          
                                                                                                                                     
27 #include "memory/allocation.hpp"                                                                                                     
28 #include "memory/iterator.hpp"                                                                                                       
29 #include "runtime/thread.hpp"                                                                                                        
30 #include "utilities/globalDefinitions.hpp"                                                                                           
31 
32 class ZRootsIteratorClosure : public OopClosure, public ThreadClosure {                                                              
33 public:                                                                                                                              
34   virtual void do_thread(Thread* thread) {                                                                                           
35     thread->oops_do(this, NULL);                                                                                                     
36   }                                                                                                                                  
37 };                                                                                                                                   
38 
39 typedef OopStorage::ParState<false /* concurrent */, false /* is_const */> ZOopStorageIterator;                                      
40 typedef OopStorage::ParState<true /* concurrent */, false /* is_const */>  ZConcurrentOopStorageIterator;                            
41 
42 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>                                                                          
43 class ZSerialOopsDo {                                                                                                                
44 private:                                                                                                                             
45   T* const      _iter;                                                                                                               
46   volatile bool _claimed;                                                                                                            
47 
48 public:                                                                                                                              
49   ZSerialOopsDo(T* iter);                                                                                                            
50   void oops_do(ZRootsIteratorClosure* cl);                                                                                           
51 };                                                                                                                                   
52 
53 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>                                                                          
54 class ZParallelOopsDo {                                                                                                              
55 private:                                                                                                                             
56   T* const      _iter;                                                                                                               
57   volatile bool _completed;                                                                                                          
58 
59 public:                                                                                                                              

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 #ifndef SHARE_GC_Z_ZROOTSITERATOR_HPP
24 #define SHARE_GC_Z_ZROOTSITERATOR_HPP
25 
26 #include "gc/shared/oopStorageParState.hpp"
27 #include "gc/shared/suspendibleThreadSet.hpp"
28 #include "memory/allocation.hpp"
29 #include "memory/iterator.hpp"
30 #include "runtime/thread.hpp"
31 #include "utilities/globalDefinitions.hpp"
32 
33 class ZRootsIteratorClosure : public OopClosure, public ThreadClosure {
34 public:
35   virtual void do_thread(Thread* thread) {
36     thread->oops_do(this, NULL);
37   }
38 };
39 
40 typedef OopStorage::ParState<true /* concurrent */, false /* is_const */> ZOopStorageIterator;

41 
42 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
43 class ZSerialOopsDo {
44 private:
45   T* const      _iter;
46   volatile bool _claimed;
47 
48 public:
49   ZSerialOopsDo(T* iter);
50   void oops_do(ZRootsIteratorClosure* cl);
51 };
52 
53 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
54 class ZParallelOopsDo {
55 private:
56   T* const      _iter;
57   volatile bool _completed;
58 
59 public:

68   volatile bool _claimed;                                                                                                            
69 
70 public:                                                                                                                              
71   ZSerialWeakOopsDo(T* iter);                                                                                                        
72   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);                                                         
73 };                                                                                                                                   
74 
75 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>                                                      
76 class ZParallelWeakOopsDo {                                                                                                          
77 private:                                                                                                                             
78   T* const      _iter;                                                                                                               
79   volatile bool _completed;                                                                                                          
80 
81 public:                                                                                                                              
82   ZParallelWeakOopsDo(T* iter);                                                                                                      
83   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);                                                         
84 };                                                                                                                                   
85 
86 class ZRootsIterator {                                                                                                               
87 private:                                                                                                                             
88   ZOopStorageIterator _jni_handles_iter;                                                                                             
89                                                                                                                                      
90   void do_universe(ZRootsIteratorClosure* cl);                                                                                       
91   void do_jni_handles(ZRootsIteratorClosure* cl);                                                                                    
92   void do_object_synchronizer(ZRootsIteratorClosure* cl);                                                                            
93   void do_management(ZRootsIteratorClosure* cl);                                                                                     
94   void do_jvmti_export(ZRootsIteratorClosure* cl);                                                                                   
95   void do_jvmti_weak_export(ZRootsIteratorClosure* cl);                                                                              
96   void do_system_dictionary(ZRootsIteratorClosure* cl);                                                                              
97   void do_class_loader_data_graph(ZRootsIteratorClosure* cl);                                                                        
98   void do_threads(ZRootsIteratorClosure* cl);                                                                                        
99   void do_code_cache(ZRootsIteratorClosure* cl);                                                                                     
100 
101   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe>                  _universe;                                            
102   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer>       _object_synchronizer;                                 
103   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_management>                _management;                                          
104   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_export>              _jvmti_export;                                        
105   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_weak_export>         _jvmti_weak_export;                                   
106   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_system_dictionary>         _system_dictionary;                                   
107   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_jni_handles>             _jni_handles;                                         
108   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_class_loader_data_graph> _class_loader_data_graph;                             
109   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_threads>                 _threads;                                             
110   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_code_cache>              _code_cache;                                          
111 
112 public:                                                                                                                              
113   ZRootsIterator();                                                                                                                  
114   ~ZRootsIterator();                                                                                                                 
115 
116   void oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export = false);                                                     
117 };                                                                                                                                   
118 
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
119 class ZWeakRootsIterator {                                                                                                           
120 private:                                                                                                                             
121   void do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);                                                 
122   void do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);                                                          
123 
124   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export>  _jvmti_weak_export;                              
125   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak>           _jfr_weak;                                       
126 
127 public:                                                                                                                              
128   ZWeakRootsIterator();                                                                                                              
129   ~ZWeakRootsIterator();                                                                                                             
130 
131   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);                                                         
132   void oops_do(ZRootsIteratorClosure* cl);                                                                                           
133 };                                                                                                                                   
134 
135 class ZConcurrentWeakRootsIterator {                                                                                                 
136 private:                                                                                                                             
137   ZConcurrentOopStorageIterator _vm_weak_handles_iter;                                                                               
138   ZConcurrentOopStorageIterator _jni_weak_handles_iter;                                                                              
139   ZConcurrentOopStorageIterator _string_table_iter;                                                                                  
140 
141   void do_vm_weak_handles(ZRootsIteratorClosure* cl);                                                                                
142   void do_jni_weak_handles(ZRootsIteratorClosure* cl);                                                                               
143   void do_string_table(ZRootsIteratorClosure* cl);                                                                                   
144 
145   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_vm_weak_handles>  _vm_weak_handles;                
146   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_jni_weak_handles> _jni_weak_handles;               
147   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_string_table>     _string_table;                   
148 
149 public:                                                                                                                              
150   ZConcurrentWeakRootsIterator();                                                                                                    
151   ~ZConcurrentWeakRootsIterator();                                                                                                   
152 
153   void oops_do(ZRootsIteratorClosure* cl);                                                                                           
154 };                                                                                                                                   
155 
156 class ZThreadRootsIterator {                                                                                                         
157 private:                                                                                                                             
158   void do_threads(ZRootsIteratorClosure* cl);                                                                                        

68   volatile bool _claimed;
69 
70 public:
71   ZSerialWeakOopsDo(T* iter);
72   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
73 };
74 
75 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
76 class ZParallelWeakOopsDo {
77 private:
78   T* const      _iter;
79   volatile bool _completed;
80 
81 public:
82   ZParallelWeakOopsDo(T* iter);
83   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
84 };
85 
86 class ZRootsIterator {
87 private:


88   void do_universe(ZRootsIteratorClosure* cl);

89   void do_object_synchronizer(ZRootsIteratorClosure* cl);
90   void do_management(ZRootsIteratorClosure* cl);
91   void do_jvmti_export(ZRootsIteratorClosure* cl);
92   void do_jvmti_weak_export(ZRootsIteratorClosure* cl);
93   void do_system_dictionary(ZRootsIteratorClosure* cl);

94   void do_threads(ZRootsIteratorClosure* cl);
95   void do_code_cache(ZRootsIteratorClosure* cl);
96 
97   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe>            _universe;
98   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer> _object_synchronizer;
99   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_management>          _management;
100   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_export>        _jvmti_export;
101   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_weak_export>   _jvmti_weak_export;
102   ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_system_dictionary>   _system_dictionary;
103   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_threads>           _threads;
104   ZParallelOopsDo<ZRootsIterator, &ZRootsIterator::do_code_cache>        _code_cache;


105 
106 public:
107   ZRootsIterator();
108   ~ZRootsIterator();
109 
110   void oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export = false);
111 };
112 
113 class ZConcurrentRootsIterator {
114 private:
115   bool                       _marking;
116   SuspendibleThreadSetJoiner _sts_joiner;
117   ZOopStorageIterator        _jni_handles_iter;
118 
119   void do_jni_handles(ZRootsIteratorClosure* cl);
120   void do_class_loader_data_graph(ZRootsIteratorClosure* cl);
121 
122   ZParallelOopsDo<ZConcurrentRootsIterator, &ZConcurrentRootsIterator::do_jni_handles>             _jni_handles;
123   ZParallelOopsDo<ZConcurrentRootsIterator, &ZConcurrentRootsIterator::do_class_loader_data_graph> _class_loader_data_graph;
124 
125 public:
126   ZConcurrentRootsIterator(bool claim_clds);
127   ~ZConcurrentRootsIterator();
128 
129   void oops_do(ZRootsIteratorClosure* cl);
130 };
131 
132 class ZWeakRootsIterator {
133 private:
134   void do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
135   void do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
136 
137   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export>  _jvmti_weak_export;
138   ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak>           _jfr_weak;
139 
140 public:
141   ZWeakRootsIterator();
142   ~ZWeakRootsIterator();
143 
144   void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
145   void oops_do(ZRootsIteratorClosure* cl);
146 };
147 
148 class ZConcurrentWeakRootsIterator {
149 private:
150   ZOopStorageIterator _vm_weak_handles_iter;
151   ZOopStorageIterator _jni_weak_handles_iter;
152   ZOopStorageIterator _string_table_iter;
153 
154   void do_vm_weak_handles(ZRootsIteratorClosure* cl);
155   void do_jni_weak_handles(ZRootsIteratorClosure* cl);
156   void do_string_table(ZRootsIteratorClosure* cl);
157 
158   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_vm_weak_handles>  _vm_weak_handles;
159   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_jni_weak_handles> _jni_weak_handles;
160   ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_string_table>     _string_table;
161 
162 public:
163   ZConcurrentWeakRootsIterator();
164   ~ZConcurrentWeakRootsIterator();
165 
166   void oops_do(ZRootsIteratorClosure* cl);
167 };
168 
169 class ZThreadRootsIterator {
170 private:
171   void do_threads(ZRootsIteratorClosure* cl);
< prev index next >