< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahAsserts.hpp

Print this page




   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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
  26 
  27 #include "memory/iterator.hpp"
  28 #include "runtime/mutex.hpp"
  29 #include "utilities/formatBuffer.hpp"
  30 
  31 typedef FormatBuffer<8192> ShenandoahMessageBuffer;
  32 
  33 class ShenandoahAsserts {
  34 public:
  35   enum SafeLevel {
  36     _safe_unknown,
  37     _safe_oop,
  38     _safe_oop_fwd,
  39     _safe_all
  40   };
  41 
  42   static void print_obj(ShenandoahMessageBuffer &msg, oop obj);
  43 
  44   static void print_non_obj(ShenandoahMessageBuffer &msg, void *loc);
  45 
  46   static void print_obj_safe(ShenandoahMessageBuffer &msg, void *loc);
  47 
  48   static void print_failure(SafeLevel level, oop obj, void *interior_loc, oop loc,
  49                             const char *phase, const char *label,
  50                             const char *file, int line);
  51 
  52   static void print_rp_failure(const char *label, BoolObjectClosure* actual,
  53                                const char *file, int line);
  54 
  55   static void assert_in_heap(void* interior_loc, oop obj, const char* file, int line);
  56   static void assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line);
  57 
  58   static void assert_correct(void* interior_loc, oop obj, const char* file, int line);
  59   static void assert_forwarded(void* interior_loc, oop obj, const char* file, int line);
  60   static void assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line);
  61   static void assert_marked(void* interior_loc, oop obj, const char* file, int line);
  62   static void assert_in_cset(void* interior_loc, oop obj, const char* file, int line);
  63   static void assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line);
  64   static void assert_not_in_cset_loc(void* interior_loc, const char* file, int line);
  65 
  66   static void assert_rp_isalive_not_installed(const char *file, int line);
  67   static void assert_rp_isalive_installed(const char *file, int line);
  68 
  69   static void assert_locked_or_shenandoah_safepoint(const Monitor* lock, const char*file, int line);
  70 
  71 #ifdef ASSERT
  72 #define shenandoah_assert_in_heap(interior_loc, obj) \
  73                     ShenandoahAsserts::assert_in_heap(interior_loc, obj, __FILE__, __LINE__);
  74 #define shenandoah_assert_in_correct_region(interior_loc, obj) \
  75                     ShenandoahAsserts::assert_in_correct_region(interior_loc, obj, __FILE__, __LINE__);
  76 
  77 #define shenandoah_assert_correct_if(interior_loc, obj, condition) \
  78   if (condition)    ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  79 #define shenandoah_assert_correct_except(interior_loc, obj, exception) \
  80   if (!(exception)) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  81 #define shenandoah_assert_correct(interior_loc, obj) \
  82                     ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  83 
  84 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition) \
  85   if (condition)    ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  86 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception) \
  87   if (!(exception)) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  88 #define shenandoah_assert_forwarded(interior_loc, obj) \
  89                     ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  90 


 110                     ShenandoahAsserts::assert_in_cset(interior_loc, obj, __FILE__, __LINE__);
 111 
 112 #define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition) \
 113   if (condition)    ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 114 #define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception) \
 115   if (!(exception)) ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 116 #define shenandoah_assert_not_in_cset(interior_loc, obj) \
 117                     ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 118 
 119 #define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition) \
 120   if (condition)    ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 121 #define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception) \
 122   if (!(exception)) ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 123 #define shenandoah_assert_not_in_cset_loc(interior_loc) \
 124                     ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 125 
 126 #define shenandoah_assert_rp_isalive_installed() \
 127                     ShenandoahAsserts::assert_rp_isalive_installed(__FILE__, __LINE__);
 128 #define shenandoah_assert_rp_isalive_not_installed() \
 129                     ShenandoahAsserts::assert_rp_isalive_not_installed(__FILE__, __LINE__);
 130 
 131 #define shenandoah_assert_safepoint() \
 132                     assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Should be at Shenandoah Safepoints");
 133 
 134 #define shenandoah_assert_locked_or_safepoint(lock) \
 135                     ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(lock, __FILE__, __LINE__);
 136 #else
 137 #define shenandoah_assert_in_heap(interior_loc, obj)
 138 #define shenandoah_assert_in_correct_region(interior_loc, obj)
 139 
 140 #define shenandoah_assert_correct_if(interior_loc, obj, condition)
 141 #define shenandoah_assert_correct_except(interior_loc, obj, exception)
 142 #define shenandoah_assert_correct(interior_loc, obj)
 143 
 144 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition)
 145 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception)
 146 #define shenandoah_assert_forwarded(interior_loc, obj)
 147 
 148 #define shenandoah_assert_not_forwarded_if(interior_loc, obj, condition)
 149 #define shenandoah_assert_not_forwarded_except(interior_loc, obj, exception)
 150 #define shenandoah_assert_not_forwarded(interior_loc, obj)
 151 
 152 #define shenandoah_assert_marked_if(interior_loc, obj, condition)
 153 #define shenandoah_assert_marked_except(interior_loc, obj, exception)
 154 #define shenandoah_assert_marked(interior_loc, obj)
 155 
 156 #define shenandoah_assert_in_cset_if(interior_loc, obj, condition)
 157 #define shenandoah_assert_in_cset_except(interior_loc, obj, exception)
 158 #define shenandoah_assert_in_cset(interior_loc, obj)
 159 
 160 #define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition)
 161 #define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception)
 162 #define shenandoah_assert_not_in_cset(interior_loc, obj)
 163 
 164 #define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition)
 165 #define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception)
 166 #define shenandoah_assert_not_in_cset_loc(interior_loc)
 167 
 168 #define shenandoah_assert_rp_isalive_installed()
 169 #define shenandoah_assert_rp_isalive_not_installed()
 170 
 171 #define shenandoah_assert_safepoint()
 172 #define shenandoah_assert_locked_or_safepoint(lock)
 173 
 174 #endif
 175 
 176 #define shenandoah_not_implemented \
 177                     { fatal("Deliberately not implemented."); }
 178 #define shenandoah_not_implemented_return(v) \
 179                     { fatal("Deliberately not implemented."); return v; }
 180 
 181 };
 182 
 183 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP


   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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
  26 
  27 #include "memory/iterator.hpp"

  28 #include "utilities/formatBuffer.hpp"
  29 
  30 typedef FormatBuffer<8192> ShenandoahMessageBuffer;
  31 
  32 class ShenandoahAsserts {
  33 public:
  34   enum SafeLevel {
  35     _safe_unknown,
  36     _safe_oop,
  37     _safe_oop_fwd,
  38     _safe_all
  39   };
  40 
  41   static void print_obj(ShenandoahMessageBuffer &msg, oop obj);
  42 
  43   static void print_non_obj(ShenandoahMessageBuffer &msg, void *loc);
  44 
  45   static void print_obj_safe(ShenandoahMessageBuffer &msg, void *loc);
  46 
  47   static void print_failure(SafeLevel level, oop obj, void *interior_loc, oop loc,
  48                             const char *phase, const char *label,
  49                             const char *file, int line);
  50 
  51   static void print_rp_failure(const char *label, BoolObjectClosure* actual,
  52                                const char *file, int line);
  53 
  54   static void assert_in_heap(void* interior_loc, oop obj, const char* file, int line);
  55   static void assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line);
  56 
  57   static void assert_correct(void* interior_loc, oop obj, const char* file, int line);
  58   static void assert_forwarded(void* interior_loc, oop obj, const char* file, int line);
  59   static void assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line);
  60   static void assert_marked(void* interior_loc, oop obj, const char* file, int line);
  61   static void assert_in_cset(void* interior_loc, oop obj, const char* file, int line);
  62   static void assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line);
  63   static void assert_not_in_cset_loc(void* interior_loc, const char* file, int line);
  64 
  65   static void assert_rp_isalive_not_installed(const char *file, int line);
  66   static void assert_rp_isalive_installed(const char *file, int line);
  67 


  68 #ifdef ASSERT
  69 #define shenandoah_assert_in_heap(interior_loc, obj) \
  70                     ShenandoahAsserts::assert_in_heap(interior_loc, obj, __FILE__, __LINE__);
  71 #define shenandoah_assert_in_correct_region(interior_loc, obj) \
  72                     ShenandoahAsserts::assert_in_correct_region(interior_loc, obj, __FILE__, __LINE__);
  73 
  74 #define shenandoah_assert_correct_if(interior_loc, obj, condition) \
  75   if (condition)    ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  76 #define shenandoah_assert_correct_except(interior_loc, obj, exception) \
  77   if (!(exception)) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  78 #define shenandoah_assert_correct(interior_loc, obj) \
  79                     ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__);
  80 
  81 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition) \
  82   if (condition)    ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  83 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception) \
  84   if (!(exception)) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  85 #define shenandoah_assert_forwarded(interior_loc, obj) \
  86                     ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__);
  87 


 107                     ShenandoahAsserts::assert_in_cset(interior_loc, obj, __FILE__, __LINE__);
 108 
 109 #define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition) \
 110   if (condition)    ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 111 #define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception) \
 112   if (!(exception)) ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 113 #define shenandoah_assert_not_in_cset(interior_loc, obj) \
 114                     ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__);
 115 
 116 #define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition) \
 117   if (condition)    ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 118 #define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception) \
 119   if (!(exception)) ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 120 #define shenandoah_assert_not_in_cset_loc(interior_loc) \
 121                     ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__);
 122 
 123 #define shenandoah_assert_rp_isalive_installed() \
 124                     ShenandoahAsserts::assert_rp_isalive_installed(__FILE__, __LINE__);
 125 #define shenandoah_assert_rp_isalive_not_installed() \
 126                     ShenandoahAsserts::assert_rp_isalive_not_installed(__FILE__, __LINE__);






 127 #else
 128 #define shenandoah_assert_in_heap(interior_loc, obj)
 129 #define shenandoah_assert_in_correct_region(interior_loc, obj)
 130 
 131 #define shenandoah_assert_correct_if(interior_loc, obj, condition)
 132 #define shenandoah_assert_correct_except(interior_loc, obj, exception)
 133 #define shenandoah_assert_correct(interior_loc, obj)
 134 
 135 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition)
 136 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception)
 137 #define shenandoah_assert_forwarded(interior_loc, obj)
 138 
 139 #define shenandoah_assert_not_forwarded_if(interior_loc, obj, condition)
 140 #define shenandoah_assert_not_forwarded_except(interior_loc, obj, exception)
 141 #define shenandoah_assert_not_forwarded(interior_loc, obj)
 142 
 143 #define shenandoah_assert_marked_if(interior_loc, obj, condition)
 144 #define shenandoah_assert_marked_except(interior_loc, obj, exception)
 145 #define shenandoah_assert_marked(interior_loc, obj)
 146 
 147 #define shenandoah_assert_in_cset_if(interior_loc, obj, condition)
 148 #define shenandoah_assert_in_cset_except(interior_loc, obj, exception)
 149 #define shenandoah_assert_in_cset(interior_loc, obj)
 150 
 151 #define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition)
 152 #define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception)
 153 #define shenandoah_assert_not_in_cset(interior_loc, obj)
 154 
 155 #define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition)
 156 #define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception)
 157 #define shenandoah_assert_not_in_cset_loc(interior_loc)
 158 
 159 #define shenandoah_assert_rp_isalive_installed()
 160 #define shenandoah_assert_rp_isalive_not_installed()




 161 #endif
 162 
 163 #define shenandoah_not_implemented \
 164                     { fatal("Deliberately not implemented."); }
 165 #define shenandoah_not_implemented_return(v) \
 166                     { fatal("Deliberately not implemented."); return v; }
 167 
 168 };
 169 
 170 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
< prev index next >