< prev index next >

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

Print this page
rev 10658 : [backport] Single marking bitmap
rev 10669 : [backport] Clean up dead code
rev 10715 : [backport] Cleanup up superfluous newlines
rev 10724 : [backport] Add JFR parallel and concurrent events (infrastructure)
rev 10764 : [backport] Rename BrooksPointer to ShenandoahBrooksPointer
rev 10772 : [backport] Update copyrights

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2018, Red Hat, Inc. and/or its affiliates.
+ * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
  *

@@ -21,28 +21,27 @@
  *
  */
 
 #include "precompiled.hpp"
 
-#include "gc_implementation/shenandoah/brooksPointer.hpp"
 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
+#include "gc_implementation/shenandoah/shenandoahBrooksPointer.hpp"
 #include "gc_implementation/shenandoah/shenandoahHeap.hpp"
 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
+#include "gc_implementation/shenandoah/shenandoahUtils.hpp"
 #include "memory/resourceArea.hpp"
 
-
 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
   // Be extra safe. Only access data that is guaranteed to be safe:
   // should be in heap, in known committed region, within that region.
 
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   if (!heap->is_in(loc)) return;
 
   ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
   if (r != NULL && r->is_committed()) {
-
     address start = MAX2((address) r->bottom(), (address) loc - 32);
     address end   = MIN2((address) r->end(),    (address) loc + 128);
     if (start >= end) return;
 
     stringStream ss;

@@ -58,18 +57,15 @@
 
   ResourceMark rm;
   stringStream ss;
   r->print_on(&ss);
 
-  ShenandoahMarkingContext* const next_ctx = heap->next_marking_context();
-  ShenandoahMarkingContext* const compl_ctx = heap->complete_marking_context();
+  ShenandoahMarkingContext* const ctx = heap->marking_context();
 
   msg.append("  " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name());
-  msg.append("    %3s allocated after complete mark start\n", compl_ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not");
-  msg.append("    %3s allocated after next mark start\n",     next_ctx->allocated_after_mark_start((HeapWord *) obj)     ? "" : "not");
-  msg.append("    %3s marked complete\n",      compl_ctx->is_marked(obj) ? "" : "not");
-  msg.append("    %3s marked next\n",          next_ctx->is_marked(obj) ? "" : "not");
+  msg.append("    %3s allocated after mark start\n", ctx->allocated_after_mark_start((HeapWord *) obj)     ? "" : "not");
+  msg.append("    %3s marked \n",                    ctx->is_marked(obj) ? "" : "not");
   msg.append("    %3s in collection set\n",    heap->in_collection_set(obj) ? "" : "not");
   msg.append("  region: %s", ss.as_string());
 }
 
 void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {

@@ -134,11 +130,11 @@
     print_obj_safe(msg, obj);
   }
   msg.append("\n");
 
   if (level >= _safe_oop) {
-    oop fwd = (oop) BrooksPointer::get_raw_unchecked(obj);
+    oop fwd = (oop) ShenandoahBrooksPointer::get_raw_unchecked(obj);
     msg.append("Forwardee:\n");
     if (!oopDesc::unsafe_equals(obj, fwd)) {
       if (level >= _safe_oop_fwd) {
         print_obj(msg, fwd);
       } else {

@@ -149,12 +145,12 @@
     }
     msg.append("\n");
   }
 
   if (level >= _safe_oop_fwd) {
-    oop fwd = (oop) BrooksPointer::get_raw_unchecked(obj);
-    oop fwd2 = (oop) BrooksPointer::get_raw_unchecked(fwd);
+    oop fwd = (oop) ShenandoahBrooksPointer::get_raw_unchecked(obj);
+    oop fwd2 = (oop) ShenandoahBrooksPointer::get_raw_unchecked(fwd);
     if (!oopDesc::unsafe_equals(fwd, fwd2)) {
       msg.append("Second forwardee:\n");
       print_obj_safe(msg, fwd2);
       msg.append("\n");
     }

@@ -195,14 +191,13 @@
     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
                   "Object klass pointer must go to metaspace",
                   file,line);
   }
 
-  oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
+  oop fwd = oop(ShenandoahBrooksPointer::get_raw_unchecked(obj));
 
   if (!oopDesc::unsafe_equals(obj, fwd)) {
-
     // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something
     // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr
     // that still points to the object itself.
     if (heap->is_full_gc_move_in_progress()) {
       print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed",

@@ -229,11 +224,11 @@
                     "Non-trivial forwardee should in another region",
                     file, line);
     }
 
     // Step 4. Check for multiple forwardings
-    oop fwd2 = oop(BrooksPointer::get_raw_unchecked(fwd));
+    oop fwd2 = oop(ShenandoahBrooksPointer::get_raw_unchecked(fwd));
     if (!oopDesc::unsafe_equals(fwd, fwd2)) {
       print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed",
                     "Multiple forwardings",
                     file, line);
     }

@@ -249,11 +244,11 @@
     print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed",
                   "Object must reside in active region",
                   file, line);
   }
 
-  size_t alloc_size = obj->size() + BrooksPointer::word_size();
+  size_t alloc_size = obj->size() + ShenandoahBrooksPointer::word_size();
   if (alloc_size > ShenandoahHeapRegion::humongous_threshold_words()) {
     size_t idx = r->region_number();
     size_t num_regions = ShenandoahHeapRegion::required_regions(alloc_size * HeapWordSize);
     for (size_t i = idx; i < idx + num_regions; i++) {
       ShenandoahHeapRegion* chain_reg = heap->get_region(i);

@@ -271,48 +266,37 @@
   }
 }
 
 void ShenandoahAsserts::assert_forwarded(void* interior_loc, oop obj, const char* file, int line) {
   assert_correct(interior_loc, obj, file, line);
-  oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
+  oop fwd = oop(ShenandoahBrooksPointer::get_raw_unchecked(obj));
 
   if (oopDesc::unsafe_equals(obj, fwd)) {
     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_forwarded failed",
                   "Object should be forwarded",
                   file, line);
   }
 }
 
 void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line) {
   assert_correct(interior_loc, obj, file, line);
-  oop fwd = oop(BrooksPointer::get_raw_unchecked(obj));
+  oop fwd = oop(ShenandoahBrooksPointer::get_raw_unchecked(obj));
 
   if (!oopDesc::unsafe_equals(obj, fwd)) {
     print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_forwarded failed",
                   "Object should not be forwarded",
                   file, line);
   }
 }
 
-void ShenandoahAsserts::assert_marked_complete(void* interior_loc, oop obj, const char* file, int line) {
+void ShenandoahAsserts::assert_marked(void *interior_loc, oop obj, const char *file, int line) {
   assert_correct(interior_loc, obj, file, line);
 
   ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
-  if (!heap->complete_marking_context()->is_marked(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_complete failed",
-                  "Object should be marked (complete)",
-                  file, line);
-  }
-}
-
-void ShenandoahAsserts::assert_marked_next(void* interior_loc, oop obj, const char* file, int line) {
-  assert_correct(interior_loc, obj, file, line);
-
-  ShenandoahHeap* heap = ShenandoahHeap::heap_no_check();
-  if (!heap->next_marking_context()->is_marked(obj)) {
-    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_next failed",
-                  "Object should be marked (next)",
+  if (!heap->marking_context()->is_marked(obj)) {
+    print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked failed",
+                  "Object should be marked",
                   file, line);
   }
 }
 
 void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char* file, int line) {

@@ -346,11 +330,10 @@
   }
 }
 
 void ShenandoahAsserts::print_rp_failure(const char *label, BoolObjectClosure* actual,
                                          const char *file, int line) {
-  ShenandoahHeap* heap = ShenandoahHeap::heap();
   ShenandoahMessageBuffer msg("%s\n", label);
   msg.append(" Actual:                  " PTR_FORMAT "\n", p2i(actual));
   report_vm_error(file, line, msg.buffer());
 }
 
< prev index next >