src/hotspot/share/oops/instanceMirrorKlass.hpp
author ccheung
Wed, 02 Oct 2019 16:55:08 -0700
changeset 58447 319173c62caa
parent 53244 9807daeb47c4
permissions -rw-r--r--
8231606: _method_ordering is not set during CDS dynamic dump time Summary: Add the missing DynamicDumpSharedSpaces check in sort_methods(); replace the (DumpSharedSpaces || DynamicDumpSharedSpaces) with the Arguments::is_dumping_archive() function call. Reviewed-by: iklam, coleenp, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52119
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     4
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     8
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    13
 * accompanied this code).
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    14
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    18
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    21
 * questions.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    22
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    23
 */
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52119
diff changeset
    25
#ifndef SHARE_OOPS_INSTANCEMIRRORKLASS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52119
diff changeset
    26
#define SHARE_OOPS_INSTANCEMIRRORKLASS_HPP
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    27
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8878
diff changeset
    28
#include "classfile/systemDictionary.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    29
#include "oops/instanceKlass.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8878
diff changeset
    30
#include "runtime/handles.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13738
diff changeset
    31
#include "utilities/macros.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    32
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 33151
diff changeset
    33
class ClassFileParser;
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 33151
diff changeset
    34
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    35
// An InstanceMirrorKlass is a specialized InstanceKlass for
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    36
// java.lang.Class instances.  These instances are special because
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    37
// they contain the static fields of the class in addition to the
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    38
// normal fields of Class.  This means they are variable sized
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    39
// instances and need special logic for computing their size and for
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    40
// iteration of their oops.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    41
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    42
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    43
class InstanceMirrorKlass: public InstanceKlass {
8878
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
    44
  friend class VMStructs;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8878
diff changeset
    45
  friend class InstanceKlass;
8878
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
    46
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
    47
 public:
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
    48
  static const KlassID ID = InstanceMirrorKlassID;
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
    49
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    50
 private:
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    51
  static int _offset_of_static_fields;
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    52
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
    53
  InstanceMirrorKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_mirror, ID) {}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8878
diff changeset
    54
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    55
 public:
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    56
  InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    57
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8878
diff changeset
    58
  // Casting from Klass*
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    59
  static InstanceMirrorKlass* cast(Klass* k) {
33151
686d694f5c6a 8138659: Speed up InstanceKlass subclass discrimination
kbarrett
parents: 32606
diff changeset
    60
    assert(InstanceKlass::cast(k)->is_mirror_instance_klass(),
686d694f5c6a 8138659: Speed up InstanceKlass subclass discrimination
kbarrett
parents: 32606
diff changeset
    61
           "cast to InstanceMirrorKlass");
686d694f5c6a 8138659: Speed up InstanceKlass subclass discrimination
kbarrett
parents: 32606
diff changeset
    62
    return static_cast<InstanceMirrorKlass*>(k);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    63
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    64
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    65
  // Returns the size of the instance including the extra static fields.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    66
  virtual int oop_size(oop obj) const;
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    67
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    68
  // Static field offset is an offset into the Heap, should be converted by
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    69
  // based on UseCompressedOop for traversal
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    70
  static HeapWord* start_of_static_fields(oop obj) {
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 15482
diff changeset
    71
    return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    72
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    73
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    74
  static void init_offset_of_static_fields() {
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    75
    // Cache the offset of the static fields in the Class instance
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    76
    assert(_offset_of_static_fields == 0, "once");
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    77
    _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    78
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    79
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    80
  static int offset_of_static_fields() {
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    81
    return _offset_of_static_fields;
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    82
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    83
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    84
  int compute_static_oop_field_count(oop obj);
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    85
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    86
  // Given a Klass return the size of the instance
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 35877
diff changeset
    87
  int instance_size(Klass* k);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    88
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    89
  // allocation
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 35877
diff changeset
    90
  instanceOop allocate_instance(Klass* k, TRAPS);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    91
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50752
diff changeset
    92
  static void serialize_offsets(class SerializeClosure* f) NOT_CDS_RETURN;
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50752
diff changeset
    93
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
    94
  // Oop fields (and metadata) iterators
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
    95
  //
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
    96
  // The InstanceMirrorKlass iterators also visit the hidden Klass pointer.
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
    97
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
    98
  // Iterate over the static fields.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
    99
  template <typename T, class OopClosureType>
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   100
  inline void oop_oop_iterate_statics(oop obj, OopClosureType* closure);
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   101
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   102
  // Forward iteration
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   103
  // Iterate over the oop fields and metadata.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   104
  template <typename T, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   105
  inline void oop_oop_iterate(oop obj, OopClosureType* closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   106
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   107
  // Reverse iteration
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   108
  // Iterate over the oop fields and metadata.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   109
  template <typename T, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   110
  inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   111
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   112
  // Bounded range iteration
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   113
  // Iterate over the oop fields and metadata.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   114
  template <typename T, class OopClosureType>
32606
fdaa30d06ada 8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents: 30880
diff changeset
   115
  inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   116
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   117
 private:
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   118
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29688
diff changeset
   119
  // Iterate over the static fields.
50752
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   120
  template <typename T, class OopClosureType>
9d62da00bf15 8204540: Automatic oop closure devirtualization
stefank
parents: 49982
diff changeset
   121
  inline void oop_oop_iterate_statics_bounded(oop obj, OopClosureType* closure, MemRegion mr);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
   122
};
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
   123
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52119
diff changeset
   124
#endif // SHARE_OOPS_INSTANCEMIRRORKLASS_HPP