< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2018, 2019, 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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
 27 #define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
 28 
 29 #include "memory/iterator.hpp"

 30 #include "runtime/mutex.hpp"
 31 #include "utilities/formatBuffer.hpp"
 32 
 33 typedef FormatBuffer<8192> ShenandoahMessageBuffer;
 34 
 35 class ShenandoahAsserts {
 36 public:
 37   enum SafeLevel {
 38     _safe_unknown,
 39     _safe_oop,
 40     _safe_oop_fwd,
 41     _safe_all
 42   };
 43 
 44   static void print_obj(ShenandoahMessageBuffer &msg, oop obj);
 45 
 46   static void print_non_obj(ShenandoahMessageBuffer &msg, void *loc);
 47 
 48   static void print_obj_safe(ShenandoahMessageBuffer &msg, void *loc);
 49 

 60 
 61   static void assert_correct(void* interior_loc, oop obj, const char* file, int line);
 62   static void assert_forwarded(void* interior_loc, oop obj, const char* file, int line);
 63   static void assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line);
 64   static void assert_marked(void* interior_loc, oop obj, const char* file, int line);
 65   static void assert_marked_weak(void* interior_loc, oop obj, const char* file, int line);
 66   static void assert_marked_strong(void* interior_loc, oop obj, const char* file, int line);
 67   static void assert_in_cset(void* interior_loc, oop obj, const char* file, int line);
 68   static void assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line);
 69   static void assert_not_in_cset_loc(void* interior_loc, const char* file, int line);
 70 
 71   static void assert_locked_or_shenandoah_safepoint(Mutex* lock, const char* file, int line);
 72 
 73   static void assert_heaplocked(const char* file, int line);
 74   static void assert_not_heaplocked(const char* file, int line);
 75   static void assert_heaplocked_or_safepoint(const char* file, int line);
 76   static void assert_control_or_vm_thread_at_safepoint(bool at_safepoint, const char* file, int line);
 77   static void assert_generational(const char* file, int line);
 78   static void assert_generations_reconciled(const char* file, int line);
 79 





 80 #ifdef ASSERT
 81 #define shenandoah_assert_in_heap_bounds(interior_loc, obj) \
 82                     ShenandoahAsserts::assert_in_heap_bounds(interior_loc, obj, __FILE__, __LINE__)
 83 #define shenandoah_assert_in_heap_bounds_or_null(interior_loc, obj) \
 84                     ShenandoahAsserts::assert_in_heap_bounds_or_null(interior_loc, obj, __FILE__, __LINE__)
 85 #define shenandoah_assert_in_correct_region(interior_loc, obj) \
 86                     ShenandoahAsserts::assert_in_correct_region(interior_loc, obj, __FILE__, __LINE__)
 87 
 88 #define shenandoah_assert_correct_if(interior_loc, obj, condition) \
 89   if (condition)    ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
 90 #define shenandoah_assert_correct_except(interior_loc, obj, exception) \
 91   if (!(exception)) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
 92 #define shenandoah_assert_correct(interior_loc, obj) \
 93                     ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
 94 
 95 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition) \
 96   if (condition)    ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
 97 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception) \
 98   if (!(exception)) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
 99 #define shenandoah_assert_forwarded(interior_loc, obj) \

  1 /*
  2  * Copyright (c) 2018, 2025, 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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
 27 #define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
 28 
 29 #include "memory/iterator.hpp"
 30 #include "oops/compressedKlass.hpp"
 31 #include "runtime/mutex.hpp"
 32 #include "utilities/formatBuffer.hpp"
 33 
 34 typedef FormatBuffer<8192> ShenandoahMessageBuffer;
 35 
 36 class ShenandoahAsserts {
 37 public:
 38   enum SafeLevel {
 39     _safe_unknown,
 40     _safe_oop,
 41     _safe_oop_fwd,
 42     _safe_all
 43   };
 44 
 45   static void print_obj(ShenandoahMessageBuffer &msg, oop obj);
 46 
 47   static void print_non_obj(ShenandoahMessageBuffer &msg, void *loc);
 48 
 49   static void print_obj_safe(ShenandoahMessageBuffer &msg, void *loc);
 50 

 61 
 62   static void assert_correct(void* interior_loc, oop obj, const char* file, int line);
 63   static void assert_forwarded(void* interior_loc, oop obj, const char* file, int line);
 64   static void assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line);
 65   static void assert_marked(void* interior_loc, oop obj, const char* file, int line);
 66   static void assert_marked_weak(void* interior_loc, oop obj, const char* file, int line);
 67   static void assert_marked_strong(void* interior_loc, oop obj, const char* file, int line);
 68   static void assert_in_cset(void* interior_loc, oop obj, const char* file, int line);
 69   static void assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line);
 70   static void assert_not_in_cset_loc(void* interior_loc, const char* file, int line);
 71 
 72   static void assert_locked_or_shenandoah_safepoint(Mutex* lock, const char* file, int line);
 73 
 74   static void assert_heaplocked(const char* file, int line);
 75   static void assert_not_heaplocked(const char* file, int line);
 76   static void assert_heaplocked_or_safepoint(const char* file, int line);
 77   static void assert_control_or_vm_thread_at_safepoint(bool at_safepoint, const char* file, int line);
 78   static void assert_generational(const char* file, int line);
 79   static void assert_generations_reconciled(const char* file, int line);
 80 
 81   // Given a possibly invalid oop, extract narrowKlass (if UCCP) and Klass*
 82   // from it safely.
 83   // Note: For -UCCP, returned nk is always 0.
 84   static bool extract_klass_safely(oop obj, narrowKlass& nk, const Klass*& k);
 85 
 86 #ifdef ASSERT
 87 #define shenandoah_assert_in_heap_bounds(interior_loc, obj) \
 88                     ShenandoahAsserts::assert_in_heap_bounds(interior_loc, obj, __FILE__, __LINE__)
 89 #define shenandoah_assert_in_heap_bounds_or_null(interior_loc, obj) \
 90                     ShenandoahAsserts::assert_in_heap_bounds_or_null(interior_loc, obj, __FILE__, __LINE__)
 91 #define shenandoah_assert_in_correct_region(interior_loc, obj) \
 92                     ShenandoahAsserts::assert_in_correct_region(interior_loc, obj, __FILE__, __LINE__)
 93 
 94 #define shenandoah_assert_correct_if(interior_loc, obj, condition) \
 95   if (condition)    ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
 96 #define shenandoah_assert_correct_except(interior_loc, obj, exception) \
 97   if (!(exception)) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
 98 #define shenandoah_assert_correct(interior_loc, obj) \
 99                     ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
100 
101 #define shenandoah_assert_forwarded_if(interior_loc, obj, condition) \
102   if (condition)    ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
103 #define shenandoah_assert_forwarded_except(interior_loc, obj, exception) \
104   if (!(exception)) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
105 #define shenandoah_assert_forwarded(interior_loc, obj) \
< prev index next >