< prev index next >

src/hotspot/share/gc/shared/oopStorageParState.hpp

Print this page

116 //   Wrappers around iterate, providing an adaptation layer allowing
117 //   the use of is-alive closures and OopClosures for iteration.
118 //   Assume p is of type oop*.  Then
119 //
120 //   - cl->do_oop(p) must be a valid expression whose value is ignored.
121 //
122 //   - is_alive->do_object_b(*p) must be a valid expression whose value
123 //   is convertible to bool.
124 //
125 //   If *p == NULL then neither is_alive nor cl will be invoked for p.
126 //   If is_alive->do_object_b(*p) is false, then cl will not be
127 //   invoked on p.
128 
129 class OopStorage::BasicParState {
130   const OopStorage* _storage;
131   ActiveArray* _active_array;
132   size_t _block_count;
133   volatile size_t _next_block;
134   uint _estimated_thread_count;
135   bool _concurrent;

136 
137   NONCOPYABLE(BasicParState);
138 
139   struct IterationData;
140 
141   void update_concurrent_iteration_count(int value);
142   bool claim_next_segment(IterationData* data);
143   bool finish_iteration(const IterationData* data) const;
144 
145   // Wrapper for iteration handler; ignore handler result and return true.
146   template<typename F> class AlwaysTrueFn;
147 
148 public:
149   BasicParState(const OopStorage* storage,
150                 uint estimated_thread_count,
151                 bool concurrent);
152   ~BasicParState();
153 
154   const OopStorage* storage() const { return _storage; }
155 
156   template<bool is_const, typename F> void iterate(F f);
157 
158   static uint default_estimated_thread_count(bool concurrent);



159 };
160 
161 template<bool concurrent, bool is_const>
162 class OopStorage::ParState {
163   BasicParState _basic_state;
164 
165   typedef typename Conditional<is_const,
166                                const OopStorage*,
167                                OopStorage*>::type StoragePtr;
168 
169 public:
170   ParState(StoragePtr storage,
171            uint estimated_thread_count = BasicParState::default_estimated_thread_count(concurrent)) :
172     _basic_state(storage, estimated_thread_count, concurrent)
173   {}
174 
175   const OopStorage* storage() const { return _basic_state.storage(); }
176   template<typename F> void iterate(F f);
177   template<typename Closure> void oops_do(Closure* cl);



178 };
179 
180 template<>
181 class OopStorage::ParState<false, false> {
182   BasicParState _basic_state;
183 
184 public:
185   ParState(OopStorage* storage,
186            uint estimated_thread_count = BasicParState::default_estimated_thread_count(false)) :
187     _basic_state(storage, estimated_thread_count, false)
188   {}
189 
190   const OopStorage* storage() const { return _basic_state.storage(); }
191   template<typename F> void iterate(F f);
192   template<typename Closure> void oops_do(Closure* cl);
193   template<typename Closure> void weak_oops_do(Closure* cl);
194   template<typename IsAliveClosure, typename Closure>
195   void weak_oops_do(IsAliveClosure* is_alive, Closure* cl);



196 };
197 
198 #endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP

116 //   Wrappers around iterate, providing an adaptation layer allowing
117 //   the use of is-alive closures and OopClosures for iteration.
118 //   Assume p is of type oop*.  Then
119 //
120 //   - cl->do_oop(p) must be a valid expression whose value is ignored.
121 //
122 //   - is_alive->do_object_b(*p) must be a valid expression whose value
123 //   is convertible to bool.
124 //
125 //   If *p == NULL then neither is_alive nor cl will be invoked for p.
126 //   If is_alive->do_object_b(*p) is false, then cl will not be
127 //   invoked on p.
128 
129 class OopStorage::BasicParState {
130   const OopStorage* _storage;
131   ActiveArray* _active_array;
132   size_t _block_count;
133   volatile size_t _next_block;
134   uint _estimated_thread_count;
135   bool _concurrent;
136   volatile size_t _num_dead;
137 
138   NONCOPYABLE(BasicParState);
139 
140   struct IterationData;
141 
142   void update_concurrent_iteration_count(int value);
143   bool claim_next_segment(IterationData* data);
144   bool finish_iteration(const IterationData* data) const;
145 
146   // Wrapper for iteration handler; ignore handler result and return true.
147   template<typename F> class AlwaysTrueFn;
148 
149 public:
150   BasicParState(const OopStorage* storage,
151                 uint estimated_thread_count,
152                 bool concurrent);
153   ~BasicParState();
154 
155   const OopStorage* storage() const { return _storage; }
156 
157   template<bool is_const, typename F> void iterate(F f);
158 
159   static uint default_estimated_thread_count(bool concurrent);
160 
161   size_t num_dead() const { return _num_dead; }
162   void increment_dead_counter(size_t num_dead);
163 };
164 
165 template<bool concurrent, bool is_const>
166 class OopStorage::ParState {
167   BasicParState _basic_state;
168 
169   typedef typename Conditional<is_const,
170                                const OopStorage*,
171                                OopStorage*>::type StoragePtr;
172 
173 public:
174   ParState(StoragePtr storage,
175            uint estimated_thread_count = BasicParState::default_estimated_thread_count(concurrent)) :
176     _basic_state(storage, estimated_thread_count, concurrent)
177   {}
178 
179   const OopStorage* storage() const { return _basic_state.storage(); }
180   template<typename F> void iterate(F f);
181   template<typename Closure> void oops_do(Closure* cl);
182 
183   size_t num_dead() const { return _basic_state.num_dead(); }
184   void increment_dead_counter(size_t num_dead) { _basic_state.increment_dead_counter(num_dead); }
185 };
186 
187 template<>
188 class OopStorage::ParState<false, false> {
189   BasicParState _basic_state;
190 
191 public:
192   ParState(OopStorage* storage,
193            uint estimated_thread_count = BasicParState::default_estimated_thread_count(false)) :
194     _basic_state(storage, estimated_thread_count, false)
195   {}
196 
197   const OopStorage* storage() const { return _basic_state.storage(); }
198   template<typename F> void iterate(F f);
199   template<typename Closure> void oops_do(Closure* cl);
200   template<typename Closure> void weak_oops_do(Closure* cl);
201   template<typename IsAliveClosure, typename Closure>
202   void weak_oops_do(IsAliveClosure* is_alive, Closure* cl);
203 
204   size_t num_dead() const { return _basic_state.num_dead(); }
205   void increment_dead_counter(size_t num_dead) { _basic_state.increment_dead_counter(num_dead); }
206 };
207 
208 #endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
< prev index next >