< prev index next >
src/share/vm/gc/shared/collectedHeap.cpp
Print this page
rev 12265 : 8168492: Convert CollectedHeap_test to GTest
Reviewed-by: duke
*** 599,634 ****
// temporarily think something is in the heap. (Seen this happen in asserts.)
_reserved.set_word_size(0);
_reserved.set_start(start);
_reserved.set_end(end);
}
-
- /////////////// Unit tests ///////////////
-
- #ifndef PRODUCT
- void CollectedHeap::test_is_in() {
- CollectedHeap* heap = Universe::heap();
-
- uintptr_t epsilon = (uintptr_t) MinObjAlignment;
- uintptr_t heap_start = (uintptr_t) heap->_reserved.start();
- uintptr_t heap_end = (uintptr_t) heap->_reserved.end();
-
- // Test that NULL is not in the heap.
- assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
-
- // Test that a pointer to before the heap start is reported as outside the heap.
- assert(heap_start >= ((uintptr_t)NULL + epsilon), "sanity");
- void* before_heap = (void*)(heap_start - epsilon);
- assert(!heap->is_in(before_heap),
- "before_heap: " PTR_FORMAT " is unexpectedly in the heap", p2i(before_heap));
-
- // Test that a pointer to after the heap end is reported as outside the heap.
- assert(heap_end <= ((uintptr_t)-1 - epsilon), "sanity");
- void* after_heap = (void*)(heap_end + epsilon);
- assert(!heap->is_in(after_heap),
- "after_heap: " PTR_FORMAT " is unexpectedly in the heap", p2i(after_heap));
- }
-
- void CollectedHeap_test() {
- CollectedHeap::test_is_in();
- }
- #endif
--- 599,603 ----
< prev index next >