737 #ifdef _LP64 738 if (UseCompressedOops) { 739 // Subtract a page because something can get allocated at heap base. 740 // This also makes implicit null checking work, because the 741 // memory+1 page below heap_base needs to cause a signal. 742 // See needs_explicit_null_check. 743 // Only set the heap base for compressed oops because it indicates 744 // compressed oops for pstack code. 745 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) { 746 // Didn't reserve heap below 4Gb. Must shift. 747 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 748 } 749 if ((uint64_t)Universe::heap()->reserved_region().end() <= OopEncodingHeapMax) { 750 // Did reserve heap below 32Gb. Can use base == 0; 751 Universe::set_narrow_oop_base(0); 752 } 753 754 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base()); 755 756 if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) { 757 Universe::print_compressed_oops_mode(); 758 } 759 760 // Tell tests in which mode we run. 761 Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode", 762 narrow_oop_mode_to_string(narrow_oop_mode()), 763 false)); 764 } 765 // Universe::narrow_oop_base() is one page below the heap. 766 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - 767 os::vm_page_size()) || 768 Universe::narrow_oop_base() == NULL, "invalid value"); 769 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes || 770 Universe::narrow_oop_shift() == 0, "invalid value"); 771 #endif 772 773 // We will never reach the CATCH below since Exceptions::_throw will cause 774 // the VM to exit if an exception is thrown during initialization 775 776 if (UseTLAB) { 777 assert(Universe::heap()->supports_tlab_allocation(), 778 "Should support thread-local allocation buffers"); 779 ThreadLocalAllocBuffer::startup_initialization(); 780 } 781 return JNI_OK; 782 } 783 784 void Universe::print_compressed_oops_mode() { 785 tty->cr(); 786 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", 787 p2i(Universe::heap()->base()), Universe::heap()->reserved_region().byte_size()/M); 788 789 tty->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode())); 790 791 if (Universe::narrow_oop_base() != 0) { 792 tty->print(": " PTR_FORMAT, p2i(Universe::narrow_oop_base())); 793 } 794 795 if (Universe::narrow_oop_shift() != 0) { 796 tty->print(", Oop shift amount: %d", Universe::narrow_oop_shift()); 797 } 798 799 if (!Universe::narrow_oop_use_implicit_null_checks()) { 800 tty->print(", no protected page in front of the heap"); 801 } 802 803 tty->cr(); 804 tty->cr(); 805 } 806 807 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { 808 809 assert(alignment <= Arguments::conservative_max_heap_alignment(), 810 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT, 811 alignment, Arguments::conservative_max_heap_alignment())); 812 813 size_t total_reserved = align_size_up(heap_size, alignment); 814 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())), 815 "heap size is too big for compressed oops"); 816 817 bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size()); 818 assert(!UseLargePages 819 || UseParallelGC 820 || use_large_pages, "Wrong alignment to use large pages"); 821 822 // Now create the space. 823 ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages); 824 | 737 #ifdef _LP64 738 if (UseCompressedOops) { 739 // Subtract a page because something can get allocated at heap base. 740 // This also makes implicit null checking work, because the 741 // memory+1 page below heap_base needs to cause a signal. 742 // See needs_explicit_null_check. 743 // Only set the heap base for compressed oops because it indicates 744 // compressed oops for pstack code. 745 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) { 746 // Didn't reserve heap below 4Gb. Must shift. 747 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 748 } 749 if ((uint64_t)Universe::heap()->reserved_region().end() <= OopEncodingHeapMax) { 750 // Did reserve heap below 32Gb. Can use base == 0; 751 Universe::set_narrow_oop_base(0); 752 } 753 754 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base()); 755 756 if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) { 757 Universe::print_compressed_oops_mode(tty); 758 } 759 760 // Tell tests in which mode we run. 761 Arguments::PropertyList_add(new SystemProperty("java.vm.compressedOopsMode", 762 narrow_oop_mode_to_string(narrow_oop_mode()), 763 false)); 764 } 765 // Universe::narrow_oop_base() is one page below the heap. 766 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - 767 os::vm_page_size()) || 768 Universe::narrow_oop_base() == NULL, "invalid value"); 769 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes || 770 Universe::narrow_oop_shift() == 0, "invalid value"); 771 #endif 772 773 // We will never reach the CATCH below since Exceptions::_throw will cause 774 // the VM to exit if an exception is thrown during initialization 775 776 if (UseTLAB) { 777 assert(Universe::heap()->supports_tlab_allocation(), 778 "Should support thread-local allocation buffers"); 779 ThreadLocalAllocBuffer::startup_initialization(); 780 } 781 return JNI_OK; 782 } 783 784 void Universe::print_compressed_oops_mode(outputStream* st) { 785 st->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", 786 p2i(Universe::heap()->base()), Universe::heap()->reserved_region().byte_size()/M); 787 788 st->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode())); 789 790 if (Universe::narrow_oop_base() != 0) { 791 st->print(": " PTR_FORMAT, p2i(Universe::narrow_oop_base())); 792 } 793 794 if (Universe::narrow_oop_shift() != 0) { 795 st->print(", Oop shift amount: %d", Universe::narrow_oop_shift()); 796 } 797 798 if (!Universe::narrow_oop_use_implicit_null_checks()) { 799 st->print(", no protected page in front of the heap"); 800 } 801 st->cr(); 802 } 803 804 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { 805 806 assert(alignment <= Arguments::conservative_max_heap_alignment(), 807 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT, 808 alignment, Arguments::conservative_max_heap_alignment())); 809 810 size_t total_reserved = align_size_up(heap_size, alignment); 811 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())), 812 "heap size is too big for compressed oops"); 813 814 bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size()); 815 assert(!UseLargePages 816 || UseParallelGC 817 || use_large_pages, "Wrong alignment to use large pages"); 818 819 // Now create the space. 820 ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages); 821 |