< prev index next >

src/share/vm/oops/instanceKlass.inline.hpp

Print this page
rev 8366 : 8080746: Refactor oop iteration macros to be more general
Reviewed-by:


  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_VM_OOPS_INSTANCEKLASS_INLINE_HPP
  26 #define SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP
  27 
  28 #include "memory/iterator.hpp"
  29 #include "oops/instanceKlass.hpp"

  30 #include "oops/oop.inline.hpp"
  31 #include "utilities/debug.hpp"
  32 #include "utilities/globalDefinitions.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 // The iteration over the oops in objects is a hot path in the GC code.
  36 // By force inlining the following functions, we get similar GC performance
  37 // as the previous macro based implementation.
  38 #ifdef TARGET_COMPILER_visCPP
  39 #define INLINE __forceinline
  40 #else
  41 #define INLINE inline
  42 #endif
  43 
  44 template <bool nv, typename T, class OopClosureType>
  45 INLINE void InstanceKlass::oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure) {
  46   T* p         = (T*)obj->obj_field_addr<T>(map->offset());
  47   T* const end = p + map->count();
  48 
  49   for (; p < end; ++p) {


 170 
 171   return size_helper();
 172 }
 173 #endif
 174 
 175 template <bool nv, class OopClosureType>
 176 INLINE int InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
 177   if (Devirtualizer<nv>::do_metadata(closure)) {
 178     if (mr.contains(obj)) {
 179       Devirtualizer<nv>::do_klass(closure, this);
 180     }
 181   }
 182 
 183   oop_oop_iterate_oop_maps_bounded<nv>(obj, closure, mr);
 184 
 185   return size_helper();
 186 }
 187 
 188 #undef INLINE
 189 
 190 
 191 #define InstanceKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)              \
 192 int InstanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {  \
 193   return oop_oop_iterate<nvs_to_bool(nv_suffix)>(obj, closure);                    \
 194 }
 195 
 196 #if INCLUDE_ALL_GCS
 197 #define InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)              \
 198 int InstanceKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {  \
 199   return oop_oop_iterate_reverse<nvs_to_bool(nv_suffix)>(obj, closure);                      \
 200 }
 201 #else
 202 #define InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 203 #endif
 204 
 205 #define InstanceKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)                              \
 206 int InstanceKlass::oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* closure, MemRegion mr) {  \
 207   return oop_oop_iterate_bounded<nvs_to_bool(nv_suffix)>(obj, closure, mr);                          \
 208 }
 209 
 210 #define ALL_INSTANCE_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)  \
 211   InstanceKlass_OOP_OOP_ITERATE_DEFN(          OopClosureType, nv_suffix)   \
 212   InstanceKlass_OOP_OOP_ITERATE_DEFN_m(        OopClosureType, nv_suffix)   \
 213   InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 214 
 215 #endif // SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP


  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_VM_OOPS_INSTANCEKLASS_INLINE_HPP
  26 #define SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP
  27 
  28 #include "memory/iterator.hpp"
  29 #include "oops/instanceKlass.hpp"
  30 #include "oops/klass.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "utilities/debug.hpp"
  33 #include "utilities/globalDefinitions.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 // The iteration over the oops in objects is a hot path in the GC code.
  37 // By force inlining the following functions, we get similar GC performance
  38 // as the previous macro based implementation.
  39 #ifdef TARGET_COMPILER_visCPP
  40 #define INLINE __forceinline
  41 #else
  42 #define INLINE inline
  43 #endif
  44 
  45 template <bool nv, typename T, class OopClosureType>
  46 INLINE void InstanceKlass::oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure) {
  47   T* p         = (T*)obj->obj_field_addr<T>(map->offset());
  48   T* const end = p + map->count();
  49 
  50   for (; p < end; ++p) {


 171 
 172   return size_helper();
 173 }
 174 #endif
 175 
 176 template <bool nv, class OopClosureType>
 177 INLINE int InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
 178   if (Devirtualizer<nv>::do_metadata(closure)) {
 179     if (mr.contains(obj)) {
 180       Devirtualizer<nv>::do_klass(closure, this);
 181     }
 182   }
 183 
 184   oop_oop_iterate_oop_maps_bounded<nv>(obj, closure, mr);
 185 
 186   return size_helper();
 187 }
 188 
 189 #undef INLINE
 190 




















 191 #define ALL_INSTANCE_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)  \
 192   OOP_OOP_ITERATE_DEFN(          InstanceKlass, OopClosureType, nv_suffix)  \
 193   OOP_OOP_ITERATE_DEFN_m(        InstanceKlass, OopClosureType, nv_suffix)  \
 194   OOP_OOP_ITERATE_BACKWARDS_DEFN(InstanceKlass, OopClosureType, nv_suffix)
 195 
 196 #endif // SHARE_VM_OOPS_INSTANCEKLASS_INLINE_HPP
< prev index next >