1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 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_INLINE_HPP 26 #define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP 27 28 #include "gc/shared/oopStorage.inline.hpp" 29 #include "gc/shared/oopStorageParState.hpp" 30 #include "metaprogramming/conditional.hpp" 31 #include "utilities/macros.hpp" 32 33 #if INCLUDE_ALL_GCS 34 35 template<typename F> 36 class OopStorage::BasicParState::AlwaysTrueFn { 37 F _f; 38 39 public: 40 AlwaysTrueFn(F f) : _f(f) {} 41 42 template<typename OopPtr> // [const] oop* 43 bool operator()(OopPtr ptr) const { _f(ptr); return true; } 44 }; 45 46 template<bool is_const, typename F> 47 inline void OopStorage::BasicParState::iterate(F f) { 48 // Wrap f in ATF so we can use Block::iterate. 49 AlwaysTrueFn<F> atf_f(f); 50 ensure_iteration_started(); 51 typename Conditional<is_const, const Block*, Block*>::type block; 52 while ((block = claim_next_block()) != NULL) { 53 block->iterate(atf_f); 54 } 55 } 56 57 template<bool concurrent, bool is_const> 58 template<typename F> 59 inline void OopStorage::ParState<concurrent, is_const>::iterate(F f) { 60 _basic_state.template iterate<is_const>(f); 61 } 62 63 template<bool concurrent, bool is_const> 64 template<typename Closure> 65 inline void OopStorage::ParState<concurrent, is_const>::oops_do(Closure* cl) { 66 this->iterate(oop_fn(cl)); 67 } 68 69 template<typename F> 70 inline void OopStorage::ParState<false, false>::iterate(F f) { 71 _basic_state.template iterate<false>(f); 72 } 73 74 template<typename Closure> 75 inline void OopStorage::ParState<false, false>::oops_do(Closure* cl) { 76 this->iterate(oop_fn(cl)); 77 } 78 79 template<typename Closure> 80 inline void OopStorage::ParState<false, false>::weak_oops_do(Closure* cl) { 81 this->iterate(skip_null_fn(oop_fn(cl))); 82 } 83 84 template<typename IsAliveClosure, typename Closure> 85 inline void OopStorage::ParState<false, false>::weak_oops_do(IsAliveClosure* is_alive, Closure* cl) { 86 this->iterate(if_alive_fn(is_alive, oop_fn(cl))); 87 } 88 89 #endif // INCLUDE_ALL_GCS 90 91 #endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP