comparison src/share/vm/gc_interface/collectedHeap.cpp @ 4708:3c648b9ad052

7121373: Clean up CollectedHeap::is_in Summary: Fixed G1CollectedHeap::is_in, added tests, cleaned up comments and made Space::is_in pure virtual. Reviewed-by: brutisso, tonyp, jcoomes
author stefank
date Wed, 14 Dec 2011 12:15:26 +0100
parents e5928e7dab26
children b6a04c79ccbc
comparison
equal deleted inserted replaced
4132:6d7d0790074d 4708:3c648b9ad052
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