Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/leakprofiler/chains/rootSetClosure.cpp
41153 views
1
/*
2
* Copyright (c) 2014, 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
#include "precompiled.hpp"
26
#include "classfile/classLoaderDataGraph.hpp"
27
#include "classfile/stringTable.hpp"
28
#include "gc/shared/oopStorage.inline.hpp"
29
#include "gc/shared/oopStorageSet.inline.hpp"
30
#include "gc/shared/strongRootsScope.hpp"
31
#include "jfr/leakprofiler/chains/bfsClosure.hpp"
32
#include "jfr/leakprofiler/chains/dfsClosure.hpp"
33
#include "jfr/leakprofiler/chains/edgeQueue.hpp"
34
#include "jfr/leakprofiler/chains/rootSetClosure.hpp"
35
#include "jfr/leakprofiler/utilities/unifiedOopRef.inline.hpp"
36
#include "oops/access.inline.hpp"
37
#include "oops/oop.inline.hpp"
38
#include "runtime/synchronizer.hpp"
39
#include "runtime/thread.hpp"
40
#include "services/management.hpp"
41
#include "utilities/align.hpp"
42
43
template <typename Delegate>
44
RootSetClosure<Delegate>::RootSetClosure(Delegate* delegate) : _delegate(delegate) {}
45
46
template <typename Delegate>
47
void RootSetClosure<Delegate>::do_oop(oop* ref) {
48
assert(ref != NULL, "invariant");
49
assert(is_aligned(ref, HeapWordSize), "invariant");
50
if (*ref != NULL) {
51
_delegate->do_root(UnifiedOopRef::encode_in_native(ref));
52
}
53
}
54
55
template <typename Delegate>
56
void RootSetClosure<Delegate>::do_oop(narrowOop* ref) {
57
assert(ref != NULL, "invariant");
58
assert(is_aligned(ref, sizeof(narrowOop)), "invariant");
59
if (!CompressedOops::is_null(*ref)) {
60
_delegate->do_root(UnifiedOopRef::encode_in_native(ref));
61
}
62
}
63
64
class RootSetClosureMarkScope : public MarkScope {};
65
66
template <typename Delegate>
67
void RootSetClosure<Delegate>::process() {
68
RootSetClosureMarkScope mark_scope;
69
CLDToOopClosure cldt_closure(this, ClassLoaderData::_claim_none);
70
ClassLoaderDataGraph::always_strong_cld_do(&cldt_closure);
71
// We don't follow code blob oops, because they have misaligned oops.
72
Threads::oops_do(this, NULL);
73
OopStorageSet::strong_oops_do(this);
74
}
75
76
template class RootSetClosure<BFSClosure>;
77
template class RootSetClosure<DFSClosure>;
78
79