author | dholmes |
Sat, 23 Jun 2018 01:32:41 -0400 | |
changeset 50735 | 2f2af62dfac7 |
parent 49592 | 77fb0be7d19f |
child 50752 | 9d62da00bf15 |
permissions | -rw-r--r-- |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff
changeset
|
1 |
/* |
47580 | 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" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47580
diff
changeset
|
30 |
#include "oops/access.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47580
diff
changeset
|
31 |
#include "oops/compressedOops.inline.hpp" |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff
changeset
|
32 |
#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
|
33 |
#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
|
34 |
#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
|
35 |
#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
|
36 |
#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
|
37 |
#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
|
38 |
#include "oops/typeArrayKlass.inline.hpp" |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff
changeset
|
39 |
#include "utilities/debug.hpp" |
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
diff
changeset
|
40 |
|
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30150
diff
changeset
|
41 |
inline void MetadataAwareOopClosure::do_cld_nv(ClassLoaderData* cld) { |
25356
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. |
47580 | 43 |
cld->oops_do(this, claim); |
25356
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()) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47580
diff
changeset
|
57 |
T heap_oop = RawAccess<>::oop_load(p); |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47580
diff
changeset
|
58 |
if (!CompressedOops::is_null(heap_oop)) { |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47580
diff
changeset
|
59 |
oop o = CompressedOops::decode_not_null(heap_oop); |
30150
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 |