Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
41152 views
1
/*
2
* Copyright (c) 2010, 2021, 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_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
26
#define SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
27
28
#include "gc/parallel/psCompactionManager.hpp"
29
30
#include "classfile/classLoaderData.hpp"
31
#include "classfile/javaClasses.inline.hpp"
32
#include "gc/parallel/parMarkBitMap.hpp"
33
#include "gc/parallel/psParallelCompact.inline.hpp"
34
#include "gc/shared/taskqueue.inline.hpp"
35
#include "oops/access.inline.hpp"
36
#include "oops/arrayOop.hpp"
37
#include "oops/compressedOops.inline.hpp"
38
#include "oops/objArrayOop.inline.hpp"
39
#include "oops/oop.inline.hpp"
40
#include "utilities/debug.hpp"
41
#include "utilities/globalDefinitions.hpp"
42
43
class PCMarkAndPushClosure: public OopClosure {
44
private:
45
ParCompactionManager* _compaction_manager;
46
public:
47
PCMarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }
48
49
template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
50
virtual void do_oop(oop* p) { do_oop_nv(p); }
51
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
52
};
53
54
class PCIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
55
private:
56
ParCompactionManager* _compaction_manager;
57
public:
58
PCIterateMarkAndPushClosure(ParCompactionManager* cm, ReferenceProcessor* rp) : MetadataVisitingOopIterateClosure(rp), _compaction_manager(cm) { }
59
60
template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
61
virtual void do_oop(oop* p) { do_oop_nv(p); }
62
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
63
64
void do_klass_nv(Klass* k) { _compaction_manager->follow_klass(k); }
65
void do_cld_nv(ClassLoaderData* cld) { _compaction_manager->follow_class_loader(cld); }
66
};
67
68
inline bool ParCompactionManager::steal(int queue_num, oop& t) {
69
return oop_task_queues()->steal(queue_num, t);
70
}
71
72
inline bool ParCompactionManager::steal_objarray(int queue_num, ObjArrayTask& t) {
73
return _objarray_task_queues->steal(queue_num, t);
74
}
75
76
inline bool ParCompactionManager::steal(int queue_num, size_t& region) {
77
return region_task_queues()->steal(queue_num, region);
78
}
79
80
inline void ParCompactionManager::push(oop obj) {
81
_marking_stack.push(obj);
82
}
83
84
void ParCompactionManager::push_objarray(oop obj, size_t index)
85
{
86
ObjArrayTask task(obj, index);
87
assert(task.is_valid(), "bad ObjArrayTask");
88
_objarray_stack.push(task);
89
}
90
91
void ParCompactionManager::push_region(size_t index)
92
{
93
#ifdef ASSERT
94
const ParallelCompactData& sd = PSParallelCompact::summary_data();
95
ParallelCompactData::RegionData* const region_ptr = sd.region(index);
96
assert(region_ptr->claimed(), "must be claimed");
97
assert(region_ptr->_pushed++ == 0, "should only be pushed once");
98
#endif
99
region_stack()->push(index);
100
}
101
102
template <typename T>
103
inline void ParCompactionManager::mark_and_push(T* p) {
104
T heap_oop = RawAccess<>::oop_load(p);
105
if (!CompressedOops::is_null(heap_oop)) {
106
oop obj = CompressedOops::decode_not_null(heap_oop);
107
assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
108
109
if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
110
push(obj);
111
}
112
}
113
}
114
115
inline void ParCompactionManager::follow_klass(Klass* klass) {
116
oop holder = klass->class_loader_data()->holder_no_keepalive();
117
mark_and_push(&holder);
118
}
119
120
inline void ParCompactionManager::FollowStackClosure::do_void() {
121
_compaction_manager->follow_marking_stacks();
122
if (_terminator != nullptr) {
123
steal_marking_work(*_terminator, _worker_id);
124
}
125
}
126
127
template <typename T>
128
inline void follow_array_specialized(objArrayOop obj, int index, ParCompactionManager* cm) {
129
const size_t len = size_t(obj->length());
130
const size_t beg_index = size_t(index);
131
assert(beg_index < len || len == 0, "index too large");
132
133
const size_t stride = MIN2(len - beg_index, (size_t)ObjArrayMarkingStride);
134
const size_t end_index = beg_index + stride;
135
T* const base = (T*)obj->base();
136
T* const beg = base + beg_index;
137
T* const end = base + end_index;
138
139
if (end_index < len) {
140
cm->push_objarray(obj, end_index); // Push the continuation.
141
}
142
143
// Push the non-NULL elements of the next stride on the marking stack.
144
for (T* e = beg; e < end; e++) {
145
cm->mark_and_push<T>(e);
146
}
147
}
148
149
inline void ParCompactionManager::follow_array(objArrayOop obj, int index) {
150
if (UseCompressedOops) {
151
follow_array_specialized<narrowOop>(obj, index, this);
152
} else {
153
follow_array_specialized<oop>(obj, index, this);
154
}
155
}
156
157
inline void ParCompactionManager::update_contents(oop obj) {
158
if (!obj->klass()->is_typeArray_klass()) {
159
PCAdjustPointerClosure apc(this);
160
obj->oop_iterate(&apc);
161
}
162
}
163
164
inline void ParCompactionManager::follow_class_loader(ClassLoaderData* cld) {
165
PCMarkAndPushClosure mark_and_push_closure(this);
166
cld->oops_do(&mark_and_push_closure, true);
167
}
168
169
inline void ParCompactionManager::follow_contents(oop obj) {
170
assert(PSParallelCompact::mark_bitmap()->is_marked(obj), "should be marked");
171
if (obj->is_objArray()) {
172
follow_array(objArrayOop(obj), 0);
173
} else {
174
PCIterateMarkAndPushClosure cl(this, PSParallelCompact::ref_processor());
175
obj->oop_iterate(&cl);
176
}
177
}
178
179
#endif // SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_INLINE_HPP
180
181