< prev index next >

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

Print this page




  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/shenandoahAsserts.hpp"
  32 #include "gc/shenandoah/shenandoahHeap.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/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 
  57 void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
  58   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
  59   if (verify(CodeRoots)) {
  60     shenandoah_assert_locked_or_safepoint(CodeCache_lock);
  61     CodeCache::blobs_do(&blobs);
  62   }
  63 
  64   if (verify(CLDGRoots)) {
  65     shenandoah_assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
  66     CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
  67     ClassLoaderDataGraph::cld_do(&clds);
  68   }
  69 
  70   if (verify(SerialRoots)) {
  71     shenandoah_assert_safepoint();
  72     Universe::oops_do(oops);
  73     Management::oops_do(oops);
  74     JvmtiExport::oops_do(oops);

  75     ObjectSynchronizer::oops_do(oops);
  76     SystemDictionary::oops_do(oops);
  77   }
  78 
  79   if (verify(JNIHandleRoots)) {
  80     shenandoah_assert_safepoint();
  81     JNIHandles::oops_do(oops);
  82   }
  83 
  84   if (verify(WeakRoots)) {
  85     shenandoah_assert_safepoint();
  86     AlwaysTrueClosure always_true;
  87     WeakProcessor::weak_oops_do(&always_true, oops);
  88   }
  89 
  90   if (ShenandoahStringDedup::is_enabled() && verify(StringDedupRoots)) {
  91     shenandoah_assert_safepoint();
  92     ShenandoahStringDedup::oops_do_slow(oops);
  93   }
  94 
  95   if (verify(ThreadRoots)) {
  96     shenandoah_assert_safepoint();
  97     // Do thread roots the last. This allows verification code to find
  98     // any broken objects from those special roots first, not the accidental
  99     // dangling reference from the thread root.
 100     Threads::possibly_parallel_oops_do(false, oops, &blobs);
 101   }
 102 }
 103 
 104 void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
 105   shenandoah_assert_safepoint();
 106 
 107   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 108   CodeCache::blobs_do(&blobs);
 109 
 110   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 111   ClassLoaderDataGraph::cld_do(&clds);
 112 
 113   Universe::oops_do(oops);
 114   Management::oops_do(oops);
 115   JvmtiExport::oops_do(oops);
 116   JNIHandles::oops_do(oops);
 117   ObjectSynchronizer::oops_do(oops);
 118   SystemDictionary::oops_do(oops);
 119 
 120   AlwaysTrueClosure always_true;
 121   WeakProcessor::weak_oops_do(&always_true, oops);
 122 
 123   if (ShenandoahStringDedup::is_enabled()) {
 124     ShenandoahStringDedup::oops_do_slow(oops);
 125   }
 126 
 127   // Do thread roots the last. This allows verification code to find
 128   // any broken objects from those special roots first, not the accidental
 129   // dangling reference from the thread root.
 130   Threads::possibly_parallel_oops_do(false, oops, &blobs);
 131 }
 132 
 133 void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
 134   shenandoah_assert_safepoint();
 135 
 136   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 137 
 138   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 139   ClassLoaderDataGraph::roots_cld_do(&clds, NULL);
 140 
 141   Universe::oops_do(oops);
 142   Management::oops_do(oops);
 143   JvmtiExport::oops_do(oops);
 144   JNIHandles::oops_do(oops);
 145   ObjectSynchronizer::oops_do(oops);
 146   SystemDictionary::oops_do(oops);
 147 
 148   // Do thread roots the last. This allows verification code to find
 149   // any broken objects from those special roots first, not the accidental
 150   // dangling reference from the thread root.
 151   Threads::possibly_parallel_oops_do(false, oops, &blobs);
 152 }


  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)) {

  62     CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
  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 }
  91 
  92 void ShenandoahRootVerifier::roots_do(OopClosure* oops) {


  93   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
  94   CodeCache::blobs_do(&blobs);
  95 
  96   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
  97   ClassLoaderDataGraph::cld_do(&clds);
  98 
  99   Universe::oops_do(oops);
 100   Management::oops_do(oops);
 101   JvmtiExport::oops_do(oops);
 102   JNIHandles::oops_do(oops);
 103   ObjectSynchronizer::oops_do(oops);
 104   SystemDictionary::oops_do(oops);
 105 
 106   AlwaysTrueClosure always_true;
 107   WeakProcessor::weak_oops_do(&always_true, oops);
 108 
 109   if (ShenandoahStringDedup::is_enabled()) {
 110     ShenandoahStringDedup::oops_do_slow(oops);
 111   }
 112 
 113   // Do thread roots the last. This allows verification code to find
 114   // any broken objects from those special roots first, not the accidental
 115   // dangling reference from the thread root.
 116   Threads::possibly_parallel_oops_do(false, oops, &blobs);
 117 }
 118 
 119 void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {


 120   CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
 121 
 122   CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
 123   ClassLoaderDataGraph::roots_cld_do(&clds, NULL);
 124 
 125   Universe::oops_do(oops);
 126   Management::oops_do(oops);
 127   JvmtiExport::oops_do(oops);
 128   JNIHandles::oops_do(oops);
 129   ObjectSynchronizer::oops_do(oops);
 130   SystemDictionary::oops_do(oops);
 131 
 132   // Do thread roots the last. This allows verification code to find
 133   // any broken objects from those special roots first, not the accidental
 134   // dangling reference from the thread root.
 135   Threads::possibly_parallel_oops_do(false, oops, &blobs);
 136 }
< prev index next >