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
26 #include "precompiled.hpp"
27
28
29 #include "classfile/classLoaderDataGraph.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/shenandoah/shenandoahAsserts.hpp"
32 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
33 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
34 #include "gc/shenandoah/shenandoahRootVerifier.hpp"
35 #include "gc/shenandoah/shenandoahStringDedup.hpp"
36 #include "gc/shenandoah/shenandoahUtils.hpp"
37 #include "gc/shared/oopStorage.inline.hpp"
38 #include "gc/shared/oopStorageSet.hpp"
39 #include "runtime/jniHandles.hpp"
40 #include "runtime/thread.hpp"
41 #include "utilities/debug.hpp"
42 #include "utilities/enumIterator.hpp"
43
44 ShenandoahGCStateResetter::ShenandoahGCStateResetter() :
45 _heap(ShenandoahHeap::heap()),
46 _gc_state(_heap->gc_state()) {
47 _heap->_gc_state.clear();
48 }
49
50 ShenandoahGCStateResetter::~ShenandoahGCStateResetter() {
51 _heap->_gc_state.set(_gc_state);
52 assert(_heap->gc_state() == _gc_state, "Should be restored");
53 }
54
55 void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
56 ShenandoahGCStateResetter resetter;
57 shenandoah_assert_safepoint();
58
59 CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
60 CodeCache::blobs_do(&blobs);
61
62 CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
63 ClassLoaderDataGraph::cld_do(&clds);
64
65 for (auto id : EnumRange<OopStorageSet::StrongId>()) {
66 OopStorageSet::storage(id)->oops_do(oops);
67 }
68
69 // Do thread roots the last. This allows verification code to find
70 // any broken objects from those special roots first, not the accidental
71 // dangling reference from the thread root.
72 Threads::possibly_parallel_oops_do(true, oops, NULL);
73 }
74
75 void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
76 ShenandoahGCStateResetter resetter;
77 shenandoah_assert_safepoint();
78
79 CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
80 ClassLoaderDataGraph::always_strong_cld_do(&clds);
81
82 for (auto id : EnumRange<OopStorageSet::StrongId>()) {
83 OopStorageSet::storage(id)->oops_do(oops);
84 }
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 CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
89 Threads::possibly_parallel_oops_do(true, oops, &blobs);
90 }
|
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
26 #include "precompiled.hpp"
27
28
29 #include "classfile/classLoaderDataGraph.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/shenandoah/shenandoahAsserts.hpp"
32 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
33 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
34 #include "gc/shenandoah/shenandoahRootVerifier.hpp"
35 #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp"
36 #include "gc/shenandoah/shenandoahStringDedup.hpp"
37 #include "gc/shenandoah/shenandoahUtils.hpp"
38 #include "gc/shared/oopStorage.inline.hpp"
39 #include "gc/shared/oopStorageSet.hpp"
40 #include "runtime/jniHandles.hpp"
41 #include "runtime/thread.hpp"
42 #include "utilities/debug.hpp"
43 #include "utilities/enumIterator.hpp"
44
45 ShenandoahGCStateResetter::ShenandoahGCStateResetter() :
46 _heap(ShenandoahHeap::heap()),
47 _gc_state(_heap->gc_state()) {
48 _heap->_gc_state.clear();
49 }
50
51 ShenandoahGCStateResetter::~ShenandoahGCStateResetter() {
52 _heap->_gc_state.set(_gc_state);
53 assert(_heap->gc_state() == _gc_state, "Should be restored");
54 }
55
56 void ShenandoahRootVerifier::roots_do(OopIterateClosure* oops) {
57 ShenandoahGCStateResetter resetter;
58 shenandoah_assert_safepoint();
59
60 CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
61 CodeCache::blobs_do(&blobs);
62
63 CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
64 ClassLoaderDataGraph::cld_do(&clds);
65
66 for (auto id : EnumRange<OopStorageSet::StrongId>()) {
67 OopStorageSet::storage(id)->oops_do(oops);
68 }
69
70 ShenandoahHeap* heap = ShenandoahHeap::heap();
71 if (heap->mode()->is_generational() && heap->is_gc_generation_young()) {
72 shenandoah_assert_safepoint();
73 heap->card_scan()->roots_do(oops);
74 }
75
76 // Do thread roots the last. This allows verification code to find
77 // any broken objects from those special roots first, not the accidental
78 // dangling reference from the thread root.
79 Threads::possibly_parallel_oops_do(true, oops, NULL);
80 }
81
82 void ShenandoahRootVerifier::strong_roots_do(OopIterateClosure* oops) {
83 ShenandoahGCStateResetter resetter;
84 shenandoah_assert_safepoint();
85
86 CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
87 ClassLoaderDataGraph::always_strong_cld_do(&clds);
88
89 for (auto id : EnumRange<OopStorageSet::StrongId>()) {
90 OopStorageSet::storage(id)->oops_do(oops);
91 }
92
93 ShenandoahHeap* heap = ShenandoahHeap::heap();
94 if (heap->mode()->is_generational() && heap->is_gc_generation_young()) {
95 heap->card_scan()->roots_do(oops);
96 }
97
98 // Do thread roots the last. This allows verification code to find
99 // any broken objects from those special roots first, not the accidental
100 // dangling reference from the thread root.
101 CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
102 Threads::possibly_parallel_oops_do(true, oops, &blobs);
103 }
|