author | zgu |
Mon, 27 May 2019 14:34:58 -0400 | |
changeset 55048 | 812212323fb1 |
parent 54882 | b99e97bc5040 |
child 55119 | 04ff1e00635a |
child 58678 | 9cf78a70fa4f |
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" |
|
31 |
#include "gc/shenandoah/shenandoahHeap.hpp" |
|
32 |
#include "gc/shenandoah/shenandoahPhaseTimings.hpp" |
|
33 |
#include "gc/shenandoah/shenandoahRootVerifier.hpp" |
|
34 |
#include "gc/shenandoah/shenandoahStringDedup.hpp" |
|
35 |
#include "gc/shared/weakProcessor.inline.hpp" |
|
36 |
#include "memory/universe.hpp" |
|
37 |
#include "runtime/thread.hpp" |
|
38 |
#include "services/management.hpp" |
|
39 |
#include "utilities/debug.hpp" |
|
40 |
||
41 |
// Check for overflow of number of root types. |
|
42 |
STATIC_ASSERT((static_cast<uint>(ShenandoahRootVerifier::AllRoots) + 1) > static_cast<uint>(ShenandoahRootVerifier::AllRoots)); |
|
43 |
||
44 |
ShenandoahRootVerifier::ShenandoahRootVerifier() : _types(AllRoots) { |
|
45 |
} |
|
46 |
||
47 |
void ShenandoahRootVerifier::excludes(RootTypes types) { |
|
48 |
_types = static_cast<ShenandoahRootVerifier::RootTypes>(static_cast<uint>(_types) & (~static_cast<uint>(types))); |
|
49 |
} |
|
50 |
||
51 |
bool ShenandoahRootVerifier::verify(RootTypes type) const { |
|
52 |
return (_types & type) != 0; |
|
53 |
} |
|
54 |
||
55 |
void ShenandoahRootVerifier::oops_do(OopClosure* oops) { |
|
56 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
|
57 |
if (verify(CodeRoots)) { |
|
58 |
CodeCache::blobs_do(&blobs); |
|
59 |
} |
|
60 |
||
61 |
if (verify(CLDGRoots)) { |
|
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
62 |
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none); |
54882 | 63 |
ClassLoaderDataGraph::cld_do(&clds); |
64 |
} |
|
65 |
||
66 |
if (verify(SerialRoots)) { |
|
67 |
Universe::oops_do(oops); |
|
68 |
Management::oops_do(oops); |
|
69 |
JvmtiExport::oops_do(oops); |
|
70 |
JNIHandles::oops_do(oops); |
|
71 |
ObjectSynchronizer::oops_do(oops); |
|
72 |
SystemDictionary::oops_do(oops); |
|
73 |
} |
|
74 |
||
75 |
if (verify(WeakRoots)) { |
|
76 |
AlwaysTrueClosure always_true; |
|
77 |
WeakProcessor::weak_oops_do(&always_true, oops); |
|
78 |
} |
|
79 |
||
80 |
if (ShenandoahStringDedup::is_enabled() && verify(StringDedupRoots)) { |
|
81 |
ShenandoahStringDedup::oops_do_slow(oops); |
|
82 |
} |
|
83 |
||
84 |
if (verify(ThreadRoots)) { |
|
85 |
// Do thread roots the last. This allows verification code to find |
|
86 |
// any broken objects from those special roots first, not the accidental |
|
87 |
// dangling reference from the thread root. |
|
88 |
Threads::possibly_parallel_oops_do(false, oops, &blobs); |
|
89 |
} |
|
90 |
} |
|
55048
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
91 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
92 |
void ShenandoahRootVerifier::roots_do(OopClosure* oops) { |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
93 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
94 |
CodeCache::blobs_do(&blobs); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
95 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
96 |
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
|
97 |
ClassLoaderDataGraph::cld_do(&clds); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
98 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
99 |
Universe::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
100 |
Management::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
101 |
JvmtiExport::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
102 |
JNIHandles::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
103 |
ObjectSynchronizer::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
104 |
SystemDictionary::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
105 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
106 |
AlwaysTrueClosure always_true; |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
107 |
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
|
108 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
109 |
if (ShenandoahStringDedup::is_enabled()) { |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
110 |
ShenandoahStringDedup::oops_do_slow(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
111 |
} |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
112 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
113 |
// 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
|
114 |
// 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
|
115 |
// 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
|
116 |
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
|
117 |
} |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
118 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
119 |
void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) { |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
120 |
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
121 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
125 |
Universe::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
126 |
Management::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
127 |
JvmtiExport::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
128 |
JNIHandles::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
129 |
ObjectSynchronizer::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
130 |
SystemDictionary::oops_do(oops); |
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
131 |
|
812212323fb1
8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle
zgu
parents:
54882
diff
changeset
|
132 |
// 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
|
133 |
// 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
|
134 |
// 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
|
135 |
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
|
136 |
} |