< prev index next >

src/hotspot/share/gc/shared/oopStorage.inline.hpp

Print this page

 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_OOPSTORAGE_INLINE_HPP
 26 #define SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP
 27 
 28 #include "gc/shared/oopStorage.hpp"
 29 
 30 #include "memory/allocation.hpp"
 31 #include "metaprogramming/conditional.hpp"
 32 #include "metaprogramming/isConst.hpp"
 33 #include "oops/oop.hpp"

 34 #include "runtime/safepoint.hpp"
 35 #include "utilities/align.hpp"
 36 #include "utilities/count_trailing_zeros.hpp"
 37 #include "utilities/debug.hpp"
 38 #include "utilities/globalDefinitions.hpp"
 39 
 40 // Array of all active blocks.  Refcounted for lock-free reclaim of
 41 // old array when a new array is allocated for expansion.
 42 class OopStorage::ActiveArray {
 43   friend class OopStorage::TestAccess;
 44 
 45   size_t _size;
 46   volatile size_t _block_count;
 47   mutable volatile int _refcount;
 48   // Block* _blocks[1];            // Pseudo flexible array member.
 49 
 50   ActiveArray(size_t size);
 51   ~ActiveArray();
 52 
 53   NONCOPYABLE(ActiveArray);

245   Closure* _cl;
246 };
247 
248 template<typename Closure>
249 inline OopStorage::OopFn<Closure> OopStorage::oop_fn(Closure* cl) {
250   return OopFn<Closure>(cl);
251 }
252 
253 template<typename IsAlive, typename F>
254 class OopStorage::IfAliveFn {
255 public:
256   IfAliveFn(IsAlive* is_alive, F f) : _is_alive(is_alive), _f(f) {}
257 
258   bool operator()(oop* ptr) const {
259     bool result = true;
260     oop v = *ptr;
261     if (v != NULL) {
262       if (_is_alive->do_object_b(v)) {
263         result = _f(ptr);
264       } else {

265         *ptr = NULL;            // Clear dead value.
266       }
267     }
268     return result;
269   }
270 
271 private:
272   IsAlive* _is_alive;
273   F _f;
274 };
275 
276 template<typename IsAlive, typename F>
277 inline OopStorage::IfAliveFn<IsAlive, F> OopStorage::if_alive_fn(IsAlive* is_alive, F f) {
278   return IfAliveFn<IsAlive, F>(is_alive, f);
279 }
280 
281 template<typename F>
282 class OopStorage::SkipNullFn {
283 public:
284   SkipNullFn(F f) : _f(f) {}

 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_OOPSTORAGE_INLINE_HPP
 26 #define SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP
 27 
 28 #include "gc/shared/oopStorage.hpp"
 29 
 30 #include "memory/allocation.hpp"
 31 #include "metaprogramming/conditional.hpp"
 32 #include "metaprogramming/isConst.hpp"
 33 #include "oops/oop.hpp"
 34 #include "runtime/objectMonitor.hpp"
 35 #include "runtime/safepoint.hpp"
 36 #include "utilities/align.hpp"
 37 #include "utilities/count_trailing_zeros.hpp"
 38 #include "utilities/debug.hpp"
 39 #include "utilities/globalDefinitions.hpp"
 40 
 41 // Array of all active blocks.  Refcounted for lock-free reclaim of
 42 // old array when a new array is allocated for expansion.
 43 class OopStorage::ActiveArray {
 44   friend class OopStorage::TestAccess;
 45 
 46   size_t _size;
 47   volatile size_t _block_count;
 48   mutable volatile int _refcount;
 49   // Block* _blocks[1];            // Pseudo flexible array member.
 50 
 51   ActiveArray(size_t size);
 52   ~ActiveArray();
 53 
 54   NONCOPYABLE(ActiveArray);

246   Closure* _cl;
247 };
248 
249 template<typename Closure>
250 inline OopStorage::OopFn<Closure> OopStorage::oop_fn(Closure* cl) {
251   return OopFn<Closure>(cl);
252 }
253 
254 template<typename IsAlive, typename F>
255 class OopStorage::IfAliveFn {
256 public:
257   IfAliveFn(IsAlive* is_alive, F f) : _is_alive(is_alive), _f(f) {}
258 
259   bool operator()(oop* ptr) const {
260     bool result = true;
261     oop v = *ptr;
262     if (v != NULL) {
263       if (_is_alive->do_object_b(v)) {
264         result = _f(ptr);
265       } else {
266         ObjectMonitor::maybe_deflate_dead(ptr);
267         *ptr = NULL;            // Clear dead value.
268       }
269     }
270     return result;
271   }
272 
273 private:
274   IsAlive* _is_alive;
275   F _f;
276 };
277 
278 template<typename IsAlive, typename F>
279 inline OopStorage::IfAliveFn<IsAlive, F> OopStorage::if_alive_fn(IsAlive* is_alive, F f) {
280   return IfAliveFn<IsAlive, F>(is_alive, f);
281 }
282 
283 template<typename F>
284 class OopStorage::SkipNullFn {
285 public:
286   SkipNullFn(F f) : _f(f) {}
< prev index next >