Merge
authorcoleenp
Tue, 20 Nov 2012 20:27:40 -0500
changeset 14570 c4327fef74c0
parent 14568 e601a3059a10 (current diff)
parent 14569 96937297368d (diff)
child 14571 1e4d36113875
child 14572 62c896e036da
Merge
--- a/hotspot/src/share/vm/services/memSnapshot.cpp	Fri Nov 16 09:43:43 2012 -0800
+++ b/hotspot/src/share/vm/services/memSnapshot.cpp	Tue Nov 20 20:27:40 2012 -0500
@@ -261,17 +261,19 @@
   VMMemRegion* cur = (VMMemRegion*)current();
   assert(cur->is_reserved_region() && cur->contains_region(rec),
     "Sanity check");
+  if (rec->is_same_region(cur)) {
+    // release whole reserved region
 #ifdef ASSERT
-  VMMemRegion* next_reg = (VMMemRegion*)peek_next();
-  // should not have any committed memory in this reserved region
-  assert(next_reg == NULL || !next_reg->is_committed_region(), "Sanity check");
+    VMMemRegion* next_region = (VMMemRegion*)peek_next();
+    // should not have any committed memory in this reserved region
+    assert(next_region == NULL || !next_region->is_committed_region(), "Sanity check");
 #endif
-  if (rec->is_same_region(cur)) {
     remove();
   } else if (rec->addr() == cur->addr() ||
     rec->addr() + rec->size() == cur->addr() + cur->size()) {
     // released region is at either end of this region
     cur->exclude_region(rec->addr(), rec->size());
+    assert(check_reserved_region(), "Integrity check");
   } else { // split the reserved region and release the middle
     address high_addr = cur->addr() + cur->size();
     size_t sz = high_addr - rec->addr();
@@ -280,10 +282,14 @@
     if (MemTracker::track_callsite()) {
       MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz,
         ((VMMemRegionEx*)cur)->pc());
-      return insert_reserved_region(&tmp);
+      bool ret = insert_reserved_region(&tmp);
+      assert(!ret || check_reserved_region(), "Integrity check");
+      return ret;
     } else {
       MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz);
-      return insert_reserved_region(&tmp);
+      bool ret = insert_reserved_region(&tmp);
+      assert(!ret || check_reserved_region(), "Integrity check");
+      return ret;
     }
   }
   return true;
--- a/hotspot/src/share/vm/services/memSnapshot.hpp	Fri Nov 16 09:43:43 2012 -0800
+++ b/hotspot/src/share/vm/services/memSnapshot.hpp	Tue Nov 20 20:27:40 2012 -0500
@@ -146,6 +146,23 @@
   // reset current position
   inline void reset() { _pos = 0; }
 #ifdef ASSERT
+  // check integrity of records on current reserved memory region.
+  bool check_reserved_region() {
+    VMMemRegion* reserved_region = (VMMemRegion*)current();
+    assert(reserved_region != NULL && reserved_region->is_reserved_region(),
+          "Sanity check");
+    // all committed regions that follow current reserved region, should all
+    // belong to the reserved region.
+    VMMemRegion* next_region = (VMMemRegion*)next();
+    for (; next_region != NULL && next_region->is_committed_region();
+         next_region = (VMMemRegion*)next() ) {
+      if(!reserved_region->contains_region(next_region)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
   virtual bool is_dup_pointer(const MemPointer* ptr1,
     const MemPointer* ptr2) const {
     VMMemRegion* p1 = (VMMemRegion*)ptr1;