author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 51516 | 7c3891b9f1e0 |
permissions | -rw-r--r-- |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51516
diff
changeset
|
1 |
/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
3 |
* |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
4 |
* This code is free software; you can redistribute it and/or modify it |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
6 |
* published by the Free Software Foundation. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
7 |
* |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
8 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
9 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
10 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
11 |
* version 2 for more details (a copy is included in the LICENSE file that |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
12 |
* accompanied this code). |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
13 |
* |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License version |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
15 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
17 |
* |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
18 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
19 |
* or visit www.oracle.com if you need additional information or have any |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
20 |
* questions. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
21 |
* |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
22 |
*/ |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
23 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51516
diff
changeset
|
24 |
#ifndef SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51516
diff
changeset
|
25 |
#define SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
26 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
27 |
#include "classfile/javaClasses.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
28 |
#include "oops/instanceKlass.inline.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
29 |
#include "oops/instanceMirrorKlass.hpp" |
30880
efe35e08179f
8080746: Refactor oop iteration macros to be more general
sjohanss
parents:
30150
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:
diff
changeset
|
31 |
#include "oops/oop.inline.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
32 |
#include "utilities/debug.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
33 |
#include "utilities/globalDefinitions.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
34 |
#include "utilities/macros.hpp" |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
35 |
|
50752 | 36 |
template <typename T, class OopClosureType> |
37 |
void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) { |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
38 |
T* p = (T*)start_of_static_fields(obj); |
51516
7c3891b9f1e0
8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents:
51444
diff
changeset
|
39 |
T* const end = p + java_lang_Class::static_oop_field_count_raw(obj); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
40 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
41 |
for (; p < end; ++p) { |
50752 | 42 |
Devirtualizer::do_oop(closure, p); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
43 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
44 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
45 |
|
50752 | 46 |
template <typename T, class OopClosureType> |
47 |
void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) { |
|
48 |
InstanceKlass::oop_oop_iterate<T>(obj, closure); |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
49 |
|
50752 | 50 |
if (Devirtualizer::do_metadata(closure)) { |
51516
7c3891b9f1e0
8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents:
51444
diff
changeset
|
51 |
Klass* klass = java_lang_Class::as_Klass_raw(obj); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
52 |
// We'll get NULL for primitive mirrors. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
53 |
if (klass != NULL) { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
50752
diff
changeset
|
54 |
if (klass->is_instance_klass() && |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
50752
diff
changeset
|
55 |
InstanceKlass::cast(klass)->is_unsafe_anonymous()) { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
50752
diff
changeset
|
56 |
// An unsafe anonymous class doesn't have its own class loader, so |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
50752
diff
changeset
|
57 |
// when handling the java mirror for the class we need to make sure its class |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
58 |
// loader data is claimed, this is done by calling do_cld explicitly. |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
59 |
// For non-anonymous classes the call to do_cld is made when the class |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
60 |
// loader itself is handled. |
50752 | 61 |
Devirtualizer::do_cld(closure, klass->class_loader_data()); |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
62 |
} else { |
50752 | 63 |
Devirtualizer::do_klass(closure, klass); |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
64 |
} |
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
65 |
} else { |
48101
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
66 |
// We would like to assert here (as below) that if klass has been NULL, then |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
67 |
// this has been a mirror for a primitive type that we do not need to follow |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
68 |
// as they are always strong roots. |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
69 |
// However, we might get across a klass that just changed during CMS concurrent |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
70 |
// marking if allocation occurred in the old generation. |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
71 |
// This is benign here, as we keep alive all CLDs that were loaded during the |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
72 |
// CMS concurrent phase in the class loading, i.e. they will be iterated over |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
73 |
// and kept alive during remark. |
02f9be87cf5c
8179244: Assert failed in instanceMirrorKlass.inline.hpp
tschatzl
parents:
47216
diff
changeset
|
74 |
// assert(java_lang_Class::is_primitive(obj), "Sanity check"); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
75 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
76 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
77 |
|
50752 | 78 |
oop_oop_iterate_statics<T>(obj, closure); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
79 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
80 |
|
50752 | 81 |
template <typename T, class OopClosureType> |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
82 |
void InstanceMirrorKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) { |
50752 | 83 |
InstanceKlass::oop_oop_iterate_reverse<T>(obj, closure); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
84 |
|
50752 | 85 |
InstanceMirrorKlass::oop_oop_iterate_statics<T>(obj, closure); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
86 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
87 |
|
50752 | 88 |
template <typename T, class OopClosureType> |
89 |
void InstanceMirrorKlass::oop_oop_iterate_statics_bounded(oop obj, |
|
90 |
OopClosureType* closure, |
|
91 |
MemRegion mr) { |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
92 |
T* p = (T*)start_of_static_fields(obj); |
51516
7c3891b9f1e0
8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents:
51444
diff
changeset
|
93 |
T* end = p + java_lang_Class::static_oop_field_count_raw(obj); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
94 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
95 |
T* const l = (T*)mr.start(); |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
96 |
T* const h = (T*)mr.end(); |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
97 |
assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 && |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
98 |
mask_bits((intptr_t)h, sizeof(T)-1) == 0, |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
99 |
"bounded region must be properly aligned"); |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
100 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
101 |
if (p < l) { |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
102 |
p = l; |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
103 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
104 |
if (end > h) { |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
105 |
end = h; |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
106 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
107 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
108 |
for (;p < end; ++p) { |
50752 | 109 |
Devirtualizer::do_oop(closure, p); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
110 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
111 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
112 |
|
50752 | 113 |
template <typename T, class OopClosureType> |
114 |
void InstanceMirrorKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) { |
|
115 |
InstanceKlass::oop_oop_iterate_bounded<T>(obj, closure, mr); |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
116 |
|
50752 | 117 |
if (Devirtualizer::do_metadata(closure)) { |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
118 |
if (mr.contains(obj)) { |
51516
7c3891b9f1e0
8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents:
51444
diff
changeset
|
119 |
Klass* klass = java_lang_Class::as_Klass_raw(obj); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
120 |
// We'll get NULL for primitive mirrors. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
121 |
if (klass != NULL) { |
50752 | 122 |
Devirtualizer::do_klass(closure, klass); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
123 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
124 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
125 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
126 |
|
50752 | 127 |
oop_oop_iterate_statics_bounded<T>(obj, closure, mr); |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
128 |
} |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
diff
changeset
|
129 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51516
diff
changeset
|
130 |
#endif // SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP |