Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahBarrierSetClone.inline.hpp
40961 views
1
/*
2
* Copyright (c) 2013, 2021, Red Hat, Inc. 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_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
26
#define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
27
28
// No shenandoahBarrierSetClone.hpp
29
30
#include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
31
#include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
32
#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
33
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
34
#include "memory/iterator.inline.hpp"
35
#include "oops/access.hpp"
36
#include "oops/compressedOops.hpp"
37
38
template <bool HAS_FWD, bool EVAC, bool ENQUEUE>
39
class ShenandoahUpdateRefsForOopClosure: public BasicOopIterateClosure {
40
private:
41
ShenandoahHeap* const _heap;
42
ShenandoahBarrierSet* const _bs;
43
const ShenandoahCollectionSet* const _cset;
44
Thread* const _thread;
45
46
template <class T>
47
inline void do_oop_work(T* p) {
48
T o = RawAccess<>::oop_load(p);
49
if (!CompressedOops::is_null(o)) {
50
oop obj = CompressedOops::decode_not_null(o);
51
if (HAS_FWD && _cset->is_in(obj)) {
52
oop fwd = _bs->resolve_forwarded_not_null(obj);
53
if (EVAC && obj == fwd) {
54
fwd = _heap->evacuate_object(obj, _thread);
55
}
56
assert(obj != fwd || _heap->cancelled_gc(), "must be forwarded");
57
ShenandoahHeap::cas_oop(fwd, p, o);
58
obj = fwd;
59
}
60
if (ENQUEUE) {
61
_bs->enqueue(obj);
62
}
63
}
64
}
65
public:
66
ShenandoahUpdateRefsForOopClosure() :
67
_heap(ShenandoahHeap::heap()),
68
_bs(ShenandoahBarrierSet::barrier_set()),
69
_cset(_heap->collection_set()),
70
_thread(Thread::current()) {
71
}
72
73
virtual void do_oop(oop* p) { do_oop_work(p); }
74
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
75
};
76
77
void ShenandoahBarrierSet::clone_marking(oop obj) {
78
assert(_heap->is_concurrent_mark_in_progress(), "only during marking");
79
assert(ShenandoahIUBarrier, "only with incremental-update");
80
if (!_heap->marking_context()->allocated_after_mark_start(obj)) {
81
ShenandoahUpdateRefsForOopClosure</* has_fwd = */ false, /* evac = */ false, /* enqueue */ true> cl;
82
obj->oop_iterate(&cl);
83
}
84
}
85
86
void ShenandoahBarrierSet::clone_evacuation(oop obj) {
87
assert(_heap->is_evacuation_in_progress(), "only during evacuation");
88
if (need_bulk_update(cast_from_oop<HeapWord*>(obj))) {
89
ShenandoahEvacOOMScope oom_evac_scope;
90
ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ true, /* enqueue */ false> cl;
91
obj->oop_iterate(&cl);
92
}
93
}
94
95
void ShenandoahBarrierSet::clone_update(oop obj) {
96
assert(_heap->is_update_refs_in_progress(), "only during update-refs");
97
if (need_bulk_update(cast_from_oop<HeapWord*>(obj))) {
98
ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ false, /* enqueue */ false> cl;
99
obj->oop_iterate(&cl);
100
}
101
}
102
103
void ShenandoahBarrierSet::clone_barrier(oop obj) {
104
assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");
105
shenandoah_assert_correct(NULL, obj);
106
107
int gc_state = _heap->gc_state();
108
if ((gc_state & ShenandoahHeap::MARKING) != 0) {
109
clone_marking(obj);
110
} else if ((gc_state & ShenandoahHeap::EVACUATION) != 0) {
111
clone_evacuation(obj);
112
} else {
113
clone_update(obj);
114
}
115
}
116
117
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
118
119