author | stefank |
Tue, 26 Nov 2019 10:47:46 +0100 | |
changeset 59290 | 97d13893ec3c |
parent 55476 | aee0d296c0ef |
child 58679 | 9c3209ff7550 |
child 59296 | 9186be5c78ba |
permissions | -rw-r--r-- |
54882 | 1 |
/* |
2 |
* Copyright (c) 2019, Red Hat, Inc. All rights reserved. |
|
3 |
* |
|
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
6 |
* published by the Free Software Foundation. |
|
7 |
* |
|
8 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
9 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
10 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
11 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
12 |
* accompanied this code). |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License version |
|
15 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17 |
* |
|
18 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
19 |
* or visit www.oracle.com if you need additional information or have any |
|
20 |
* questions. |
|
21 |
* |
|
22 |
*/ |
|
23 |
||
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
||
27 |
||
28 |
#include "classfile/classLoaderDataGraph.hpp" |
|
29 |
#include "classfile/systemDictionary.hpp" |
|
30 |
#include "code/codeCache.hpp" |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
31 |
#include "gc/shenandoah/shenandoahAsserts.hpp" |
54882 | 32 |
#include "gc/shenandoah/shenandoahHeap.hpp" |
33 |
#include "gc/shenandoah/shenandoahPhaseTimings.hpp" |
|
34 |
#include "gc/shenandoah/shenandoahRootVerifier.hpp" |
|
35 |
#include "gc/shenandoah/shenandoahStringDedup.hpp" |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
36 |
#include "gc/shenandoah/shenandoahUtils.hpp" |
54882 | 37 |
#include "gc/shared/weakProcessor.inline.hpp" |
38 |
#include "memory/universe.hpp" |
|
39 |
#include "runtime/thread.hpp" |
|
40 |
#include "services/management.hpp" |
|
41 |
#include "utilities/debug.hpp" |
|
42 |
||
43 |
// Check for overflow of number of root types. |
|
44 |
STATIC_ASSERT((static_cast<uint>(ShenandoahRootVerifier::AllRoots) + 1) > static_cast<uint>(ShenandoahRootVerifier::AllRoots)); |
|
45 |
||
46 |
ShenandoahRootVerifier::ShenandoahRootVerifier() : _types(AllRoots) { |
|
47 |
} |
|
48 |
||
49 |
void ShenandoahRootVerifier::excludes(RootTypes types) { |
|
50 |
_types = static_cast<ShenandoahRootVerifier::RootTypes>(static_cast<uint>(_types) & (~static_cast<uint>(types))); |
|
51 |
} |
|
52 |
||
53 |
bool ShenandoahRootVerifier::verify(RootTypes type) const { |
|
54 |
return (_types & type) != 0; |
|
55 |
} |
|
56 |
||
55476
aee0d296c0ef
8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents:
55335
diff
changeset
|
57 |
ShenandoahRootVerifier::RootTypes ShenandoahRootVerifier::combine(RootTypes t1, RootTypes t2) { |
aee0d296c0ef
8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents:
55335
diff
changeset
|
58 |
return static_cast<ShenandoahRootVerifier::RootTypes>(static_cast<uint>(t1) | static_cast<uint>(t2)); |
aee0d296c0ef
8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents:
55335
diff
changeset
|
59 |
} |
aee0d296c0ef
8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots
zgu
parents:
55335
diff
changeset
|
60 |
|
54882 | 61 |
void ShenandoahRootVerifier::oops_do(OopClosure* oops) { |
62 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
|
63 |
if (verify(CodeRoots)) { |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
64 |
shenandoah_assert_locked_or_safepoint(CodeCache_lock); |
54882 | 65 |
CodeCache::blobs_do(&blobs); |
66 |
} |
|
67 |
||
68 |
if (verify(CLDGRoots)) { |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
69 |
shenandoah_assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
70 |
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none); |
54882 | 71 |
ClassLoaderDataGraph::cld_do(&clds); |
72 |
} |
|
73 |
||
74 |
if (verify(SerialRoots)) { |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
75 |
shenandoah_assert_safepoint(); |
54882 | 76 |
Universe::oops_do(oops); |
77 |
Management::oops_do(oops); |
|
78 |
JvmtiExport::oops_do(oops); |
|
79 |
ObjectSynchronizer::oops_do(oops); |
|
80 |
SystemDictionary::oops_do(oops); |
|
81 |
} |
|
82 |
||
55335
f7cc25dda38a
8225572: Shenandoah: Move JNIHandles root out of serial roots
zgu
parents:
55119
diff
changeset
|
83 |
if (verify(JNIHandleRoots)) { |
f7cc25dda38a
8225572: Shenandoah: Move JNIHandles root out of serial roots
zgu
parents:
55119
diff
changeset
|
84 |
shenandoah_assert_safepoint(); |
f7cc25dda38a
8225572: Shenandoah: Move JNIHandles root out of serial roots
zgu
parents:
55119
diff
changeset
|
85 |
JNIHandles::oops_do(oops); |
f7cc25dda38a
8225572: Shenandoah: Move JNIHandles root out of serial roots
zgu
parents:
55119
diff
changeset
|
86 |
} |
f7cc25dda38a
8225572: Shenandoah: Move JNIHandles root out of serial roots
zgu
parents:
55119
diff
changeset
|
87 |
|
54882 | 88 |
if (verify(WeakRoots)) { |
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
89 |
shenandoah_assert_safepoint(); |
54882 | 90 |
AlwaysTrueClosure always_true; |
91 |
WeakProcessor::weak_oops_do(&always_true, oops); |
|
92 |
} |
|
93 |
||
94 |
if (ShenandoahStringDedup::is_enabled() && verify(StringDedupRoots)) { |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
95 |
shenandoah_assert_safepoint(); |
54882 | 96 |
ShenandoahStringDedup::oops_do_slow(oops); |
97 |
} |
|
98 |
||
99 |
if (verify(ThreadRoots)) { |
|
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
100 |
shenandoah_assert_safepoint(); |
54882 | 101 |
// Do thread roots the last. This allows verification code to find |
102 |
// any broken objects from those special roots first, not the accidental |
|
103 |
// dangling reference from the thread root. |
|
104 |
Threads::possibly_parallel_oops_do(false, oops, &blobs); |
|
105 |
} |
|
106 |
} |
|
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
107 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
108 |
void ShenandoahRootVerifier::roots_do(OopClosure* oops) { |
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
109 |
shenandoah_assert_safepoint(); |
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
110 |
|
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
111 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
112 |
CodeCache::blobs_do(&blobs); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
113 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
114 |
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
115 |
ClassLoaderDataGraph::cld_do(&clds); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
116 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
117 |
Universe::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
118 |
Management::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
119 |
JvmtiExport::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
120 |
JNIHandles::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
121 |
ObjectSynchronizer::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
122 |
SystemDictionary::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
123 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
124 |
AlwaysTrueClosure always_true; |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
125 |
WeakProcessor::weak_oops_do(&always_true, oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
126 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
127 |
if (ShenandoahStringDedup::is_enabled()) { |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
128 |
ShenandoahStringDedup::oops_do_slow(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
129 |
} |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
130 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
131 |
// Do thread roots the last. This allows verification code to find |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
132 |
// any broken objects from those special roots first, not the accidental |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
133 |
// dangling reference from the thread root. |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
134 |
Threads::possibly_parallel_oops_do(false, oops, &blobs); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
135 |
} |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
136 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
137 |
void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) { |
55119
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
138 |
shenandoah_assert_safepoint(); |
04ff1e00635a
8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
zgu
parents:
55048
diff
changeset
|
139 |
|
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
140 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
141 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
142 |
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
143 |
ClassLoaderDataGraph::roots_cld_do(&clds, NULL); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
144 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
145 |
Universe::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
146 |
Management::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
147 |
JvmtiExport::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
148 |
JNIHandles::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
149 |
ObjectSynchronizer::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
150 |
SystemDictionary::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
151 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
152 |
// Do thread roots the last. This allows verification code to find |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
153 |
// any broken objects from those special roots first, not the accidental |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
154 |
// dangling reference from the thread root. |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
155 |
Threads::possibly_parallel_oops_do(false, oops, &blobs); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
156 |
} |