584 VM_GC_HeapInspection inspector(log.trace_stream(), false /* ! full gc */);
585 inspector.doit();
586 }
587 }
588
589 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
590 full_gc_dump(timer, true);
591 }
592
593 void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
594 full_gc_dump(timer, false);
595 }
596
597 void CollectedHeap::initialize_reserved_region(HeapWord *start, HeapWord *end) {
598 // It is important to do this in a way such that concurrent readers can't
599 // temporarily think something is in the heap. (Seen this happen in asserts.)
600 _reserved.set_word_size(0);
601 _reserved.set_start(start);
602 _reserved.set_end(end);
603 }
604
605 /////////////// Unit tests ///////////////
606
607 #ifndef PRODUCT
608 void CollectedHeap::test_is_in() {
609 CollectedHeap* heap = Universe::heap();
610
611 uintptr_t epsilon = (uintptr_t) MinObjAlignment;
612 uintptr_t heap_start = (uintptr_t) heap->_reserved.start();
613 uintptr_t heap_end = (uintptr_t) heap->_reserved.end();
614
615 // Test that NULL is not in the heap.
616 assert(!heap->is_in(NULL), "NULL is unexpectedly in the heap");
617
618 // Test that a pointer to before the heap start is reported as outside the heap.
619 assert(heap_start >= ((uintptr_t)NULL + epsilon), "sanity");
620 void* before_heap = (void*)(heap_start - epsilon);
621 assert(!heap->is_in(before_heap),
622 "before_heap: " PTR_FORMAT " is unexpectedly in the heap", p2i(before_heap));
623
624 // Test that a pointer to after the heap end is reported as outside the heap.
625 assert(heap_end <= ((uintptr_t)-1 - epsilon), "sanity");
626 void* after_heap = (void*)(heap_end + epsilon);
627 assert(!heap->is_in(after_heap),
628 "after_heap: " PTR_FORMAT " is unexpectedly in the heap", p2i(after_heap));
629 }
630
631 void CollectedHeap_test() {
632 CollectedHeap::test_is_in();
633 }
634 #endif
|
584 VM_GC_HeapInspection inspector(log.trace_stream(), false /* ! full gc */);
585 inspector.doit();
586 }
587 }
588
589 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
590 full_gc_dump(timer, true);
591 }
592
593 void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
594 full_gc_dump(timer, false);
595 }
596
597 void CollectedHeap::initialize_reserved_region(HeapWord *start, HeapWord *end) {
598 // It is important to do this in a way such that concurrent readers can't
599 // temporarily think something is in the heap. (Seen this happen in asserts.)
600 _reserved.set_word_size(0);
601 _reserved.set_start(start);
602 _reserved.set_end(end);
603 }
|