hotspot/src/share/vm/gc_interface/collectedHeap.cpp
changeset 11414 5179aa58e6e9
parent 11247 d6faa02b3802
child 11636 3c07b54482a5
equal deleted inserted replaced
11403:2a7f52ac7ce3 11414:5179aa58e6e9
   476 
   476 
   477 #ifndef PRODUCT
   477 #ifndef PRODUCT
   478 void CollectedHeap::test_is_in() {
   478 void CollectedHeap::test_is_in() {
   479   CollectedHeap* heap = Universe::heap();
   479   CollectedHeap* heap = Universe::heap();
   480 
   480 
       
   481   uintptr_t epsilon    = (uintptr_t) MinObjAlignment;
       
   482   uintptr_t heap_start = (uintptr_t) heap->_reserved.start();
       
   483   uintptr_t heap_end   = (uintptr_t) heap->_reserved.end();
       
   484 
   481   // Test that NULL is not in the heap.
   485   // Test that NULL is not in the heap.
   482   assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
   486   assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
   483 
   487 
   484   // Test that a pointer to before the heap start is reported as outside the heap.
   488   // Test that a pointer to before the heap start is reported as outside the heap.
   485   assert(heap->_reserved.start() >= (void*)MinObjAlignment, "sanity");
   489   assert(heap_start >= ((uintptr_t)NULL + epsilon), "sanity");
   486   void* before_heap = (void*)((intptr_t)heap->_reserved.start() - MinObjAlignment);
   490   void* before_heap = (void*)(heap_start - epsilon);
   487   assert(!heap->is_in(before_heap),
   491   assert(!heap->is_in(before_heap),
   488       err_msg("before_heap: " PTR_FORMAT " is unexpectedly in the heap", before_heap));
   492       err_msg("before_heap: " PTR_FORMAT " is unexpectedly in the heap", before_heap));
   489 
   493 
   490   // Test that a pointer to after the heap end is reported as outside the heap.
   494   // 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");
   495   assert(heap_end <= ((uintptr_t)-1 - epsilon), "sanity");
   492   void* after_heap = (void*)((intptr_t)heap->_reserved.end() + MinObjAlignment);
   496   void* after_heap = (void*)(heap_end + epsilon);
   493   assert(!heap->is_in(after_heap),
   497   assert(!heap->is_in(after_heap),
   494       err_msg("after_heap: " PTR_FORMAT " is unexpectedly in the heap", after_heap));
   498       err_msg("after_heap: " PTR_FORMAT " is unexpectedly in the heap", after_heap));
   495 }
   499 }
   496 #endif
   500 #endif