< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp

Print this page

  1 /*
  2  * Copyright (c) 2019, 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 
 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/javaThread.hpp"
 40 #include "runtime/jniHandles.hpp"
 41 #include "runtime/threads.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(OopClosure* 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   // Do thread roots the last. This allows verification code to find
 71   // any broken objects from those special roots first, not the accidental
 72   // dangling reference from the thread root.
 73   Threads::possibly_parallel_oops_do(true, oops, nullptr);
 74 }
 75 
 76 void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
 77   ShenandoahGCStateResetter resetter;
 78   shenandoah_assert_safepoint();
 79 
 80   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 81   ClassLoaderDataGraph::always_strong_cld_do(&clds);
 82 
 83   for (auto id : EnumRange<OopStorageSet::StrongId>()) {
 84     OopStorageSet::storage(id)->oops_do(oops);
 85   }






 86   // Do thread roots the last. This allows verification code to find
 87   // any broken objects from those special roots first, not the accidental
 88   // dangling reference from the thread root.
 89   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 90   Threads::possibly_parallel_oops_do(true, oops, &blobs);
 91 }

  1 /*
  2  * Copyright (c) 2019, 2021, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 
 27 #include "precompiled.hpp"
 28 
 29 
 30 #include "classfile/classLoaderDataGraph.hpp"
 31 #include "code/codeCache.hpp"
 32 #include "gc/shenandoah/shenandoahAsserts.hpp"
 33 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 34 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
 35 #include "gc/shenandoah/shenandoahRootVerifier.hpp"
 36 #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp"
 37 #include "gc/shenandoah/shenandoahStringDedup.hpp"
 38 #include "gc/shenandoah/shenandoahUtils.hpp"
 39 #include "gc/shared/oopStorage.inline.hpp"
 40 #include "gc/shared/oopStorageSet.hpp"
 41 #include "runtime/javaThread.hpp"
 42 #include "runtime/jniHandles.hpp"
 43 #include "runtime/threads.hpp"
 44 #include "utilities/debug.hpp"
 45 #include "utilities/enumIterator.hpp"
 46 
 47 ShenandoahGCStateResetter::ShenandoahGCStateResetter() :
 48   _heap(ShenandoahHeap::heap()),
 49   _gc_state(_heap->gc_state()) {
 50   _heap->_gc_state.clear();
 51 }
 52 
 53 ShenandoahGCStateResetter::~ShenandoahGCStateResetter() {
 54   _heap->_gc_state.set(_gc_state);
 55   assert(_heap->gc_state() == _gc_state, "Should be restored");
 56 }
 57 
 58 void ShenandoahRootVerifier::roots_do(OopIterateClosure* oops) {
 59   ShenandoahGCStateResetter resetter;
 60   shenandoah_assert_safepoint();
 61 
 62   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 63   CodeCache::blobs_do(&blobs);
 64 
 65   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 66   ClassLoaderDataGraph::cld_do(&clds);
 67 
 68   for (auto id : EnumRange<OopStorageSet::StrongId>()) {
 69     OopStorageSet::storage(id)->oops_do(oops);
 70   }
 71 
 72   ShenandoahHeap* heap = ShenandoahHeap::heap();
 73   if (heap->mode()->is_generational() && heap->is_gc_generation_young()) {
 74     shenandoah_assert_safepoint();
 75     heap->card_scan()->roots_do(oops);
 76   }
 77 
 78   // Do thread roots the last. This allows verification code to find
 79   // any broken objects from those special roots first, not the accidental
 80   // dangling reference from the thread root.
 81   Threads::possibly_parallel_oops_do(true, oops, nullptr);
 82 }
 83 
 84 void ShenandoahRootVerifier::strong_roots_do(OopIterateClosure* oops) {
 85   ShenandoahGCStateResetter resetter;
 86   shenandoah_assert_safepoint();
 87 
 88   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 89   ClassLoaderDataGraph::always_strong_cld_do(&clds);
 90 
 91   for (auto id : EnumRange<OopStorageSet::StrongId>()) {
 92     OopStorageSet::storage(id)->oops_do(oops);
 93   }
 94 
 95   ShenandoahHeap* heap = ShenandoahHeap::heap();
 96   if (heap->mode()->is_generational() && heap->is_gc_generation_young()) {
 97     heap->card_scan()->roots_do(oops);
 98   }
 99 
100   // Do thread roots the last. This allows verification code to find
101   // any broken objects from those special roots first, not the accidental
102   // dangling reference from the thread root.
103   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
104   Threads::possibly_parallel_oops_do(true, oops, &blobs);
105 }
< prev index next >