Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/oops/instanceMirrorKlass.inline.hpp
40951 views
1
/*
2
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
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
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP
26
#define SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP
27
28
#include "oops/instanceMirrorKlass.hpp"
29
30
#include "classfile/javaClasses.hpp"
31
#include "oops/instanceKlass.inline.hpp"
32
#include "oops/klass.hpp"
33
#include "oops/oop.inline.hpp"
34
#include "utilities/debug.hpp"
35
#include "utilities/globalDefinitions.hpp"
36
#include "utilities/macros.hpp"
37
38
template <typename T, class OopClosureType>
39
void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) {
40
T* p = (T*)start_of_static_fields(obj);
41
T* const end = p + java_lang_Class::static_oop_field_count_raw(obj);
42
43
for (; p < end; ++p) {
44
Devirtualizer::do_oop(closure, p);
45
}
46
}
47
48
template <typename T, class OopClosureType>
49
void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
50
InstanceKlass::oop_oop_iterate<T>(obj, closure);
51
52
if (Devirtualizer::do_metadata(closure)) {
53
Klass* klass = java_lang_Class::as_Klass_raw(obj);
54
// We'll get NULL for primitive mirrors.
55
if (klass != NULL) {
56
if (klass->class_loader_data() == NULL) {
57
// This is a mirror that belongs to a shared class that has not be loaded yet.
58
// It's only reachable via HeapShared::roots(). All of its fields should be zero
59
// so there's no need to scan.
60
assert(klass->is_shared(), "must be");
61
return;
62
} else if (klass->is_instance_klass() && klass->class_loader_data()->has_class_mirror_holder()) {
63
// A non-strong hidden class doesn't have its own class loader,
64
// so when handling the java mirror for the class we need to make sure its class
65
// loader data is claimed, this is done by calling do_cld explicitly.
66
// For non-strong hidden classes the call to do_cld is made when the class
67
// loader itself is handled.
68
Devirtualizer::do_cld(closure, klass->class_loader_data());
69
} else {
70
Devirtualizer::do_klass(closure, klass);
71
}
72
} else {
73
// We would like to assert here (as below) that if klass has been NULL, then
74
// this has been a mirror for a primitive type that we do not need to follow
75
// as they are always strong roots.
76
// However, we might get across a klass that just changed during CMS concurrent
77
// marking if allocation occurred in the old generation.
78
// This is benign here, as we keep alive all CLDs that were loaded during the
79
// CMS concurrent phase in the class loading, i.e. they will be iterated over
80
// and kept alive during remark.
81
// assert(java_lang_Class::is_primitive(obj), "Sanity check");
82
}
83
}
84
85
oop_oop_iterate_statics<T>(obj, closure);
86
}
87
88
template <typename T, class OopClosureType>
89
void InstanceMirrorKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
90
InstanceKlass::oop_oop_iterate_reverse<T>(obj, closure);
91
92
InstanceMirrorKlass::oop_oop_iterate_statics<T>(obj, closure);
93
}
94
95
template <typename T, class OopClosureType>
96
void InstanceMirrorKlass::oop_oop_iterate_statics_bounded(oop obj,
97
OopClosureType* closure,
98
MemRegion mr) {
99
T* p = (T*)start_of_static_fields(obj);
100
T* end = p + java_lang_Class::static_oop_field_count_raw(obj);
101
102
T* const l = (T*)mr.start();
103
T* const h = (T*)mr.end();
104
assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 &&
105
mask_bits((intptr_t)h, sizeof(T)-1) == 0,
106
"bounded region must be properly aligned");
107
108
if (p < l) {
109
p = l;
110
}
111
if (end > h) {
112
end = h;
113
}
114
115
for (;p < end; ++p) {
116
Devirtualizer::do_oop(closure, p);
117
}
118
}
119
120
template <typename T, class OopClosureType>
121
void InstanceMirrorKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
122
InstanceKlass::oop_oop_iterate_bounded<T>(obj, closure, mr);
123
124
if (Devirtualizer::do_metadata(closure)) {
125
if (mr.contains(obj)) {
126
Klass* klass = java_lang_Class::as_Klass_raw(obj);
127
// We'll get NULL for primitive mirrors.
128
if (klass != NULL) {
129
Devirtualizer::do_klass(closure, klass);
130
}
131
}
132
}
133
134
oop_oop_iterate_statics_bounded<T>(obj, closure, mr);
135
}
136
137
#endif // SHARE_OOPS_INSTANCEMIRRORKLASS_INLINE_HPP
138
139