9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
26 #define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
27
28 #include "gc/shared/oopStorage.hpp"
29 #include "memory/allocation.hpp"
30 #include "utilities/macros.hpp"
31
32 #if INCLUDE_ALL_GCS
33
34 //////////////////////////////////////////////////////////////////////////////
35 // Support for parallel and optionally concurrent state iteration.
36 //
37 // Parallel iteration is for the exclusive use of the GC. Other iteration
38 // clients must use serial iteration.
39 //
40 // Concurrent Iteration
41 //
42 // Iteration involves the _active_list, which contains all of the blocks owned
43 // by a storage object. This is a doubly-linked list, linked through
44 // dedicated fields in the blocks.
45 //
46 // At most one concurrent ParState can exist at a time for a given storage
47 // object.
48 //
49 // A concurrent ParState sets the associated storage's
123 // modifications of the storage by the mutator could result in the
124 // pre-filtering being applied (successfully or not) to objects that
125 // are unrelated to what the closure finds in the entry.
126 //
127 // template<typename Closure> void weak_oops_do(Closure* cl)
128 // template<typename IsAliveClosure, typename Closure>
129 // void weak_oops_do(IsAliveClosure* is_alive, Closure* cl)
130 // Wrappers around iterate, providing an adaptation layer allowing
131 // the use of is-alive closures and OopClosures for iteration.
132 // Assume p is of type oop*. Then
133 //
134 // - cl->do_oop(p) must be a valid expression whose value is ignored.
135 //
136 // - is_alive->do_object_b(*p) must be a valid expression whose value
137 // is convertible to bool.
138 //
139 // If *p == NULL then neither is_alive nor cl will be invoked for p.
140 // If is_alive->do_object_b(*p) is false, then cl will not be
141 // invoked on p.
142
143 class OopStorage::BasicParState VALUE_OBJ_CLASS_SPEC {
144 OopStorage* _storage;
145 void* volatile _next_block;
146 bool _concurrent;
147
148 // Noncopyable.
149 BasicParState(const BasicParState&);
150 BasicParState& operator=(const BasicParState&);
151
152 void update_iteration_state(bool value);
153 void ensure_iteration_started();
154 Block* claim_next_block();
155
156 // Wrapper for iteration handler; ignore handler result and return true.
157 template<typename F> class AlwaysTrueFn;
158
159 public:
160 BasicParState(OopStorage* storage, bool concurrent);
161 ~BasicParState();
162
163 template<bool is_const, typename F> void iterate(F f);
164 };
165
166 template<bool concurrent, bool is_const>
167 class OopStorage::ParState VALUE_OBJ_CLASS_SPEC {
168 BasicParState _basic_state;
169
170 public:
171 ParState(const OopStorage* storage) :
172 // For simplicity, always recorded as non-const.
173 _basic_state(const_cast<OopStorage*>(storage), concurrent)
174 {}
175
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> VALUE_OBJ_CLASS_SPEC {
182 BasicParState _basic_state;
183
184 public:
185 ParState(OopStorage* storage) :
186 _basic_state(storage, false)
187 {}
188
189 template<typename F> void iterate(F f);
190 template<typename Closure> void oops_do(Closure* cl);
191 template<typename Closure> void weak_oops_do(Closure* cl);
192 template<typename IsAliveClosure, typename Closure>
193 void weak_oops_do(IsAliveClosure* is_alive, Closure* cl);
194 };
195
196 #endif // INCLUDE_ALL_GCS
197
198 #endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
26 #define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
27
28 #include "gc/shared/oopStorage.hpp"
29 #include "utilities/macros.hpp"
30
31 #if INCLUDE_ALL_GCS
32
33 //////////////////////////////////////////////////////////////////////////////
34 // Support for parallel and optionally concurrent state iteration.
35 //
36 // Parallel iteration is for the exclusive use of the GC. Other iteration
37 // clients must use serial iteration.
38 //
39 // Concurrent Iteration
40 //
41 // Iteration involves the _active_list, which contains all of the blocks owned
42 // by a storage object. This is a doubly-linked list, linked through
43 // dedicated fields in the blocks.
44 //
45 // At most one concurrent ParState can exist at a time for a given storage
46 // object.
47 //
48 // A concurrent ParState sets the associated storage's
122 // modifications of the storage by the mutator could result in the
123 // pre-filtering being applied (successfully or not) to objects that
124 // are unrelated to what the closure finds in the entry.
125 //
126 // template<typename Closure> void weak_oops_do(Closure* cl)
127 // template<typename IsAliveClosure, typename Closure>
128 // void weak_oops_do(IsAliveClosure* is_alive, Closure* cl)
129 // Wrappers around iterate, providing an adaptation layer allowing
130 // the use of is-alive closures and OopClosures for iteration.
131 // Assume p is of type oop*. Then
132 //
133 // - cl->do_oop(p) must be a valid expression whose value is ignored.
134 //
135 // - is_alive->do_object_b(*p) must be a valid expression whose value
136 // is convertible to bool.
137 //
138 // If *p == NULL then neither is_alive nor cl will be invoked for p.
139 // If is_alive->do_object_b(*p) is false, then cl will not be
140 // invoked on p.
141
142 class OopStorage::BasicParState {
143 OopStorage* _storage;
144 void* volatile _next_block;
145 bool _concurrent;
146
147 // Noncopyable.
148 BasicParState(const BasicParState&);
149 BasicParState& operator=(const BasicParState&);
150
151 void update_iteration_state(bool value);
152 void ensure_iteration_started();
153 Block* claim_next_block();
154
155 // Wrapper for iteration handler; ignore handler result and return true.
156 template<typename F> class AlwaysTrueFn;
157
158 public:
159 BasicParState(OopStorage* storage, bool concurrent);
160 ~BasicParState();
161
162 template<bool is_const, typename F> void iterate(F f);
163 };
164
165 template<bool concurrent, bool is_const>
166 class OopStorage::ParState {
167 BasicParState _basic_state;
168
169 public:
170 ParState(const OopStorage* storage) :
171 // For simplicity, always recorded as non-const.
172 _basic_state(const_cast<OopStorage*>(storage), concurrent)
173 {}
174
175 template<typename F> void iterate(F f);
176 template<typename Closure> void oops_do(Closure* cl);
177 };
178
179 template<>
180 class OopStorage::ParState<false, false> {
181 BasicParState _basic_state;
182
183 public:
184 ParState(OopStorage* storage) :
185 _basic_state(storage, false)
186 {}
187
188 template<typename F> void iterate(F f);
189 template<typename Closure> void oops_do(Closure* cl);
190 template<typename Closure> void weak_oops_do(Closure* cl);
191 template<typename IsAliveClosure, typename Closure>
192 void weak_oops_do(IsAliveClosure* is_alive, Closure* cl);
193 };
194
195 #endif // INCLUDE_ALL_GCS
196
197 #endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
|