comparison src/share/vm/memory/universe.cpp @ 1057:f334aec453a1

6896084: VM does not reserve protected page below heap for compressed oops implicit null checks Summary: Set narrow_oop_base and narrow_oop_use_implicit_null_checks in Universe::preferred_heap_base(). Reviewed-by: twisti, jcoomes
author kvn
date Thu, 29 Oct 2009 16:57:55 -0700
parents 1a81ea4b45d4
children 7c57aead6d3e
comparison
equal deleted inserted replaced
1042:4926bf2d292f 1057:f334aec453a1
742 static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1); 742 static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1);
743 // 32Gb 743 // 32Gb
744 static const uint64_t OopEncodingHeapMax = NarrowOopHeapMax << LogMinObjAlignmentInBytes; 744 static const uint64_t OopEncodingHeapMax = NarrowOopHeapMax << LogMinObjAlignmentInBytes;
745 745
746 char* Universe::preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode) { 746 char* Universe::preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode) {
747 size_t base = 0;
747 #ifdef _LP64 748 #ifdef _LP64
748 if (UseCompressedOops) { 749 if (UseCompressedOops) {
749 assert(mode == UnscaledNarrowOop || 750 assert(mode == UnscaledNarrowOop ||
750 mode == ZeroBasedNarrowOop || 751 mode == ZeroBasedNarrowOop ||
751 mode == HeapBasedNarrowOop, "mode is invalid"); 752 mode == HeapBasedNarrowOop, "mode is invalid");
753 const size_t total_size = heap_size + HeapBaseMinAddress;
752 // Return specified base for the first request. 754 // Return specified base for the first request.
753 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) { 755 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) {
754 return (char*)HeapBaseMinAddress; 756 base = HeapBaseMinAddress;
755 } 757 } else if (total_size <= OopEncodingHeapMax && (mode != HeapBasedNarrowOop)) {
756 const size_t total_size = heap_size + HeapBaseMinAddress;
757 if (total_size <= OopEncodingHeapMax && (mode != HeapBasedNarrowOop)) {
758 if (total_size <= NarrowOopHeapMax && (mode == UnscaledNarrowOop) && 758 if (total_size <= NarrowOopHeapMax && (mode == UnscaledNarrowOop) &&
759 (Universe::narrow_oop_shift() == 0)) { 759 (Universe::narrow_oop_shift() == 0)) {
760 // Use 32-bits oops without encoding and 760 // Use 32-bits oops without encoding and
761 // place heap's top on the 4Gb boundary 761 // place heap's top on the 4Gb boundary
762 return (char*)(NarrowOopHeapMax - heap_size); 762 base = (NarrowOopHeapMax - heap_size);
763 } else { 763 } else {
764 // Can't reserve with NarrowOopShift == 0 764 // Can't reserve with NarrowOopShift == 0
765 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 765 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
766 if (mode == UnscaledNarrowOop || 766 if (mode == UnscaledNarrowOop ||
767 mode == ZeroBasedNarrowOop && total_size <= NarrowOopHeapMax) { 767 mode == ZeroBasedNarrowOop && total_size <= NarrowOopHeapMax) {
768 // Use zero based compressed oops with encoding and 768 // Use zero based compressed oops with encoding and
769 // place heap's top on the 32Gb boundary in case 769 // place heap's top on the 32Gb boundary in case
770 // total_size > 4Gb or failed to reserve below 4Gb. 770 // total_size > 4Gb or failed to reserve below 4Gb.
771 return (char*)(OopEncodingHeapMax - heap_size); 771 base = (OopEncodingHeapMax - heap_size);
772 } 772 }
773 } 773 }
774 } else { 774 } else {
775 // Can't reserve below 32Gb. 775 // Can't reserve below 32Gb.
776 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 776 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
777 } 777 }
778 // Set narrow_oop_base and narrow_oop_use_implicit_null_checks
779 // used in ReservedHeapSpace() constructors.
780 // The final values will be set in initialize_heap() below.
781 if (base != 0 && (base + heap_size) <= OopEncodingHeapMax) {
782 // Use zero based compressed oops
783 Universe::set_narrow_oop_base(NULL);
784 // Don't need guard page for implicit checks in indexed
785 // addressing mode with zero based Compressed Oops.
786 Universe::set_narrow_oop_use_implicit_null_checks(true);
787 } else {
788 // Set to a non-NULL value so the ReservedSpace ctor computes
789 // the correct no-access prefix.
790 // The final value will be set in initialize_heap() below.
791 Universe::set_narrow_oop_base((address)NarrowOopHeapMax);
792 #ifdef _WIN64
793 if (UseLargePages) {
794 // Cannot allocate guard pages for implicit checks in indexed
795 // addressing mode when large pages are specified on windows.
796 Universe::set_narrow_oop_use_implicit_null_checks(false);
797 }
798 #endif // _WIN64
799 }
778 } 800 }
779 #endif 801 #endif
780 return NULL; // also return NULL (don't care) for 32-bit VM 802 return (char*)base; // also return NULL (don't care) for 32-bit VM
781 } 803 }
782 804
783 jint Universe::initialize_heap() { 805 jint Universe::initialize_heap() {
784 806
785 if (UseParallelGC) { 807 if (UseParallelGC) {