hotspot/src/share/vm/gc_interface/collectedHeap.cpp
changeset 11247 d6faa02b3802
parent 10742 a64c942e4e6b
child 11414 5179aa58e6e9
equal deleted inserted replaced
11208:101816314520 11247:d6faa02b3802
   469   // notify jvmti and dtrace
   469   // notify jvmti and dtrace
   470   post_allocation_notify(klass, (oop)obj);
   470   post_allocation_notify(klass, (oop)obj);
   471 
   471 
   472   return mirror;
   472   return mirror;
   473 }
   473 }
       
   474 
       
   475 /////////////// Unit tests ///////////////
       
   476 
       
   477 #ifndef PRODUCT
       
   478 void CollectedHeap::test_is_in() {
       
   479   CollectedHeap* heap = Universe::heap();
       
   480 
       
   481   // Test that NULL is not in the heap.
       
   482   assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
       
   483 
       
   484   // Test that a pointer to before the heap start is reported as outside the heap.
       
   485   assert(heap->_reserved.start() >= (void*)MinObjAlignment, "sanity");
       
   486   void* before_heap = (void*)((intptr_t)heap->_reserved.start() - MinObjAlignment);
       
   487   assert(!heap->is_in(before_heap),
       
   488       err_msg("before_heap: " PTR_FORMAT " is unexpectedly in the heap", before_heap));
       
   489 
       
   490   // Test that a pointer to after the heap end is reported as outside the heap.
       
   491   assert(heap->_reserved.end() <= (void*)(uintptr_t(-1) - (uint)MinObjAlignment), "sanity");
       
   492   void* after_heap = (void*)((intptr_t)heap->_reserved.end() + MinObjAlignment);
       
   493   assert(!heap->is_in(after_heap),
       
   494       err_msg("after_heap: " PTR_FORMAT " is unexpectedly in the heap", after_heap));
       
   495 }
       
   496 #endif