8073115: assert(_covered_region.contains(p)) needs better error messages
authorsangheki
Mon, 16 Feb 2015 08:38:23 -0800
changeset 29082 cff77cc6a869
parent 29081 c61eb4914428
child 29083 5e7bce2712ac
8073115: assert(_covered_region.contains(p)) needs better error messages Summary: Changed to print out related values Reviewed-by: jwilhelm, brutisso, stefank
hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp
hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp	Fri Feb 13 14:37:35 2015 +0100
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp	Mon Feb 16 08:38:23 2015 -0800
@@ -126,7 +126,9 @@
 
 bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr,
                                               HeapWord* end_addr) const {
-  assert(start_addr <= end_addr, "range is wrong");
+  assert(start_addr <= end_addr,
+         err_msg("Range is wrong. start_addr (" PTR_FORMAT ") is after end_addr (" PTR_FORMAT ")",
+                 p2i(start_addr), p2i(end_addr)));
   if (start_addr > end_addr) {
     return false;
   }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp	Fri Feb 13 14:37:35 2015 +0100
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp	Mon Feb 16 08:38:23 2015 -0800
@@ -119,8 +119,13 @@
 
   MemRegion covered_region() { return _covered_region; }
 
+#define assert_covered_region_contains(addr)                                                                 \
+        assert(_covered_region.contains(addr),                                                               \
+               err_msg(#addr " (" PTR_FORMAT ") is not in covered region [" PTR_FORMAT ", " PTR_FORMAT "]",  \
+                       p2i(addr), p2i(_covered_region.start()), p2i(_covered_region.end())))
+
   void allocate_block(HeapWord* p) {
-    assert(_covered_region.contains(p), "Must be in covered region");
+    assert_covered_region_contains(p);
     jbyte* block = block_for_addr(p);
     HeapWord* block_base = addr_for_block(block);
     size_t offset = pointer_delta(p, block_base, sizeof(HeapWord*));
@@ -135,7 +140,7 @@
   // object in that block. Scroll backwards by one, and the first
   // object hit should be at the beginning of the block
   HeapWord* object_start(HeapWord* addr) const {
-    assert(_covered_region.contains(addr), "Must be in covered region");
+    assert_covered_region_contains(addr);
     jbyte* block = block_for_addr(addr);
     HeapWord* scroll_forward = offset_addr_for_block(block--);
     while (scroll_forward > addr) {
@@ -153,13 +158,14 @@
   }
 
   bool is_block_allocated(HeapWord* addr) {
-    assert(_covered_region.contains(addr), "Must be in covered region");
+    assert_covered_region_contains(addr);
     jbyte* block = block_for_addr(addr);
     if (*block == clean_block)
       return false;
 
     return true;
   }
+#undef assert_covered_region_contains
 
   // Return true if an object starts in the range of heap addresses.
   // If an object starts at an address corresponding to