< prev index next >

src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * 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.

@@ -58,15 +58,37 @@
   const size_t _max_gen_size;
 
   // Used when initializing the _name field.
   static inline const char* select_name();
 
+#ifdef ASSERT
+#define assert_block_in_covered_region(_block_start_, _word_size_)                          \
+  do {                                                                                      \
+    MemRegion __covered_region__ = this->start_array()->covered_region();                   \
+    MemRegion __new_memregion__(_block_start_, _word_size_);                                \
+    MemRegion __used__ = this->object_space()->used_region();                               \
+    assert(__covered_region__.contains(__new_memregion__),                                  \
+           err_msg("new region is not in covered_region [ "PTR_FORMAT", "PTR_FORMAT" ], "   \
+                   "new region [ "PTR_FORMAT", "PTR_FORMAT" ], "                            \
+                   "object space [ "PTR_FORMAT", "PTR_FORMAT" ]",                           \
+                   p2i(__covered_region__.start()),                                         \
+                   p2i(__covered_region__.end()),                                           \
+                   p2i(__new_memregion__.start()),                                          \
+                   p2i(__new_memregion__.end()),                                            \
+                   p2i(__used__.start()),                                                   \
+                   p2i(__used__.end())));                                                   \
+  } while (0)
+#else
+  #define assert_block_in_covered_region(_block_start_, _word_size_)
+#endif
+
   HeapWord* allocate_noexpand(size_t word_size) {
     // We assume the heap lock is held here.
     assert_locked_or_safepoint(Heap_lock);
     HeapWord* res = object_space()->allocate(word_size);
     if (res != NULL) {
+      assert_block_in_covered_region(res, word_size);
       _start_array.allocate_block(res);
     }
     return res;
   }
 

@@ -75,10 +97,11 @@
   // safe for use at the same time as allocate_noexpand()!
   HeapWord* cas_allocate_noexpand(size_t word_size) {
     assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint");
     HeapWord* res = object_space()->cas_allocate(word_size);
     if (res != NULL) {
+      assert_block_in_covered_region(res, word_size);
       _start_array.allocate_block(res);
     }
     return res;
   }
 
< prev index next >