src/hotspot/share/memory/iterator.inline.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 33105 hotspot/src/share/vm/memory/iterator.inline.hpp@294e48b4f704
child 47580 96392e113a0a
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
  assert(_klass_closure._oop_closure == this, "Must be");
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    41
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    42
  bool claim = true;  // Must claim the class loader data before processing.
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    43
  cld->oops_do(_klass_closure._oop_closure, &_klass_closure, claim);
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    44
}
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    45
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    46
inline void MetadataAwareOopClosure::do_klass_nv(Klass* k) {
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    47
  ClassLoaderData* cld = k->class_loader_data();
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    48
  do_cld_nv(cld);
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    49
}
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
    50
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    51
#ifdef ASSERT
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    52
// 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
    53
// 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
    54
template <typename T>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    55
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
    56
  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
    57
    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
    58
    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
    59
      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
    60
      assert(Universe::heap()->is_in_closed_subset(o),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32606
diff changeset
    61
             "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
    62
    }
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    63
  }
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
#endif
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
// 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
    68
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    69
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
    70
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
    71
  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
    72
  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
    73
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    74
template <class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    75
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
    76
  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
    77
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    78
template <class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    79
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
    80
  closure->do_cld_nv(cld);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    81
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
    82
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
    83
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
    84
  // 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
    85
  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
    86
  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
    87
}
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
// 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
    90
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    91
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
    92
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
    93
  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
    94
  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
    95
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    96
template <class OopClosureType>
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
    97
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
    98
  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
    99
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   100
template <class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   101
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
   102
  closure->do_cld(cld);
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   103
}
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30150
diff changeset
   104
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
   105
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
   106
  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
   107
}
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   108
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 25356
diff changeset
   109
// 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
   110
#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
   111
  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
   112
  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
   113
  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
   114
  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
   115
  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
   116
  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
   117
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff changeset
   118
#endif // SHARE_VM_MEMORY_ITERATOR_INLINE_HPP