src/hotspot/share/classfile/classLoaderData.inline.hpp
author coleenp
Wed, 08 Aug 2018 15:24:21 -0400
changeset 51338 aa3bfacc912c
parent 49824 e242740a92b8
child 51380 e081161320e4
permissions -rw-r--r--
8208677: Move inner metaspace cleaning out of class unloading Summary: move to safepoint cleanup actions to do if needed. Reviewed-by: eosterlund, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    24
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48884
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_CLASSLOADERDATA_INLINE_HPP
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48884
diff changeset
    26
#define SHARE_VM_CLASSFILE_CLASSLOADERDATA_INLINE_HPP
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48884
diff changeset
    27
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    28
#include "classfile/classLoaderData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    29
#include "classfile/javaClasses.hpp"
51338
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
    30
#include "oops/instanceKlass.hpp"
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 22234
diff changeset
    31
#include "oops/oop.inline.hpp"
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    32
#include "oops/oopHandle.inline.hpp"
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    33
#include "oops/weakHandle.inline.hpp"
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    34
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    35
inline oop ClassLoaderData::class_loader() const {
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    36
  assert(!_unloading, "This oop is not available to unloading class loader data");
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    37
  assert(_holder.is_null() || _holder.peek() != NULL , "This class loader data holder must be alive");
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    38
  return _class_loader.resolve();
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    39
}
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    40
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    41
inline bool ClassLoaderData::is_boot_class_loader_data() const {
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    42
    return class_loader() == NULL;
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49348
diff changeset
    43
  }
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 22234
diff changeset
    44
15847
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    45
inline ClassLoaderData* ClassLoaderData::class_loader_data_or_null(oop loader) {
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    46
  if (loader == NULL) {
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    47
    return ClassLoaderData::the_null_class_loader_data();
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    48
  }
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    49
  return java_lang_ClassLoader::loader_data(loader);
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    50
}
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    51
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
inline ClassLoaderData* ClassLoaderData::class_loader_data(oop loader) {
15847
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
    53
  ClassLoaderData* loader_data = class_loader_data_or_null(loader);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    54
  assert(loader_data != NULL, "Must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    55
  return loader_data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    56
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    57
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    58
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
    59
inline ClassLoaderData *ClassLoaderDataGraph::find_or_create(Handle loader) {
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46729
diff changeset
    60
  guarantee(loader() != NULL && oopDesc::is_oop(loader()), "Loader must be oop");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    61
  // Gets the class loader data out of the java/lang/ClassLoader object, if non-null
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    62
  // it's already in the loader_data, so no need to add
17107
46fc21b30a1e 8011802: NPG: init_dependencies in class loader data graph can cause invalid CLD
mgerdin
parents: 15847
diff changeset
    63
  ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data(loader());
46fc21b30a1e 8011802: NPG: init_dependencies in class loader data graph can cause invalid CLD
mgerdin
parents: 15847
diff changeset
    64
  if (loader_data) {
46fc21b30a1e 8011802: NPG: init_dependencies in class loader data graph can cause invalid CLD
mgerdin
parents: 15847
diff changeset
    65
     return loader_data;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    66
  }
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
    67
  return ClassLoaderDataGraph::add(loader, false);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    68
}
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    69
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    70
size_t ClassLoaderDataGraph::num_instance_classes() {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    71
  return _num_instance_classes;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    72
}
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    73
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    74
size_t ClassLoaderDataGraph::num_array_classes() {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    75
  return _num_array_classes;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    76
}
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    77
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    78
void ClassLoaderDataGraph::inc_instance_classes(size_t count) {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    79
  Atomic::add(count, &_num_instance_classes);
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    80
}
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    81
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    82
void ClassLoaderDataGraph::dec_instance_classes(size_t count) {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    83
  assert(count <= _num_instance_classes, "Sanity");
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    84
  Atomic::sub(count, &_num_instance_classes);
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    85
}
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    86
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    87
void ClassLoaderDataGraph::inc_array_classes(size_t count) {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    88
  Atomic::add(count, &_num_array_classes);
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    89
}
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    90
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    91
void ClassLoaderDataGraph::dec_array_classes(size_t count) {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    92
  assert(count <= _num_array_classes, "Sanity");
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    93
  Atomic::sub(count, &_num_array_classes);
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    94
}
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48884
diff changeset
    95
51338
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
    96
bool ClassLoaderDataGraph::should_clean_metaspaces_and_reset() {
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
    97
  bool do_cleaning = _safepoint_cleanup_needed;
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
    98
  _safepoint_cleanup_needed = false;  // reset
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
    99
  return (do_cleaning && _should_clean_deallocate_lists) || InstanceKlass::has_previous_versions();
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
   100
}
aa3bfacc912c 8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents: 49824
diff changeset
   101
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48884
diff changeset
   102
#endif // SHARE_VM_CLASSFILE_CLASSLOADERDATA_INLINE_HPP