author | coleenp |
Wed, 24 Jul 2019 10:22:11 -0400 | |
changeset 57511 | 00ae3b739184 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52119
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52119
diff
changeset
|
25 |
#ifndef SHARE_OOPS_INSTANCEREFKLASS_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52119
diff
changeset
|
26 |
#define SHARE_OOPS_INSTANCEREFKLASS_HPP |
7397 | 27 |
|
28 |
#include "oops/instanceKlass.hpp" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13738
diff
changeset
|
29 |
#include "utilities/macros.hpp" |
7397 | 30 |
|
34666 | 31 |
class ClassFileParser; |
32 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
33 |
// An InstanceRefKlass is a specialized InstanceKlass for Java |
1 | 34 |
// classes that are subclasses of java/lang/ref/Reference. |
35 |
// |
|
36 |
// These classes are used to implement soft/weak/final/phantom |
|
37 |
// references and finalization, and need special treatment by the |
|
38 |
// garbage collector. |
|
39 |
// |
|
40 |
// During GC discovered reference objects are added (chained) to one |
|
41 |
// of the four lists below, depending on the type of reference. |
|
42 |
// The linked occurs through the next field in class java/lang/ref/Reference. |
|
43 |
// |
|
44 |
// Afterwards, the discovered references are processed in decreasing |
|
45 |
// order of reachability. Reference objects eligible for notification |
|
46 |
// are linked to the static pending_list in class java/lang/ref/Reference, |
|
47 |
// and the pending list lock object in the same class is notified. |
|
48 |
||
49 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
50 |
class InstanceRefKlass: public InstanceKlass { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7446
diff
changeset
|
51 |
friend class InstanceKlass; |
50752 | 52 |
public: |
53 |
static const KlassID ID = InstanceRefKlassID; |
|
54 |
||
34666 | 55 |
private: |
50752 | 56 |
InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference, ID) {} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7446
diff
changeset
|
57 |
|
1 | 58 |
public: |
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
59 |
InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } |
1 | 60 |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
61 |
// 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
|
62 |
// |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
63 |
// The InstanceRefKlass iterators also support reference processing. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
64 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
65 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
66 |
// Forward iteration |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
67 |
// Iterate over all oop fields and metadata. |
50752 | 68 |
template <typename T, class OopClosureType> |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
69 |
inline void oop_oop_iterate(oop obj, OopClosureType* closure); |
1 | 70 |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
71 |
// Reverse iteration |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
72 |
// Iterate over all oop fields and metadata. |
50752 | 73 |
template <typename T, class OopClosureType> |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
74 |
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
|
75 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
76 |
// Bounded range iteration |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
77 |
// Iterate over all oop fields and metadata. |
50752 | 78 |
template <typename T, class OopClosureType> |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
79 |
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
|
80 |
|
50752 | 81 |
private: |
82 |
||
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
83 |
// Reference processing part of the iterators. |
1 | 84 |
|
50752 | 85 |
template <typename T, class OopClosureType, class Contains> |
86 |
inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure, Contains& contains); |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
87 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
88 |
// Only perform reference processing if the referent object is within mr. |
50752 | 89 |
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
|
90 |
inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr); |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
91 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
92 |
// Reference processing |
50752 | 93 |
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
|
94 |
inline void oop_oop_iterate_ref_processing(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
|
95 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
96 |
// Building blocks for specialized handling. |
50752 | 97 |
template <typename T, class OopClosureType, class Contains> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
98 |
static void do_referent(oop obj, OopClosureType* closure, Contains& contains); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
99 |
|
50752 | 100 |
template <typename T, class OopClosureType, class Contains> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
101 |
static void do_next(oop obj, OopClosureType* closure, Contains& contains); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
102 |
|
50752 | 103 |
template <typename T, class OopClosureType, class Contains> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
104 |
static void do_discovered(oop obj, OopClosureType* closure, Contains& contains); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
105 |
|
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
106 |
template <typename T, class OopClosureType> |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
107 |
static bool try_discover(oop obj, ReferenceType type, OopClosureType* closure); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
108 |
|
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
109 |
// Do discovery while handling InstanceRefKlasses. Reference discovery |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
110 |
// is only done if the closure provides a ReferenceProcessor. |
50752 | 111 |
template <typename T, class OopClosureType, class Contains> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
112 |
static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
113 |
|
46445
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
114 |
// Used for a special case in G1 where the closure needs to be applied |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
115 |
// to the discovered field. Reference discovery is also done if the |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
116 |
// closure provides a ReferenceProcessor. |
50752 | 117 |
template <typename T, class OopClosureType, class Contains> |
46445
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
118 |
static void oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
119 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
120 |
// Apply the closure to all fields. No reference discovery is done. |
50752 | 121 |
template <typename T, class OopClosureType, class Contains> |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
122 |
static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains); |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
123 |
|
50870
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50752
diff
changeset
|
124 |
// Apply the closure to all fields, except the referent field. No reference discovery is done. |
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50752
diff
changeset
|
125 |
template <typename T, class OopClosureType, class Contains> |
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50752
diff
changeset
|
126 |
static void oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains); |
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50752
diff
changeset
|
127 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37129
diff
changeset
|
128 |
template <typename T> |
46446
ababb65abf24
8179550: Unify trace logging for InstanceRefKlass
sjohanss
parents:
46445
diff
changeset
|
129 |
static void trace_reference_gc(const char *s, oop obj) NOT_DEBUG_RETURN; |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
130 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29688
diff
changeset
|
131 |
public: |
1 | 132 |
// Update non-static oop maps so 'referent', 'nextPending' and |
133 |
// 'discovered' will look like non-oops |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7446
diff
changeset
|
134 |
static void update_nonstatic_oop_maps(Klass* k); |
1 | 135 |
|
136 |
public: |
|
137 |
// Verification |
|
138 |
void oop_verify_on(oop obj, outputStream* st); |
|
139 |
}; |
|
7397 | 140 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52119
diff
changeset
|
141 |
#endif // SHARE_OOPS_INSTANCEREFKLASS_HPP |