< prev index next >

src/hotspot/share/gc/z/zVerify.cpp

Print this page
rev 58099 : 8239492: [x86] Turn MacroAssembler::verify_oop into macro recording file and line


  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 #include "precompiled.hpp"
  25 #include "classfile/classLoaderData.hpp"
  26 #include "gc/z/zAddress.hpp"
  27 #include "gc/z/zHeap.inline.hpp"
  28 #include "gc/z/zOop.hpp"
  29 #include "gc/z/zPageAllocator.hpp"
  30 #include "gc/z/zResurrection.hpp"
  31 #include "gc/z/zRootsIterator.hpp"
  32 #include "gc/z/zStat.hpp"
  33 #include "gc/z/zVerify.hpp"
  34 #include "memory/iterator.inline.hpp"
  35 #include "oops/oop.hpp"
  36 
  37 #define BAD_OOP_ARG(o, p)   "Bad oop " PTR_FORMAT " found at " PTR_FORMAT, p2i(o), p2i(p)
  38 
  39 static void verify_oop(oop* p) {
  40   const oop o = RawAccess<>::oop_load(p);
  41   if (o != NULL) {
  42     const uintptr_t addr = ZOop::to_address(o);
  43     guarantee(ZAddress::is_good(addr), BAD_OOP_ARG(o, p));
  44     guarantee(oopDesc::is_oop(ZOop::from_address(addr)), BAD_OOP_ARG(o, p));
  45   }
  46 }
  47 
  48 static void verify_possibly_weak_oop(oop* p) {
  49   const oop o = RawAccess<>::oop_load(p);
  50   if (o != NULL) {
  51     const uintptr_t addr = ZOop::to_address(o);
  52     guarantee(ZAddress::is_good(addr) || ZAddress::is_finalizable_good(addr), BAD_OOP_ARG(o, p));
  53     guarantee(oopDesc::is_oop(ZOop::from_address(ZAddress::good(addr))), BAD_OOP_ARG(o, p));
  54   }
  55 }
  56 
  57 class ZVerifyRootClosure : public ZRootsIteratorClosure {
  58 public:
  59   virtual void do_oop(oop* p) {
  60     verify_oop(p);
  61   }
  62 
  63   virtual void do_oop(narrowOop*) {
  64     ShouldNotReachHere();
  65   }
  66 };
  67 
  68 class ZVerifyOopClosure : public ClaimMetadataVisitingOopIterateClosure, public ZRootsIteratorClosure  {
  69 private:
  70   const bool _verify_weaks;
  71 
  72 public:
  73   ZVerifyOopClosure(bool verify_weaks) :
  74       ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other),
  75       _verify_weaks(verify_weaks) {}
  76 
  77   virtual void do_oop(oop* p) {
  78     if (_verify_weaks) {
  79       verify_possibly_weak_oop(p);
  80     } else {
  81       // We should never encounter finalizable oops through strong
  82       // paths. This assumes we have only visited strong roots.
  83       verify_oop(p);
  84     }
  85   }
  86 
  87   virtual void do_oop(narrowOop* p) {
  88     ShouldNotReachHere();
  89   }
  90 
  91   virtual ReferenceIterationMode reference_iteration_mode() {
  92     return _verify_weaks ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT;
  93   }
  94 
  95 #ifdef ASSERT
  96   // Verification handled by the closure itself
  97   virtual bool should_verify_oops() {
  98     return false;
  99   }
 100 #endif
 101 };
 102 
 103 template <typename RootsIterator>




  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 #include "precompiled.hpp"
  25 #include "classfile/classLoaderData.hpp"
  26 #include "gc/z/zAddress.hpp"
  27 #include "gc/z/zHeap.inline.hpp"
  28 #include "gc/z/zOop.hpp"
  29 #include "gc/z/zPageAllocator.hpp"
  30 #include "gc/z/zResurrection.hpp"
  31 #include "gc/z/zRootsIterator.hpp"
  32 #include "gc/z/zStat.hpp"
  33 #include "gc/z/zVerify.hpp"
  34 #include "memory/iterator.inline.hpp"
  35 #include "oops/oop.hpp"
  36 
  37 #define BAD_OOP_ARG(o, p)   "Bad oop " PTR_FORMAT " found at " PTR_FORMAT, p2i(o), p2i(p)
  38 
  39 static void z_verify_oop(oop* p) {
  40   const oop o = RawAccess<>::oop_load(p);
  41   if (o != NULL) {
  42     const uintptr_t addr = ZOop::to_address(o);
  43     guarantee(ZAddress::is_good(addr), BAD_OOP_ARG(o, p));
  44     guarantee(oopDesc::is_oop(ZOop::from_address(addr)), BAD_OOP_ARG(o, p));
  45   }
  46 }
  47 
  48 static void z_verify_possibly_weak_oop(oop* p) {
  49   const oop o = RawAccess<>::oop_load(p);
  50   if (o != NULL) {
  51     const uintptr_t addr = ZOop::to_address(o);
  52     guarantee(ZAddress::is_good(addr) || ZAddress::is_finalizable_good(addr), BAD_OOP_ARG(o, p));
  53     guarantee(oopDesc::is_oop(ZOop::from_address(ZAddress::good(addr))), BAD_OOP_ARG(o, p));
  54   }
  55 }
  56 
  57 class ZVerifyRootClosure : public ZRootsIteratorClosure {
  58 public:
  59   virtual void do_oop(oop* p) {
  60     z_verify_oop(p);
  61   }
  62 
  63   virtual void do_oop(narrowOop*) {
  64     ShouldNotReachHere();
  65   }
  66 };
  67 
  68 class ZVerifyOopClosure : public ClaimMetadataVisitingOopIterateClosure, public ZRootsIteratorClosure  {
  69 private:
  70   const bool _verify_weaks;
  71 
  72 public:
  73   ZVerifyOopClosure(bool verify_weaks) :
  74       ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other),
  75       _verify_weaks(verify_weaks) {}
  76 
  77   virtual void do_oop(oop* p) {
  78     if (_verify_weaks) {
  79       z_verify_possibly_weak_oop(p);
  80     } else {
  81       // We should never encounter finalizable oops through strong
  82       // paths. This assumes we have only visited strong roots.
  83       z_verify_oop(p);
  84     }
  85   }
  86 
  87   virtual void do_oop(narrowOop* p) {
  88     ShouldNotReachHere();
  89   }
  90 
  91   virtual ReferenceIterationMode reference_iteration_mode() {
  92     return _verify_weaks ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT;
  93   }
  94 
  95 #ifdef ASSERT
  96   // Verification handled by the closure itself
  97   virtual bool should_verify_oops() {
  98     return false;
  99   }
 100 #endif
 101 };
 102 
 103 template <typename RootsIterator>


< prev index next >