< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahAsserts.cpp

Print this page
rev 10497 : [backport] Verifier should dump raw memory around the problematic oops
rev 10580 : [backport] Refactor to group marking bitmap and TAMS structure in one class ShenandoahMarkingContext
rev 10581 : [backport] Refactor alive-closures to deal better with new marking contexts
rev 10609 : [backport] shenandoah_assert_correct should check object/forwardee klasses
rev 10614 : [backport] Replace custom asserts with shenandoah_assert_*
rev 10626 : [backport] shenandoah_assert_correct should verify classes before claiming _safe_oop
rev 10637 : [backport] Purge partial heuristics and connection matrix infrastructure


  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 #include "precompiled.hpp"
  25 
  26 #include "gc_implementation/shenandoah/brooksPointer.hpp"
  27 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
  28 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
  29 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"

  30 #include "memory/resourceArea.hpp"
  31 
  32 





















  33 void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) {
  34   ShenandoahHeap* heap = ShenandoahHeap::heap();
  35   ShenandoahHeapRegion *r = heap->heap_region_containing(obj);
  36 
  37   ResourceMark rm;
  38   stringStream ss;
  39   r->print_on(&ss);
  40 



  41   msg.append("  " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name());
  42   msg.append("    %3s allocated after complete mark start\n", heap->allocated_after_complete_mark_start((HeapWord *) obj) ? "" : "not");
  43   msg.append("    %3s allocated after next mark start\n",     heap->allocated_after_next_mark_start((HeapWord *) obj)     ? "" : "not");
  44   msg.append("    %3s marked complete\n",      heap->is_marked_complete(obj) ? "" : "not");
  45   msg.append("    %3s marked next\n",          heap->is_marked_next(obj) ? "" : "not");
  46   msg.append("    %3s in collection set\n",    heap->in_collection_set(obj) ? "" : "not");
  47   msg.append("  region: %s", ss.as_string());
  48 }
  49 
  50 void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {
  51   ShenandoahHeap* heap = ShenandoahHeap::heap();
  52   if (heap->is_in(loc)) {
  53     msg.append("  inside Java heap\n");
  54     ShenandoahHeapRegion *r = heap->heap_region_containing(loc);
  55     stringStream ss;
  56     r->print_on(&ss);
  57 
  58     msg.append("    %3s in collection set\n",    heap->in_collection_set(loc) ? "" : "not");
  59     msg.append("  region: %s", ss.as_string());
  60   } else {
  61     msg.append("  outside of Java heap\n");
  62     stringStream ss;
  63     os::print_location(&ss, (intptr_t) loc, false);
  64     msg.append("  %s", ss.as_string());
  65   }
  66 }
  67 
  68 void ShenandoahAsserts::print_obj_safe(ShenandoahMessageBuffer& msg, void* loc) {
  69   ShenandoahHeap* heap = ShenandoahHeap::heap();
  70   msg.append("  " PTR_FORMAT " - safe print, no details\n", p2i(loc));
  71   if (heap->is_in(loc)) {
  72     ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
  73     if (r != NULL) {
  74       stringStream ss;
  75       r->print_on(&ss);
  76       msg.append("  region: %s", ss.as_string());

  77     }
  78   }
  79 }
  80 
  81 void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_loc, oop loc,
  82                                        const char* phase, const char* label,
  83                                        const char* file, int line) {
  84   ShenandoahHeap* heap = ShenandoahHeap::heap();
  85   ResourceMark rm;
  86 
  87   bool loc_in_heap = (loc != NULL && heap->is_in(loc));
  88   bool interior_loc_in_heap = (interior_loc != NULL && heap->is_in(interior_loc));
  89 
  90   ShenandoahMessageBuffer msg("%s; %s\n\n", phase, label);
  91 
  92   msg.append("Referenced from:\n");
  93   if (interior_loc != NULL) {
  94     msg.append("  interior location: " PTR_FORMAT "\n", p2i(interior_loc));
  95     if (loc_in_heap) {
  96       print_obj(msg, loc);
  97     } else {
  98       print_non_obj(msg, interior_loc);
  99     }
 100   } else {
 101     msg.append("  no interior location recorded (probably a plain heap scan, or detached oop)\n");
 102   }
 103   msg.append("\n");
 104 
 105   msg.append("Object:\n");
 106   if (level >= _safe_oop) {
 107     print_obj(msg, obj);
 108   } else {


 134       msg.append("\n");
 135     }
 136   }
 137 
 138   report_vm_error(file, line, msg.buffer());
 139 }
 140 
 141 void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char *file, int line) {
 142   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 143 
 144   if (!heap->is_in(obj)) {
 145     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap failed",
 146                   "oop must point to a heap address",
 147                   file, line);
 148   }
 149 }
 150 
 151 void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) {
 152   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 153 
 154   // Step 1. Check that both obj and its fwdptr are in heap.
 155   // After this step, it is safe to call heap_region_containing().
 156   if (!heap->is_in(obj)) {
 157     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 158                   "oop must point to a heap address",
 159                   file, line);
 160   }
 161 
 162   oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));





 163 
 164   if (!heap->is_in(fwd)) {
 165     print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 166                   "Forwardee must point to a heap address",
 167                   file, line);
 168   }
 169 
 170   bool is_forwarded = !oopDesc::unsafe_equals(obj, fwd);


 171 
 172   // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
 173   // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
 174   // that still points to the object itself.
 175 
 176   if (is_forwarded && heap->is_full_gc_move_in_progress()) {
 177     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 178                   "Non-trivial forwarding pointer during Full GC moves, probable bug.",
 179                   file, line);
 180   }
 181 
 182   // Step 2. Check that forwardee points to correct region.
 183   if (is_forwarded &&
 184       (heap->heap_region_index_containing(fwd) ==
 185        heap->heap_region_index_containing(obj))) {











 186     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 187                   "Forwardee should be self, or another region",
 188                   file, line);
 189   }
 190 
 191   // Step 3. Check for multiple forwardings
 192   if (is_forwarded) {
 193     oop fwd2 = oop(BrooksPointer::get_raw_unchecked(fwd));
 194     if (!oopDesc::unsafe_equals(fwd, fwd2)) {
 195       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 196                     "Multiple forwardings",
 197                     file, line);
 198     }
 199   }
 200 }
 201 
 202 void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line) {
 203   assert_correct(interior_loc, obj, file, line);
 204 
 205   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 206   ShenandoahHeapRegion* r = heap->heap_region_containing(obj);
 207   if (!r->is_active()) {
 208     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
 209                   "Object must reside in active region",
 210                   file, line);
 211   }
 212 


 239                   "Object should be forwarded",
 240                   file, line);
 241   }
 242 }
 243 
 244 void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line) {
 245   assert_correct(interior_loc, obj, file, line);
 246   oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
 247 
 248   if (!oopDesc::unsafe_equals(obj, fwd)) {
 249     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_forwarded failed",
 250                   "Object should not be forwarded",
 251                   file, line);
 252   }
 253 }
 254 
 255 void ShenandoahAsserts::assert_marked_complete(void* interior_loc, oop obj, const char* file, int line) {
 256   assert_correct(interior_loc, obj, file, line);
 257 
 258   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 259   if (!heap->is_marked_complete(obj)) {
 260     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_complete failed",
 261                   "Object should be marked (complete)",
 262                   file, line);
 263   }
 264 }
 265 
 266 void ShenandoahAsserts::assert_marked_next(void* interior_loc, oop obj, const char* file, int line) {
 267   assert_correct(interior_loc, obj, file, line);
 268 
 269   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 270   if (!heap->is_marked_next(obj)) {
 271     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_next failed",
 272                   "Object should be marked (next)",
 273                   file, line);
 274   }
 275 }
 276 











 277 void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line) {
 278   assert_correct(interior_loc, obj, file, line);
 279 
 280   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 281   if (heap->in_collection_set(obj)) {
 282     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_in_cset failed",
 283                   "Object should not be in collection set",
 284                   file, line);
 285   }
 286 }
 287 
 288 void ShenandoahAsserts::assert_not_in_cset_loc(void* interior_loc, const char* file, int line) {
 289   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 290   if (heap->in_collection_set(interior_loc)) {
 291     print_failure(_safe_unknown, NULL, interior_loc, NULL, "Shenandoah assert_not_in_cset_loc failed",
 292                   "Interior location should not be in collection set",
 293                   file, line);
 294   }
 295 }
 296 
 297 void ShenandoahAsserts::print_rp_failure(const char *label, BoolObjectClosure* actual, BoolObjectClosure* expected,
 298                                          const char *file, int line) {
 299   ShenandoahHeap* heap = ShenandoahHeap::heap();
 300   ShenandoahMessageBuffer msg("%s\n", label);
 301   msg.append(" Actual:                  " PTR_FORMAT "\n", p2i(actual));
 302   msg.append(" Expected:                " PTR_FORMAT "\n", p2i(expected));
 303   msg.append(" SH->_is_alive:           " PTR_FORMAT "\n", p2i(&heap->_is_alive));
 304   msg.append(" SH->_forwarded_is_alive: " PTR_FORMAT "\n", p2i(&heap->_forwarded_is_alive));
 305   report_vm_error(file, line, msg.buffer());
 306 }
 307 
 308 void ShenandoahAsserts::assert_rp_isalive_not_installed(const char *file, int line) {
 309   ShenandoahHeap* heap = ShenandoahHeap::heap();
 310   ReferenceProcessor* rp = heap->ref_processor();
 311   if (rp->is_alive_non_header() != NULL) {
 312     print_rp_failure("Shenandoah assert_rp_isalive_not_installed failed", rp->is_alive_non_header(), NULL,
 313                      file, line);
 314   }
 315 }
 316 
 317 void ShenandoahAsserts::assert_rp_isalive_installed(const char *file, int line) {
 318   ShenandoahHeap* heap = ShenandoahHeap::heap();
 319   ReferenceProcessor* rp = heap->ref_processor();
 320   if (rp->is_alive_non_header() != heap->is_alive_closure()) {
 321     print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(), heap->is_alive_closure(),
 322                      file, line);
 323   }
 324 }


  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 #include "precompiled.hpp"
  25 
  26 #include "gc_implementation/shenandoah/brooksPointer.hpp"
  27 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
  28 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
  29 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
  30 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
  31 #include "memory/resourceArea.hpp"
  32 
  33 
  34 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
  35   // Be extra safe. Only access data that is guaranteed to be safe:
  36   // should be in heap, in known committed region, within that region.
  37 
  38   ShenandoahHeap* heap = ShenandoahHeap::heap();
  39   if (!heap->is_in(loc)) return;
  40 
  41   ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
  42   if (r != NULL && r->is_committed()) {
  43 
  44     address start = MAX2((address) r->bottom(), (address) loc - 32);
  45     address end   = MIN2((address) r->end(),    (address) loc + 128);
  46     if (start >= end) return;
  47 
  48     stringStream ss;
  49     os::print_hex_dump(&ss, start, end, 4);
  50     msg.append("\n");
  51     msg.append("Raw heap memory:\n%s", ss.as_string());
  52   }
  53 }
  54 
  55 void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) {
  56   ShenandoahHeap* heap = ShenandoahHeap::heap();
  57   ShenandoahHeapRegion *r = heap->heap_region_containing(obj);
  58 
  59   ResourceMark rm;
  60   stringStream ss;
  61   r->print_on(&ss);
  62 
  63   ShenandoahMarkingContext* const next_ctx = heap->next_marking_context();
  64   ShenandoahMarkingContext* const compl_ctx = heap->complete_marking_context();
  65 
  66   msg.append("  " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name());
  67   msg.append("    %3s allocated after complete mark start\n", compl_ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not");
  68   msg.append("    %3s allocated after next mark start\n",     next_ctx->allocated_after_mark_start((HeapWord *) obj)     ? "" : "not");
  69   msg.append("    %3s marked complete\n",      compl_ctx->is_marked(obj) ? "" : "not");
  70   msg.append("    %3s marked next\n",          next_ctx->is_marked(obj) ? "" : "not");
  71   msg.append("    %3s in collection set\n",    heap->in_collection_set(obj) ? "" : "not");
  72   msg.append("  region: %s", ss.as_string());
  73 }
  74 
  75 void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {
  76   ShenandoahHeap* heap = ShenandoahHeap::heap();
  77   if (heap->is_in(loc)) {
  78     msg.append("  inside Java heap\n");
  79     ShenandoahHeapRegion *r = heap->heap_region_containing(loc);
  80     stringStream ss;
  81     r->print_on(&ss);
  82 
  83     msg.append("    %3s in collection set\n",    heap->in_collection_set(loc) ? "" : "not");
  84     msg.append("  region: %s", ss.as_string());
  85   } else {
  86     msg.append("  outside of Java heap\n");
  87     stringStream ss;
  88     os::print_location(&ss, (intptr_t) loc, false);
  89     msg.append("  %s", ss.as_string());
  90   }
  91 }
  92 
  93 void ShenandoahAsserts::print_obj_safe(ShenandoahMessageBuffer& msg, void* loc) {
  94   ShenandoahHeap* heap = ShenandoahHeap::heap();
  95   msg.append("  " PTR_FORMAT " - safe print, no details\n", p2i(loc));
  96   if (heap->is_in(loc)) {
  97     ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
  98     if (r != NULL) {
  99       stringStream ss;
 100       r->print_on(&ss);
 101       msg.append("  region: %s", ss.as_string());
 102       print_raw_memory(msg, loc);
 103     }
 104   }
 105 }
 106 
 107 void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_loc, oop loc,
 108                                        const char* phase, const char* label,
 109                                        const char* file, int line) {
 110   ShenandoahHeap* heap = ShenandoahHeap::heap();
 111   ResourceMark rm;
 112 
 113   bool loc_in_heap = (loc != NULL && heap->is_in(loc));

 114 
 115   ShenandoahMessageBuffer msg("%s; %s\n\n", phase, label);
 116 
 117   msg.append("Referenced from:\n");
 118   if (interior_loc != NULL) {
 119     msg.append("  interior location: " PTR_FORMAT "\n", p2i(interior_loc));
 120     if (loc_in_heap) {
 121       print_obj(msg, loc);
 122     } else {
 123       print_non_obj(msg, interior_loc);
 124     }
 125   } else {
 126     msg.append("  no interior location recorded (probably a plain heap scan, or detached oop)\n");
 127   }
 128   msg.append("\n");
 129 
 130   msg.append("Object:\n");
 131   if (level >= _safe_oop) {
 132     print_obj(msg, obj);
 133   } else {


 159       msg.append("\n");
 160     }
 161   }
 162 
 163   report_vm_error(file, line, msg.buffer());
 164 }
 165 
 166 void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char *file, int line) {
 167   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 168 
 169   if (!heap->is_in(obj)) {
 170     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap failed",
 171                   "oop must point to a heap address",
 172                   file, line);
 173   }
 174 }
 175 
 176 void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) {
 177   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 178 
 179   // Step 1. Check that obj is correct.
 180   // After this step, it is safe to call heap_region_containing().
 181   if (!heap->is_in(obj)) {
 182     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 183                   "oop must point to a heap address",
 184                   file, line);
 185   }
 186 
 187   Klass* obj_klass = obj->klass_or_null();
 188   if (obj_klass == NULL) {
 189     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 190                   "Object klass pointer should not be NULL",
 191                   file,line);
 192   }
 193 
 194   if (!Metaspace::contains(obj_klass)) {
 195     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 196                   "Object klass pointer must go to metaspace",
 197                   file,line);
 198   }
 199 
 200   oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
 201 
 202   if (!oopDesc::unsafe_equals(obj, fwd)) {
 203 
 204     // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
 205     // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
 206     // that still points to the object itself.
 207     if (heap->is_full_gc_move_in_progress()) {
 208       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",

 209                     "Non-trivial forwarding pointer during Full GC moves, probable bug.",
 210                     file, line);
 211     }
 212 
 213     // Step 2. Check that forwardee is correct
 214     if (!heap->is_in(fwd)) {
 215       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 216                     "Forwardee must point to a heap address",
 217                     file, line);
 218     }
 219 
 220     if (obj_klass != fwd->klass()) {
 221       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 222                     "Forwardee klass disagrees with object class",
 223                     file, line);
 224     }
 225 
 226     // Step 3. Check that forwardee points to correct region
 227     if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) {
 228       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 229                     "Non-trivial forwardee should in another region",
 230                     file, line);
 231     }
 232 
 233     // Step 4. Check for multiple forwardings

 234     oop fwd2 = oop(BrooksPointer::get_raw_unchecked(fwd));
 235     if (!oopDesc::unsafe_equals(fwd, fwd2)) {
 236       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
 237                     "Multiple forwardings",
 238                     file, line);
 239     }
 240   }
 241 }
 242 
 243 void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line) {
 244   assert_correct(interior_loc, obj, file, line);
 245 
 246   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 247   ShenandoahHeapRegion* r = heap->heap_region_containing(obj);
 248   if (!r->is_active()) {
 249     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
 250                   "Object must reside in active region",
 251                   file, line);
 252   }
 253 


 280                   "Object should be forwarded",
 281                   file, line);
 282   }
 283 }
 284 
 285 void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line) {
 286   assert_correct(interior_loc, obj, file, line);
 287   oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
 288 
 289   if (!oopDesc::unsafe_equals(obj, fwd)) {
 290     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_forwarded failed",
 291                   "Object should not be forwarded",
 292                   file, line);
 293   }
 294 }
 295 
 296 void ShenandoahAsserts::assert_marked_complete(void* interior_loc, oop obj, const char* file, int line) {
 297   assert_correct(interior_loc, obj, file, line);
 298 
 299   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 300   if (!heap->complete_marking_context()->is_marked(obj)) {
 301     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_complete failed",
 302                   "Object should be marked (complete)",
 303                   file, line);
 304   }
 305 }
 306 
 307 void ShenandoahAsserts::assert_marked_next(void* interior_loc, oop obj, const char* file, int line) {
 308   assert_correct(interior_loc, obj, file, line);
 309 
 310   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 311   if (!heap->next_marking_context()->is_marked(obj)) {
 312     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_next failed",
 313                   "Object should be marked (next)",
 314                   file, line);
 315   }
 316 }
 317 
 318 void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char* file, int line) {
 319   assert_correct(interior_loc, obj, file, line);
 320 
 321   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 322   if (!heap->in_collection_set(obj)) {
 323     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_in_cset failed",
 324                   "Object should be in collection set",
 325                   file, line);
 326   }
 327 }
 328 
 329 void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line) {
 330   assert_correct(interior_loc, obj, file, line);
 331 
 332   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 333   if (heap->in_collection_set(obj)) {
 334     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_in_cset failed",
 335                   "Object should not be in collection set",
 336                   file, line);
 337   }
 338 }
 339 
 340 void ShenandoahAsserts::assert_not_in_cset_loc(void* interior_loc, const char* file, int line) {
 341   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
 342   if (heap->in_collection_set(interior_loc)) {
 343     print_failure(_safe_unknown, NULL, interior_loc, NULL, "Shenandoah assert_not_in_cset_loc failed",
 344                   "Interior location should not be in collection set",
 345                   file, line);
 346   }
 347 }
 348 
 349 void ShenandoahAsserts::print_rp_failure(const char *label, BoolObjectClosure* actual,
 350                                          const char *file, int line) {
 351   ShenandoahHeap* heap = ShenandoahHeap::heap();
 352   ShenandoahMessageBuffer msg("%s\n", label);
 353   msg.append(" Actual:                  " PTR_FORMAT "\n", p2i(actual));



 354   report_vm_error(file, line, msg.buffer());
 355 }
 356 
 357 void ShenandoahAsserts::assert_rp_isalive_not_installed(const char *file, int line) {
 358   ShenandoahHeap* heap = ShenandoahHeap::heap();
 359   ReferenceProcessor* rp = heap->ref_processor();
 360   if (rp->is_alive_non_header() != NULL) {
 361     print_rp_failure("Shenandoah assert_rp_isalive_not_installed failed", rp->is_alive_non_header(),
 362                      file, line);
 363   }
 364 }
 365 
 366 void ShenandoahAsserts::assert_rp_isalive_installed(const char *file, int line) {
 367   ShenandoahHeap* heap = ShenandoahHeap::heap();
 368   ReferenceProcessor* rp = heap->ref_processor();
 369   if (rp->is_alive_non_header() == NULL) {
 370     print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(),
 371                      file, line);
 372   }
 373 }
< prev index next >