src/hotspot/share/memory/iterator.inline.hpp
author coleenp
Wed, 21 Mar 2018 19:45:24 -0400
changeset 49480 d7df2dd501ce
parent 47580 96392e113a0a
child 49592 77fb0be7d19f
permissions -rw-r--r--
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files Summary: Remove frame.inline.hpp,etc from header files and adjust transitive includes. Reviewed-by: stefank, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     1
/*
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     4
 *
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     8
 *
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    13
 * accompanied this code).
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    14
 *
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    18
 *
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    21
 * questions.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    22
 *
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    23
 */
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    24
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    25
#ifndef SHARE_VM_MEMORY_ITERATOR_INLINE_HPP
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    26
#define SHARE_VM_MEMORY_ITERATOR_INLINE_HPP
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    27
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    28
#include "classfile/classLoaderData.hpp"
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    29
#include "memory/iterator.hpp"
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    30
#include "oops/klass.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    31
#include "oops/instanceKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    32
#include "oops/instanceMirrorKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    33
#include "oops/instanceClassLoaderKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    34
#include "oops/instanceRefKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    35
#include "oops/objArrayKlass.inline.hpp"
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    36
#include "oops/typeArrayKlass.inline.hpp"
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    37
#include "utilities/debug.hpp"
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    38
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    39
inline void MetadataAwareOopClosure::do_cld_nv(ClassLoaderData* cld) {
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    40
  bool claim = true;  // Must claim the class loader data before processing.
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
    41
  cld->oops_do(this, claim);
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    42
}
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    43
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    44
inline void MetadataAwareOopClosure::do_klass_nv(Klass* k) {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    45
  ClassLoaderData* cld = k->class_loader_data();
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    46
  do_cld_nv(cld);
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    47
}
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    48
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    49
#ifdef ASSERT
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    50
// This verification is applied to all visited oops.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    51
// The closures can turn is off by overriding should_verify_oops().
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    52
template <typename T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    53
void ExtendedOopClosure::verify(T* p) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    54
  if (should_verify_oops()) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    55
    T heap_oop = oopDesc::load_heap_oop(p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    56
    if (!oopDesc::is_null(heap_oop)) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    57
      oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    58
      assert(Universe::heap()->is_in_closed_subset(o),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32606
diff changeset
    59
             "should be in closed *p " PTR_FORMAT " " PTR_FORMAT, p2i(p), p2i(o));
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    60
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    61
  }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    62
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    63
#endif
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    64
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    65
// Implementation of the non-virtual do_oop dispatch.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    66
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    67
template <class OopClosureType, typename T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    68
inline void Devirtualizer<true>::do_oop(OopClosureType* closure, T* p) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    69
  debug_only(closure->verify(p));
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    70
  closure->do_oop_nv(p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    71
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    72
template <class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    73
inline void Devirtualizer<true>::do_klass(OopClosureType* closure, Klass* k) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    74
  closure->do_klass_nv(k);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    75
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    76
template <class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    77
void Devirtualizer<true>::do_cld(OopClosureType* closure, ClassLoaderData* cld) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    78
  closure->do_cld_nv(cld);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    79
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    80
template <class OopClosureType>
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    81
inline bool Devirtualizer<true>::do_metadata(OopClosureType* closure) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    82
  // Make sure the non-virtual and the virtual versions match.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    83
  assert(closure->do_metadata_nv() == closure->do_metadata(), "Inconsistency in do_metadata");
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    84
  return closure->do_metadata_nv();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    85
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    86
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    87
// Implementation of the virtual do_oop dispatch.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    88
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    89
template <class OopClosureType, typename T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    90
void Devirtualizer<false>::do_oop(OopClosureType* closure, T* p) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    91
  debug_only(closure->verify(p));
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    92
  closure->do_oop(p);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    93
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    94
template <class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    95
void Devirtualizer<false>::do_klass(OopClosureType* closure, Klass* k) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    96
  closure->do_klass(k);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    97
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    98
template <class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    99
void Devirtualizer<false>::do_cld(OopClosureType* closure, ClassLoaderData* cld) {
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   100
  closure->do_cld(cld);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   101
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   102
template <class OopClosureType>
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   103
bool Devirtualizer<false>::do_metadata(OopClosureType* closure) {
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   104
  return closure->do_metadata();
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   105
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   106
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   107
// The list of all "specializable" oop_oop_iterate function definitions.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   108
#define ALL_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)                  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   109
  ALL_INSTANCE_KLASS_OOP_OOP_ITERATE_DEFN(             OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   110
  ALL_INSTANCE_REF_KLASS_OOP_OOP_ITERATE_DEFN(         OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   111
  ALL_INSTANCE_MIRROR_KLASS_OOP_OOP_ITERATE_DEFN(      OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   112
  ALL_INSTANCE_CLASS_LOADER_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   113
  ALL_OBJ_ARRAY_KLASS_OOP_OOP_ITERATE_DEFN(            OopClosureType, nv_suffix)  \
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   114
  ALL_TYPE_ARRAY_KLASS_OOP_OOP_ITERATE_DEFN(           OopClosureType, nv_suffix)
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   115
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
   116
#endif // SHARE_VM_MEMORY_ITERATOR_INLINE_HPP